@@ -14,7 +14,6 @@ import (
1414 "github.com/cockroachdb/cockroach/pkg/sql/vecindex/cspann/testutils"
1515 "github.com/cockroachdb/cockroach/pkg/sql/vecindex/cspann/workspace"
1616 "github.com/cockroachdb/cockroach/pkg/util/num32"
17- "github.com/cockroachdb/cockroach/pkg/util/timeutil"
1817 "github.com/cockroachdb/cockroach/pkg/util/vector"
1918 "github.com/cockroachdb/errors"
2019 "github.com/stretchr/testify/suite"
@@ -229,7 +228,10 @@ func (suite *StoreTestSuite) TestNonRootPartition() {
229228 childKeys := []cspann.ChildKey {partitionKey1 , partitionKey2 }
230229 valueBytes := []cspann.ValueBytes {valueBytes1 , valueBytes2 }
231230 metadata := cspann.PartitionMetadata {
232- Level : cspann .SecondLevel , Centroid : quantizedSet .GetCentroid ()}
231+ Level : cspann .SecondLevel ,
232+ Centroid : quantizedSet .GetCentroid (),
233+ StateDetails : cspann .MakeReadyDetails (),
234+ }
233235 partition := cspann .NewPartition (
234236 metadata , suite .quantizer , quantizedSet , childKeys , valueBytes )
235237
@@ -400,18 +402,12 @@ func (suite *StoreTestSuite) TestTryCreateEmptyPartition() {
400402 treeKey := store .MakeTreeKey (suite .T (), treeID )
401403 partitionKey := cspann .PartitionKey (10 )
402404 centroid := vector.T {4 , 3 }
403- timestamp := timeutil .Now ()
404405
405406 // Create empty partition.
406407 metadata := cspann.PartitionMetadata {
407- Level : cspann .SecondLevel ,
408- Centroid : centroid ,
409- StateDetails : cspann.PartitionStateDetails {
410- State : cspann .SplittingState ,
411- Target1 : 20 ,
412- Target2 : 30 ,
413- Timestamp : timestamp ,
414- },
408+ Level : cspann .SecondLevel ,
409+ Centroid : centroid ,
410+ StateDetails : cspann .MakeSplittingDetails (20 , 30 ),
415411 }
416412 suite .NoError (store .TryCreateEmptyPartition (suite .ctx , treeKey , partitionKey , metadata ))
417413
@@ -500,21 +496,16 @@ func (suite *StoreTestSuite) TestTryGetPartition() {
500496 treeKey := store .MakeTreeKey (suite .T (), treeID )
501497 partitionKey := cspann .PartitionKey (10 )
502498 centroid := vector.T {4 , 3 }
503- timestamp := timeutil .Now ()
504499
505500 // Partition does not yet exist.
506501 _ , err := store .TryGetPartition (suite .ctx , treeKey , partitionKey )
507502 suite .ErrorIs (err , cspann .ErrPartitionNotFound )
508503
509504 // Create partition with some vectors in it.
510505 metadata := cspann.PartitionMetadata {
511- Level : cspann .LeafLevel ,
512- Centroid : centroid ,
513- StateDetails : cspann.PartitionStateDetails {
514- State : cspann .UpdatingState ,
515- Source : 20 ,
516- Timestamp : timestamp ,
517- },
506+ Level : cspann .LeafLevel ,
507+ Centroid : centroid ,
508+ StateDetails : cspann .MakeUpdatingDetails (20 ),
518509 }
519510 suite .NoError (store .TryCreateEmptyPartition (suite .ctx , treeKey , partitionKey , metadata ))
520511 vectors := vector .MakeSet (2 )
@@ -576,11 +567,7 @@ func (suite *StoreTestSuite) TestTryGetPartitionMetadata() {
576567 // Update the metadata and verify we get the updated values.
577568 expected := * partition .Metadata ()
578569 metadata := expected
579- metadata .StateDetails = cspann.PartitionStateDetails {
580- State : cspann .UpdatingState ,
581- Source : 30 ,
582- Timestamp : timeutil .Now (),
583- }
570+ metadata .StateDetails = cspann .MakeUpdatingDetails (30 )
584571 suite .NoError (store .TryUpdatePartitionMetadata (
585572 suite .ctx , treeKey , partitionKey , metadata , expected ))
586573
@@ -661,17 +648,12 @@ func (suite *StoreTestSuite) TestTryAddToPartition() {
661648 treeKey := store .MakeTreeKey (suite .T (), treeID )
662649 partitionKey := cspann .PartitionKey (10 )
663650 centroid := vector.T {4 , 3 }
664- timestamp := timeutil .Now ()
665651
666652 // Partition does not yet exist.
667653 metadata := cspann.PartitionMetadata {
668- Level : cspann .LeafLevel ,
669- Centroid : centroid ,
670- StateDetails : cspann.PartitionStateDetails {
671- State : cspann .UpdatingState ,
672- Source : 20 ,
673- Timestamp : timestamp ,
674- },
654+ Level : cspann .LeafLevel ,
655+ Centroid : centroid ,
656+ StateDetails : cspann .MakeUpdatingDetails (20 ),
675657 }
676658 addVectors := vector .MakeSet (2 )
677659 addVectors .Add (vec1 )
@@ -854,12 +836,9 @@ func (suite *StoreTestSuite) createTestPartition(
854836) (cspann.PartitionKey , * cspann.Partition ) {
855837 partitionKey := cspann .PartitionKey (10 )
856838 metadata := cspann.PartitionMetadata {
857- Level : cspann .SecondLevel ,
858- Centroid : vector.T {4 , 3 },
859- StateDetails : cspann.PartitionStateDetails {
860- State : cspann .ReadyState ,
861- Timestamp : timeutil .Now (),
862- },
839+ Level : cspann .SecondLevel ,
840+ Centroid : vector.T {4 , 3 },
841+ StateDetails : cspann .MakeReadyDetails (),
863842 }
864843 suite .NoError (store .TryCreateEmptyPartition (suite .ctx , treeKey , partitionKey , metadata ))
865844 vectors := vector .MakeSet (2 )
@@ -973,7 +952,10 @@ func (suite *StoreTestSuite) insertLeafPartition(store TestStore, treeID int) cs
973952 childKeys := []cspann.ChildKey {primaryKey1 , primaryKey2 , primaryKey3 }
974953 valueBytes := []cspann.ValueBytes {valueBytes1 , valueBytes2 , valueBytes3 }
975954 metadata := cspann.PartitionMetadata {
976- Level : cspann .LeafLevel , Centroid : quantizedSet .GetCentroid ()}
955+ Level : cspann .LeafLevel ,
956+ Centroid : quantizedSet .GetCentroid (),
957+ StateDetails : cspann .MakeReadyDetails (),
958+ }
977959 partition := cspann .NewPartition (
978960 metadata , suite .quantizer , quantizedSet , childKeys , valueBytes )
979961
@@ -1117,7 +1099,10 @@ func (suite *StoreTestSuite) setRootPartition(store TestStore, treeID int) {
11171099 childKeys := []cspann.ChildKey {partitionKey1 , partitionKey2 }
11181100 valueBytes := []cspann.ValueBytes {valueBytes1 , valueBytes2 }
11191101 metadata := cspann.PartitionMetadata {
1120- Level : cspann .SecondLevel , Centroid : quantizedSet .GetCentroid ()}
1102+ Level : cspann .SecondLevel ,
1103+ Centroid : quantizedSet .GetCentroid (),
1104+ StateDetails : cspann .MakeReadyDetails (),
1105+ }
11211106 newRoot := cspann .NewPartition (
11221107 metadata , suite .rootQuantizer , quantizedSet , childKeys , valueBytes )
11231108
0 commit comments