@@ -700,16 +700,13 @@ func (tc *Catalog) getLineageFile(ctx context.Context, collection *model.Collect
700
700
}
701
701
702
702
func (tc * Catalog ) ForkCollection (ctx context.Context , forkCollection * model.ForkCollection ) (* model.Collection , []* model.Segment , error ) {
703
- log .Info ("Forking collection" , zap .String ("sourceCollectionId" , forkCollection .SourceCollectionID .String ()), zap .String ("targetCollectionName" , * forkCollection .TargetCollectionName ))
704
-
705
- var newCollectionID types.UniqueID
703
+ log .Info ("Forking collection" , zap .String ("sourceCollectionId" , forkCollection .SourceCollectionID .String ()), zap .String ("targetCollectionId" , forkCollection .TargetCollectionID .String ()), zap .String ("targetCollectionName" , forkCollection .TargetCollectionName ))
706
704
707
705
err := tc .txImpl .Transaction (ctx , func (txCtx context.Context ) error {
708
706
var err error
709
707
var rootCollection * model.Collection
710
708
var sourceCollection * model.Collection
711
709
var sourceSegments []* model.Segment
712
- var newCollection * model.Collection
713
710
var newLineageFileFullName string
714
711
715
712
sourceCollectionIDStr := forkCollection .SourceCollectionID .String ()
@@ -732,8 +729,8 @@ func (tc *Catalog) ForkCollection(ctx context.Context, forkCollection *model.For
732
729
ts := time .Now ().UTC ()
733
730
734
731
createCollection := & model.CreateCollection {
735
- ID : types . NewUniqueID () ,
736
- Name : * forkCollection .TargetCollectionName ,
732
+ ID : forkCollection . TargetCollectionID ,
733
+ Name : forkCollection .TargetCollectionName ,
737
734
ConfigurationJsonStr : sourceCollection .ConfigurationJsonStr ,
738
735
Dimension : sourceCollection .Dimension ,
739
736
Metadata : sourceCollection .Metadata ,
@@ -749,18 +746,17 @@ func (tc *Catalog) ForkCollection(ctx context.Context, forkCollection *model.For
749
746
ID : types .NewUniqueID (),
750
747
Type : segment .Type ,
751
748
Scope : segment .Scope ,
752
- CollectionID : createCollection . ID ,
749
+ CollectionID : forkCollection . TargetCollectionID ,
753
750
Metadata : segment .Metadata ,
754
751
Ts : ts .Unix (),
755
752
}
756
753
createSegments = append (createSegments , createSegment )
757
754
}
758
755
759
- newCollection , _ , err = tc .CreateCollectionAndSegments (ctx , createCollection , createSegments , ts .Unix ())
756
+ _ , _ , err = tc .CreateCollectionAndSegments (ctx , createCollection , createSegments , ts .Unix ())
760
757
if err != nil {
761
758
return err
762
759
}
763
- newCollectionID = newCollection .ID
764
760
765
761
if rootCollectionID == nil {
766
762
rootCollection = sourceCollection
@@ -774,10 +770,10 @@ func (tc *Catalog) ForkCollection(ctx context.Context, forkCollection *model.For
774
770
lineageFile .Dependencies = append (lineageFile .Dependencies , & coordinatorpb.CollectionVersionDependency {
775
771
SourceCollectionId : sourceCollectionIDStr ,
776
772
SourceCollectionVersion : uint64 (sourceCollection .Version ),
777
- TargetCollectionId : newCollection . ID .String (),
773
+ TargetCollectionId : forkCollection . TargetCollectionID .String (),
778
774
})
779
775
780
- newLineageFileBaseName := fmt .Sprintf ("%d/%d/%d/%d-%d-%d-%s-%d-%s.binpb" , ts .Year (), ts .Month (), ts .Day (), ts .Hour (), ts .Minute (), ts .Second (), sourceCollectionIDStr , sourceCollection .Version , newCollectionID .String ())
776
+ newLineageFileBaseName := fmt .Sprintf ("%d/%d/%d/%d-%d-%d-%s-%d-%s.binpb" , ts .Year (), ts .Month (), ts .Day (), ts .Hour (), ts .Minute (), ts .Second (), sourceCollectionIDStr , sourceCollection .Version , forkCollection . TargetCollectionID .String ())
781
777
newLineageFileFullName , err = tc .s3Store .PutLineageFile (rootCollection .TenantID , rootCollection .DatabaseName , rootCollectionIDStr , newLineageFileBaseName , lineageFile )
782
778
if err != nil {
783
779
return err
@@ -789,7 +785,7 @@ func (tc *Catalog) ForkCollection(ctx context.Context, forkCollection *model.For
789
785
return nil , nil , err
790
786
}
791
787
792
- return tc .GetCollectionWithSegments (ctx , newCollectionID )
788
+ return tc .GetCollectionWithSegments (ctx , forkCollection . TargetCollectionID )
793
789
}
794
790
795
791
func (tc * Catalog ) CreateSegment (ctx context.Context , createSegment * model.CreateSegment , ts types.Timestamp ) (* model.Segment , error ) {
0 commit comments