1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- use std:: collections:: HashSet ;
1615use std:: num:: NonZero ;
1716use std:: sync:: Arc ;
1817use std:: time:: Duration ;
@@ -39,12 +38,10 @@ use crate::cache::{CacheManager, CacheManagerRef};
3938use crate :: compaction:: picker:: PickerOutput ;
4039use crate :: compaction:: { CompactionOutput , CompactionSstReaderBuilder , find_dynamic_options} ;
4140use crate :: config:: MitoConfig ;
42- use crate :: engine:: flush_hook:: FlushHookRef ;
4341use crate :: error;
4442use crate :: error:: {
4543 EmptyRegionDirSnafu , InvalidPartitionExprSnafu , ObjectStoreNotFoundSnafu , Result ,
4644} ;
47- use crate :: flush:: { SharedPrimaryKeys , wrap_with_pk_collector} ;
4845use crate :: manifest:: action:: { RegionEdit , RegionMetaAction , RegionMetaActionList } ;
4946use crate :: manifest:: manager:: { RegionManifestManager , RegionManifestOptions } ;
5047use crate :: region:: options:: RegionOptions ;
@@ -264,8 +261,6 @@ pub struct MergeOutput {
264261 pub compaction_time_window : Option < i64 > ,
265262 #[ serde( skip) ]
266263 pub sst_infos : Vec < SstInfo > ,
267- #[ serde( skip) ]
268- pub primary_keys : Vec < Vec < u8 > > ,
269264}
270265
271266impl MergeOutput {
@@ -311,7 +306,7 @@ pub trait SstMerger: Send + Sync + 'static {
311306 compaction_region : CompactionRegion ,
312307 output : CompactionOutput ,
313308 write_opts : WriteOptions ,
314- ) -> Result < ( Vec < FileMeta > , Vec < SstInfo > , Vec < Vec < u8 > > ) > ;
309+ ) -> Result < ( Vec < FileMeta > , Vec < SstInfo > ) > ;
315310}
316311
317312/// The production [`SstMerger`] that reads, merges, and writes SST files.
@@ -325,7 +320,7 @@ impl SstMerger for DefaultSstMerger {
325320 compaction_region : CompactionRegion ,
326321 output : CompactionOutput ,
327322 write_opts : WriteOptions ,
328- ) -> Result < ( Vec < FileMeta > , Vec < SstInfo > , Vec < Vec < u8 > > ) > {
323+ ) -> Result < ( Vec < FileMeta > , Vec < SstInfo > ) > {
329324 let region_id = compaction_region. region_id ;
330325 let storage = compaction_region. region_options . storage . clone ( ) ;
331326 let index_options = compaction_region
@@ -371,19 +366,6 @@ impl SstMerger for DefaultSstMerger {
371366 } ;
372367 let source = builder. build_flat_sst_reader ( ) . await ?;
373368
374- let hook: Option < FlushHookRef > = compaction_region. plugins . get ( ) ;
375- let pk_collector: Option < SharedPrimaryKeys > = hook
376- . as_ref ( )
377- . map ( |_| Arc :: new ( std:: sync:: Mutex :: new ( HashSet :: new ( ) ) ) ) ;
378- let source = if let Some ( collector) = & pk_collector {
379- crate :: read:: FlatSource :: new_iter (
380- source. schema ( ) . clone ( ) ,
381- wrap_with_pk_collector ( source. take_iter ( ) , & Some ( collector. clone ( ) ) ) ,
382- )
383- } else {
384- source
385- } ;
386-
387369 let mut metrics = Metrics :: new ( WriteType :: Compaction ) ;
388370 let region_metadata = compaction_region. region_metadata . clone ( ) ;
389371 let sst_infos = compaction_region
@@ -463,10 +445,7 @@ impl SstMerger for DefaultSstMerger {
463445 region_id, input_file_names, output_file_names, flat_format, metrics
464446 ) ;
465447 metrics. observe ( ) ;
466- let primary_keys: Vec < Vec < u8 > > = pk_collector
467- . map ( |c| c. lock ( ) . unwrap ( ) . drain ( ) . collect ( ) )
468- . unwrap_or_default ( ) ;
469- Ok ( ( output_files, sst_infos. into_iter ( ) . collect ( ) , primary_keys) )
448+ Ok ( ( output_files, sst_infos. into_iter ( ) . collect ( ) ) )
470449 }
471450}
472451
@@ -536,7 +515,6 @@ where
536515
537516 let mut output_files = Vec :: with_capacity ( tasks. len ( ) ) ;
538517 let mut all_sst_infos: Vec < SstInfo > = Vec :: new ( ) ;
539- let mut all_primary_keys: HashSet < Vec < u8 > > = HashSet :: new ( ) ;
540518 let mut compacted_inputs = Vec :: with_capacity (
541519 tasks. iter ( ) . map ( |( inputs, _) | inputs. len ( ) ) . sum :: < usize > ( )
542520 + picker_output. expired_ssts . len ( ) ,
@@ -560,10 +538,9 @@ where
560538 while let Some ( ( inputs, handle) ) = spawned. pop ( ) {
561539 let abort_handle = handle. abort_handle ( ) ;
562540 match CancellableFuture :: new ( handle, self . cancel_handle . clone ( ) ) . await {
563- Ok ( Ok ( Ok ( ( files, infos, pks ) ) ) ) => {
541+ Ok ( Ok ( Ok ( ( files, infos) ) ) ) => {
564542 output_files. extend ( files) ;
565543 all_sst_infos. extend ( infos) ;
566- all_primary_keys. extend ( pks) ;
567544 compacted_inputs. extend ( inputs) ;
568545 }
569546 Ok ( Ok ( Err ( e) ) ) => {
@@ -624,7 +601,6 @@ where
624601 files_to_remove : compacted_inputs,
625602 compaction_time_window : Some ( compaction_time_window) ,
626603 sst_infos : all_sst_infos,
627- primary_keys : all_primary_keys. into_iter ( ) . collect ( ) ,
628604 } )
629605 }
630606
@@ -742,10 +718,10 @@ mod tests {
742718 _compaction_region : CompactionRegion ,
743719 _output : CompactionOutput ,
744720 _write_opts : WriteOptions ,
745- ) -> Result < ( Vec < FileMeta > , Vec < SstInfo > , Vec < Vec < u8 > > ) > {
721+ ) -> Result < ( Vec < FileMeta > , Vec < SstInfo > ) > {
746722 let idx = self . call_idx . fetch_add ( 1 , Ordering :: SeqCst ) ;
747723 match self . results . lock ( ) . unwrap ( ) . get ( idx) {
748- Some ( Ok ( files) ) => Ok ( ( files. clone ( ) , Vec :: new ( ) , Vec :: new ( ) ) ) ,
724+ Some ( Ok ( files) ) => Ok ( ( files. clone ( ) , Vec :: new ( ) ) ) ,
749725 Some ( Err ( _) ) => error:: InvalidMetaSnafu {
750726 reason : format ! ( "simulated failure at index {idx}" ) ,
751727 }
@@ -914,7 +890,7 @@ mod tests {
914890 _compaction_region : CompactionRegion ,
915891 _output : CompactionOutput ,
916892 _write_opts : WriteOptions ,
917- ) -> Result < ( Vec < FileMeta > , Vec < SstInfo > , Vec < Vec < u8 > > ) > {
893+ ) -> Result < ( Vec < FileMeta > , Vec < SstInfo > ) > {
918894 self . call_idx . fetch_add ( 1 , Ordering :: SeqCst ) ;
919895 std:: future:: pending ( ) . await
920896 }
0 commit comments