@@ -456,10 +456,38 @@ func (tc *Catalog) ListCollectionsToGc(ctx context.Context, cutoffTimeSecs *uint
456
456
if err != nil {
457
457
return nil , err
458
458
}
459
- collections := convertCollectionToGcToModel (collectionsToGc )
459
+
460
+ if collectionsToGc == nil {
461
+ return nil , nil
462
+ }
463
+
464
+ collections := make ([]* model.CollectionToGc , 0 , len (collectionsToGc ))
465
+ for _ , collectionInfo := range collectionsToGc {
466
+ collection := convertCollectionToGcToModel (* collectionInfo )
467
+ collections = append (collections , & collection )
468
+ }
469
+
460
470
return collections , nil
461
471
}
462
472
473
+ func (tc * Catalog ) GetCollectionToGcInfo (ctx context.Context , collectionID types.UniqueID , tenantID string ) (* model.CollectionToGc , error ) {
474
+ tracer := otel .Tracer
475
+ if tracer != nil {
476
+ _ , span := tracer .Start (ctx , "Catalog.GetCollectionToGcInfo" )
477
+ defer span .End ()
478
+ }
479
+
480
+ collectionToGc , err := tc .metaDomain .CollectionDb (ctx ).GetCollectionToGcInfo (collectionID .String (), tenantID )
481
+ if err != nil {
482
+ return nil , err
483
+ }
484
+ if collectionToGc == nil {
485
+ return nil , common .ErrCollectionNotFound
486
+ }
487
+ result := convertCollectionToGcToModel (* collectionToGc )
488
+ return & result , nil
489
+ }
490
+
463
491
func (tc * Catalog ) GetCollectionWithSegments (ctx context.Context , collectionID types.UniqueID ) (* model.Collection , []* model.Segment , error ) {
464
492
tracer := otel .Tracer
465
493
if tracer != nil {
@@ -952,7 +980,7 @@ func (tc *Catalog) ForkCollection(ctx context.Context, forkCollection *model.For
952
980
flushFilePaths = append (flushFilePaths , flushFilePath )
953
981
}
954
982
955
- _ , _ , err = tc .CreateCollectionAndSegments (txCtx , createCollection , createSegments , ts .Unix ())
983
+ _ , _ , err = tc .CreateCollectionAndSegments (txCtx , createCollection , createSegments , flushFilePaths , ts .Unix ())
956
984
if err != nil {
957
985
return err
958
986
}
@@ -1090,7 +1118,22 @@ func (tc *Catalog) createSegmentImpl(txCtx context.Context, createSegment *model
1090
1118
return result , nil
1091
1119
}
1092
1120
1093
- func (tc * Catalog ) createFirstVersionFile (ctx context.Context , databaseID string , createCollection * model.CreateCollection , createSegments []* model.CreateSegment , ts types.Timestamp ) (string , error ) {
1121
+ func (tc * Catalog ) createFirstVersionFile (ctx context.Context , databaseID string , createCollection * model.CreateCollection , createSegments []* model.CreateSegment , initialFilePaths []* model.FlushSegmentCompaction , ts types.Timestamp ) (string , error ) {
1122
+ segmentCompactionInfos := make ([]* coordinatorpb.FlushSegmentCompactionInfo , 0 , len (createSegments ))
1123
+ for _ , compaction := range initialFilePaths {
1124
+ // Convert map[string][]string to map[string]*coordinatorpb.FilePaths
1125
+ convertedPaths := make (map [string ]* coordinatorpb.FilePaths )
1126
+ for k , v := range compaction .FilePaths {
1127
+ convertedPaths [k ] = & coordinatorpb.FilePaths {Paths : v }
1128
+ }
1129
+
1130
+ info := & coordinatorpb.FlushSegmentCompactionInfo {
1131
+ SegmentId : compaction .ID .String (),
1132
+ FilePaths : convertedPaths ,
1133
+ }
1134
+ segmentCompactionInfos = append (segmentCompactionInfos , info )
1135
+ }
1136
+
1094
1137
collectionVersionFilePb := & coordinatorpb.CollectionVersionFile {
1095
1138
CollectionInfoImmutable : & coordinatorpb.CollectionInfoImmutable {
1096
1139
TenantId : createCollection .TenantID ,
@@ -1104,6 +1147,9 @@ func (tc *Catalog) createFirstVersionFile(ctx context.Context, databaseID string
1104
1147
{
1105
1148
Version : 0 ,
1106
1149
CreatedAtSecs : int64 (ts ),
1150
+ SegmentInfo : & coordinatorpb.CollectionSegmentInfo {
1151
+ SegmentCompactionInfo : segmentCompactionInfos ,
1152
+ },
1107
1153
},
1108
1154
},
1109
1155
},
@@ -1117,7 +1163,7 @@ func (tc *Catalog) createFirstVersionFile(ctx context.Context, databaseID string
1117
1163
return fullFilePath , nil
1118
1164
}
1119
1165
1120
- func (tc * Catalog ) CreateCollectionAndSegments (ctx context.Context , createCollection * model.CreateCollection , createSegments []* model.CreateSegment , ts types.Timestamp ) (* model.Collection , bool , error ) {
1166
+ func (tc * Catalog ) CreateCollectionAndSegments (ctx context.Context , createCollection * model.CreateCollection , createSegments []* model.CreateSegment , initialFilePaths [] * model. FlushSegmentCompaction , ts types.Timestamp ) (* model.Collection , bool , error ) {
1121
1167
var resultCollection * model.Collection
1122
1168
created := false
1123
1169
@@ -1139,7 +1185,7 @@ func (tc *Catalog) CreateCollectionAndSegments(ctx context.Context, createCollec
1139
1185
return nil , false , common .ErrDatabaseNotFound
1140
1186
}
1141
1187
1142
- versionFileName , err = tc .createFirstVersionFile (ctx , databases [0 ].ID , createCollection , createSegments , ts )
1188
+ versionFileName , err = tc .createFirstVersionFile (ctx , databases [0 ].ID , createCollection , createSegments , initialFilePaths , ts )
1143
1189
if err != nil {
1144
1190
return nil , false , err
1145
1191
}
0 commit comments