@@ -9,16 +9,16 @@ use chroma_types::chroma_proto::sys_db_client::SysDbClient;
99use chroma_types:: chroma_proto:: VersionListForCollection ;
1010use chroma_types:: {
1111 chroma_proto, chroma_proto:: CollectionVersionInfo , CollectionAndSegments , CollectionFlushInfo ,
12- CollectionMetadataUpdate , CountCollectionsError , CreateCollectionError , CreateDatabaseError ,
13- CreateDatabaseResponse , CreateTenantError , CreateTenantResponse , Database ,
14- DeleteCollectionError , DeleteDatabaseError , DeleteDatabaseResponse , GetCollectionByCrnError ,
15- GetCollectionSizeError , GetCollectionWithSegmentsError , GetCollectionsError , GetDatabaseError ,
16- GetDatabaseResponse , GetSegmentsError , GetTenantError , GetTenantResponse ,
17- InternalCollectionConfiguration , InternalUpdateCollectionConfiguration ,
18- ListAttachedFunctionsError , ListCollectionVersionsError , ListDatabasesError ,
19- ListDatabasesResponse , Metadata , ResetError , ResetResponse , SegmentFlushInfo ,
20- SegmentFlushInfoConversionError , SegmentUuid , UpdateCollectionError , UpdateTenantError ,
21- UpdateTenantResponse ,
12+ CollectionFlushInfoConversionError , CollectionMetadataUpdate , CountCollectionsError ,
13+ CreateCollectionError , CreateDatabaseError , CreateDatabaseResponse , CreateTenantError ,
14+ CreateTenantResponse , Database , DeleteCollectionError , DeleteDatabaseError ,
15+ DeleteDatabaseResponse , GetCollectionByCrnError , GetCollectionSizeError ,
16+ GetCollectionWithSegmentsError , GetCollectionsError , GetDatabaseError , GetDatabaseResponse ,
17+ GetSegmentsError , GetTenantError , GetTenantResponse , InternalCollectionConfiguration ,
18+ InternalUpdateCollectionConfiguration , ListAttachedFunctionsError , ListCollectionVersionsError ,
19+ ListDatabasesError , ListDatabasesResponse , Metadata , ResetError , ResetResponse ,
20+ SegmentFlushInfo , SegmentFlushInfoConversionError , SegmentUuid , UpdateCollectionError ,
21+ UpdateTenantError , UpdateTenantResponse ,
2222} ;
2323use chroma_types:: {
2424 AttachedFunctionUpdateInfo , AttachedFunctionUuid , BatchGetCollectionSoftDeleteStatusError ,
@@ -1657,38 +1657,10 @@ impl GrpcSysDb {
16571657 attached_function_update : AttachedFunctionUpdateInfo ,
16581658 ) -> Result < FlushCompactionAndAttachedFunctionResponse , FlushCompactionError > {
16591659 // Process all collections into flush compaction requests
1660- let mut flush_compactions = Vec :: with_capacity ( collections. len ( ) ) ;
1661-
1662- for collection in collections {
1663- let segment_compaction_info = collection
1664- . segment_flush_info
1665- . iter ( )
1666- . map ( |segment_flush_info| segment_flush_info. try_into ( ) )
1667- . collect :: < Result <
1668- Vec < chroma_proto:: FlushSegmentCompactionInfo > ,
1669- SegmentFlushInfoConversionError ,
1670- > > ( ) ?;
1671-
1672- let schema_str = collection. schema . and_then ( |s| {
1673- serde_json:: to_string ( & s) . ok ( ) . or_else ( || {
1674- tracing:: error!(
1675- "Failed to serialize schema for flush_compaction_and_attached_function"
1676- ) ;
1677- None
1678- } )
1679- } ) ;
1680-
1681- flush_compactions. push ( chroma_proto:: FlushCollectionCompactionRequest {
1682- tenant_id : collection. tenant_id ,
1683- collection_id : collection. collection_id . 0 . to_string ( ) ,
1684- log_position : collection. log_position ,
1685- collection_version : collection. collection_version ,
1686- segment_compaction_info,
1687- total_records_post_compaction : collection. total_records_post_compaction ,
1688- size_bytes_post_compaction : collection. size_bytes_post_compaction ,
1689- schema_str,
1690- } ) ;
1691- }
1660+ let flush_compactions = collections
1661+ . into_iter ( )
1662+ . map ( |collection| collection. try_into ( ) )
1663+ . collect :: < Result < Vec < _ > , _ > > ( ) ?;
16921664
16931665 let attached_function_update_proto = Some ( chroma_proto:: AttachedFunctionUpdateInfo {
16941666 id : attached_function_update. attached_function_id . 0 . to_string ( ) ,
@@ -2137,6 +2109,8 @@ pub enum FlushCompactionError {
21372109 FailedToFlushCompaction ( #[ from] tonic:: Status ) ,
21382110 #[ error( "Failed to convert segment flush info" ) ]
21392111 SegmentFlushInfoConversionError ( #[ from] SegmentFlushInfoConversionError ) ,
2112+ #[ error( "Failed to convert collection flush info" ) ]
2113+ CollectionFlushInfoConversionError ( #[ from] CollectionFlushInfoConversionError ) ,
21402114 #[ error( "Failed to convert flush compaction response" ) ]
21412115 FlushCompactionResponseConversionError ( #[ from] FlushCompactionResponseConversionError ) ,
21422116 #[ error( "Collection not found in sysdb" ) ]
@@ -2158,6 +2132,7 @@ impl ChromaError for FlushCompactionError {
21582132 }
21592133 }
21602134 FlushCompactionError :: SegmentFlushInfoConversionError ( _) => ErrorCodes :: Internal ,
2135+ FlushCompactionError :: CollectionFlushInfoConversionError ( _) => ErrorCodes :: Internal ,
21612136 FlushCompactionError :: FlushCompactionResponseConversionError ( _) => ErrorCodes :: Internal ,
21622137 FlushCompactionError :: CollectionNotFound => ErrorCodes :: Internal ,
21632138 FlushCompactionError :: SegmentNotFound => ErrorCodes :: Internal ,
0 commit comments