@@ -660,26 +660,41 @@ 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 }
684699 println ! (
685700 "{} Splits were unable to be removed." ,
@@ -690,7 +705,7 @@ pub async fn garbage_collect_index_cli(args: GarbageCollectIndexArgs) -> anyhow:
690705 let deleted_bytes: u64 = removal_info
691706 . removed_split_entries
692707 . iter ( )
693- . map ( |split_info| split_info . file_size_bytes . as_u64 ( ) )
708+ . map ( |s| s . file_size_bytes . as_u64 ( ) )
694709 . sum ( ) ;
695710 println ! (
696711 "{}MB of storage garbage collected." ,
@@ -702,9 +717,59 @@ pub async fn garbage_collect_index_cli(args: GarbageCollectIndexArgs) -> anyhow:
702717 "{} Index successfully garbage collected." ,
703718 "✔" . color( GREEN_COLOR )
704719 ) ;
705- } else if removal_info. removed_split_entries . is_empty ( )
706- && !removal_info. failed_splits . is_empty ( )
720+ } else if removal_info. removed_split_entries . is_empty ( ) {
721+ println ! ( "{} Failed to garbage collect index." , "✘" . color( RED_COLOR ) ) ;
722+ } else {
723+ println ! (
724+ "{} Index partially garbage collected." ,
725+ "✘" . color( RED_COLOR )
726+ ) ;
727+ }
728+
729+ Ok ( ( ) )
730+ }
731+
732+ fn print_parquet_gc_result (
733+ dry_run : bool ,
734+ removal_info : quickwit_index_management:: ParquetSplitRemovalInfo ,
735+ ) -> anyhow:: Result < ( ) > {
736+ if removal_info. removed_parquet_splits_entries . is_empty ( )
737+ && removal_info. failed_parquet_splits . is_empty ( )
707738 {
739+ println ! ( "No dangling files to garbage collect." ) ;
740+ return Ok ( ( ) ) ;
741+ }
742+
743+ if dry_run {
744+ println ! ( "The following files will be garbage collected." ) ;
745+ for entry in & removal_info. removed_parquet_splits_entries {
746+ println ! ( " - {}.parquet" , entry. split_id) ;
747+ }
748+ return Ok ( ( ) ) ;
749+ }
750+
751+ if !removal_info. failed_parquet_splits . is_empty ( ) {
752+ println ! ( "The following splits were attempted to be removed, but failed." ) ;
753+ for split in & removal_info. failed_parquet_splits {
754+ println ! ( " - {}" , split. split_id) ;
755+ }
756+ println ! (
757+ "{} Splits were unable to be removed." ,
758+ removal_info. failed_parquet_splits. len( )
759+ ) ;
760+ }
761+
762+ println ! (
763+ "{}MB of storage garbage collected." ,
764+ removal_info. removed_bytes( ) / 1_000_000
765+ ) ;
766+
767+ if removal_info. failed_parquet_splits . is_empty ( ) {
768+ println ! (
769+ "{} Index successfully garbage collected." ,
770+ "✔" . color( GREEN_COLOR )
771+ ) ;
772+ } else if removal_info. removed_parquet_splits_entries . is_empty ( ) {
708773 println ! ( "{} Failed to garbage collect index." , "✘" . color( RED_COLOR ) ) ;
709774 } else {
710775 println ! (
0 commit comments