@@ -660,51 +660,101 @@ pub async fn garbage_collect_index_cli(args: GarbageCollectIndexArgs) -> anyhow:
660660 get_resolvers ( & config. storage_configs , & config. metastore_configs ) ;
661661 let metastore = metastore_resolver. resolve ( & config. metastore_uri ) . await ?;
662662 let mut index_service = IndexService :: new ( metastore, storage_resolver) ;
663+
664+ if quickwit_common:: is_metrics_index ( & args. index_id ) {
665+ let removal_info = index_service
666+ . garbage_collect_parquet_index ( & args. index_id , args. grace_period , args. dry_run )
667+ . await ?;
668+ return print_parquet_gc_result ( args. dry_run , removal_info) ;
669+ }
670+
663671 let removal_info = index_service
664672 . garbage_collect_index ( & args. index_id , args. grace_period , args. dry_run )
665673 . await ?;
674+ print_tantivy_gc_result ( args. dry_run , removal_info)
675+ }
676+
677+ fn print_tantivy_gc_result (
678+ dry_run : bool ,
679+ removal_info : quickwit_index_management:: SplitRemovalInfo ,
680+ ) -> anyhow:: Result < ( ) > {
666681 if removal_info. removed_split_entries . is_empty ( ) && removal_info. failed_splits . is_empty ( ) {
667682 println ! ( "No dangling files to garbage collect." ) ;
668683 return Ok ( ( ) ) ;
669684 }
670685
671- if args . dry_run {
686+ if dry_run {
672687 println ! ( "The following files will be garbage collected." ) ;
673- for split_info in removal_info. removed_split_entries {
674- println ! ( " - {}" , split_info . file_name. display( ) ) ;
688+ for entry in & removal_info. removed_split_entries {
689+ println ! ( " - {}" , entry . file_name. display( ) ) ;
675690 }
676691 return Ok ( ( ) ) ;
677692 }
678693
679694 if !removal_info. failed_splits . is_empty ( ) {
680695 println ! ( "The following splits were attempted to be removed, but failed." ) ;
681- for split_info in & removal_info. failed_splits {
682- println ! ( " - {}" , split_info . split_id) ;
696+ for split in & removal_info. failed_splits {
697+ println ! ( " - {}" , split . split_id) ;
683698 }
684- println ! (
685- "{} Splits were unable to be removed." ,
686- removal_info. failed_splits. len( )
687- ) ;
699+ println ! ( "{} Splits were unable to be removed." , removal_info. failed_splits. len( ) ) ;
688700 }
689701
690702 let deleted_bytes: u64 = removal_info
691703 . removed_split_entries
692704 . iter ( )
693- . map ( |split_info| split_info . file_size_bytes . as_u64 ( ) )
705+ . map ( |s| s . file_size_bytes . as_u64 ( ) )
694706 . sum ( ) ;
695- println ! (
696- "{}MB of storage garbage collected." ,
697- deleted_bytes / 1_000_000
698- ) ;
707+ println ! ( "{}MB of storage garbage collected." , deleted_bytes / 1_000_000 ) ;
699708
700709 if removal_info. failed_splits . is_empty ( ) {
710+ println ! ( "{} Index successfully garbage collected." , "✔" . color( GREEN_COLOR ) ) ;
711+ } else if removal_info. removed_split_entries . is_empty ( ) {
712+ println ! ( "{} Failed to garbage collect index." , "✘" . color( RED_COLOR ) ) ;
713+ } else {
701714 println ! (
702- "{} Index successfully garbage collected." ,
703- "✔ " . color( GREEN_COLOR )
715+ "{} Index partially garbage collected." ,
716+ "✘ " . color( RED_COLOR )
704717 ) ;
705- } else if removal_info. removed_split_entries . is_empty ( )
706- && !removal_info. failed_splits . is_empty ( )
718+ }
719+
720+ Ok ( ( ) )
721+ }
722+
723+ fn print_parquet_gc_result (
724+ dry_run : bool ,
725+ removal_info : quickwit_index_management:: ParquetSplitRemovalInfo ,
726+ ) -> anyhow:: Result < ( ) > {
727+ if removal_info. removed_parquet_splits_entries . is_empty ( )
728+ && removal_info. failed_parquet_splits . is_empty ( )
707729 {
730+ println ! ( "No dangling files to garbage collect." ) ;
731+ return Ok ( ( ) ) ;
732+ }
733+
734+ if dry_run {
735+ println ! ( "The following files will be garbage collected." ) ;
736+ for entry in & removal_info. removed_parquet_splits_entries {
737+ println ! ( " - {}.parquet" , entry. split_id) ;
738+ }
739+ return Ok ( ( ) ) ;
740+ }
741+
742+ if !removal_info. failed_parquet_splits . is_empty ( ) {
743+ println ! ( "The following splits were attempted to be removed, but failed." ) ;
744+ for split in & removal_info. failed_parquet_splits {
745+ println ! ( " - {}" , split. split_id) ;
746+ }
747+ println ! (
748+ "{} Splits were unable to be removed." ,
749+ removal_info. failed_parquet_splits. len( )
750+ ) ;
751+ }
752+
753+ println ! ( "{}MB of storage garbage collected." , removal_info. removed_bytes( ) / 1_000_000 ) ;
754+
755+ if removal_info. failed_parquet_splits . is_empty ( ) {
756+ println ! ( "{} Index successfully garbage collected." , "✔" . color( GREEN_COLOR ) ) ;
757+ } else if removal_info. removed_parquet_splits_entries . is_empty ( ) {
708758 println ! ( "{} Failed to garbage collect index." , "✘" . color( RED_COLOR ) ) ;
709759 } else {
710760 println ! (
0 commit comments