@@ -12,7 +12,7 @@ import (
12
12
"github.com/cockroachdb/cockroach/pkg/sql/vecindex/cspann"
13
13
"github.com/cockroachdb/cockroach/pkg/sql/vecindex/cspann/quantize"
14
14
"github.com/cockroachdb/cockroach/pkg/sql/vecindex/cspann/testutils"
15
- "github.com/cockroachdb/cockroach/pkg/sql/vecindex/veclib "
15
+ "github.com/cockroachdb/cockroach/pkg/sql/vecindex/cspann/workspace "
16
16
"github.com/cockroachdb/cockroach/pkg/util/vector"
17
17
"github.com/stretchr/testify/require"
18
18
"gonum.org/v1/gonum/floats/scalar"
@@ -28,7 +28,7 @@ func StoreTests(
28
28
testPKs []cspann.KeyBytes ,
29
29
testVectors []vector.T ,
30
30
) {
31
- var workspace veclib. Workspace
31
+ var workspace workspace. T
32
32
childKey2 := cspann.ChildKey {PartitionKey : 2 }
33
33
valueBytes2 := cspann.ValueBytes {0 }
34
34
primaryKey100 := cspann.ChildKey {KeyBytes : cspann.KeyBytes {1 , 00 }}
@@ -45,7 +45,7 @@ func StoreTests(
45
45
valueBytes600 := cspann.ValueBytes {11 , 12 }
46
46
47
47
t .Run ("get full vectors" , func (t * testing.T ) {
48
- txn := BeginTransaction (ctx , t , & workspace , store )
48
+ txn := BeginTransaction (ctx , t , store )
49
49
defer CommitTransaction (ctx , t , store , txn )
50
50
51
51
// Include primary keys that cannot be found.
@@ -84,7 +84,7 @@ func StoreTests(
84
84
})
85
85
86
86
t .Run ("search empty root partition" , func (t * testing.T ) {
87
- txn := BeginTransaction (ctx , t , & workspace , store )
87
+ txn := BeginTransaction (ctx , t , store )
88
88
defer CommitTransaction (ctx , t , store , txn )
89
89
90
90
searchSet := cspann.SearchSet {MaxResults : 2 }
@@ -103,7 +103,7 @@ func StoreTests(
103
103
})
104
104
105
105
t .Run ("add to root partition" , func (t * testing.T ) {
106
- txn := BeginTransaction (ctx , t , & workspace , store )
106
+ txn := BeginTransaction (ctx , t , store )
107
107
defer CommitTransaction (ctx , t , store , txn )
108
108
109
109
// Get partition metadata with forUpdate = true before updates.
@@ -112,18 +112,22 @@ func StoreTests(
112
112
CheckPartitionMetadata (t , metadata , cspann .Level (1 ), vector.T {0 , 0 }, 0 )
113
113
114
114
// Add to root partition.
115
- metadata , err = txn .AddToPartition (ctx , cspann .RootKey , vector.T {1 , 2 }, primaryKey100 , valueBytes100 )
115
+ metadata , err = txn .AddToPartition (
116
+ ctx , cspann .RootKey , vector.T {1 , 2 }, primaryKey100 , valueBytes100 )
116
117
require .NoError (t , err )
117
118
CheckPartitionMetadata (t , metadata , cspann .LeafLevel , vector.T {0 , 0 }, 1 )
118
- metadata , err = txn .AddToPartition (ctx , cspann .RootKey , vector.T {7 , 4 }, primaryKey200 , valueBytes200 )
119
+ metadata , err = txn .AddToPartition (
120
+ ctx , cspann .RootKey , vector.T {7 , 4 }, primaryKey200 , valueBytes200 )
119
121
require .NoError (t , err )
120
122
CheckPartitionMetadata (t , metadata , cspann .LeafLevel , vector.T {0 , 0 }, 2 )
121
- metadata , err = txn .AddToPartition (ctx , cspann .RootKey , vector.T {4 , 3 }, primaryKey300 , valueBytes300 )
123
+ metadata , err = txn .AddToPartition (
124
+ ctx , cspann .RootKey , vector.T {4 , 3 }, primaryKey300 , valueBytes300 )
122
125
require .NoError (t , err )
123
126
CheckPartitionMetadata (t , metadata , cspann .LeafLevel , vector.T {0 , 0 }, 3 )
124
127
125
128
// Add duplicate and expect value to be overwritten
126
- metadata , err = txn .AddToPartition (ctx , cspann .RootKey , vector.T {5 , 5 }, primaryKey300 , valueBytes300 )
129
+ metadata , err = txn .AddToPartition (
130
+ ctx , cspann .RootKey , vector.T {5 , 5 }, primaryKey300 , valueBytes300 )
127
131
require .NoError (t , err )
128
132
CheckPartitionMetadata (t , metadata , cspann .LeafLevel , vector.T {0 , 0 }, 3 )
129
133
@@ -153,7 +157,7 @@ func StoreTests(
153
157
154
158
var root * cspann.Partition
155
159
t .Run ("get root partition" , func (t * testing.T ) {
156
- txn := BeginTransaction (ctx , t , & workspace , store )
160
+ txn := BeginTransaction (ctx , t , store )
157
161
defer CommitTransaction (ctx , t , store , txn )
158
162
159
163
// Get root partition.
@@ -184,7 +188,7 @@ func StoreTests(
184
188
})
185
189
186
190
t .Run ("replace root partition" , func (t * testing.T ) {
187
- txn := BeginTransaction (ctx , t , & workspace , store )
191
+ txn := BeginTransaction (ctx , t , store )
188
192
defer CommitTransaction (ctx , t , store , txn )
189
193
190
194
// Replace root partition.
@@ -220,7 +224,7 @@ func StoreTests(
220
224
221
225
var partitionKey1 cspann.PartitionKey
222
226
t .Run ("insert another partition and update it" , func (t * testing.T ) {
223
- txn := BeginTransaction (ctx , t , & workspace , store )
227
+ txn := BeginTransaction (ctx , t , store )
224
228
defer CommitTransaction (ctx , t , store , txn )
225
229
226
230
_ , err := txn .GetPartition (ctx , cspann .RootKey )
@@ -263,7 +267,7 @@ func StoreTests(
263
267
})
264
268
265
269
t .Run ("search multiple partitions at leaf level" , func (t * testing.T ) {
266
- txn := BeginTransaction (ctx , t , & workspace , store )
270
+ txn := BeginTransaction (ctx , t , store )
267
271
defer CommitTransaction (ctx , t , store , txn )
268
272
269
273
_ , err := txn .GetPartition (ctx , cspann .RootKey )
@@ -307,23 +311,21 @@ func CheckPartitionMetadata(
307
311
}
308
312
309
313
// BeginTransaction starts a new transaction for the given store and returns it.
310
- func BeginTransaction (
311
- ctx context.Context , t * testing.T , w * veclib.Workspace , store cspann.Store ,
312
- ) cspann.Txn {
313
- txn , err := store .Begin (ctx , w )
314
+ func BeginTransaction (ctx context.Context , t * testing.T , store cspann.Store ) cspann.Txn {
315
+ txn , err := store .BeginTransaction (ctx )
314
316
require .NoError (t , err )
315
317
return txn
316
318
}
317
319
318
320
// CommitTransaction commits a transaction that was started by BeginTransaction.
319
321
func CommitTransaction (ctx context.Context , t * testing.T , store cspann.Store , txn cspann.Txn ) {
320
- err := store .Commit (ctx , txn )
322
+ err := store .CommitTransaction (ctx , txn )
321
323
require .NoError (t , err )
322
324
}
323
325
324
326
// AbortTransaction aborts a transaction that was started by BeginTransaction.
325
327
func AbortTransaction (ctx context.Context , t * testing.T , store cspann.Store , txn cspann.Txn ) {
326
- err := store .Abort (ctx , txn )
328
+ err := store .AbortTransaction (ctx , txn )
327
329
require .NoError (t , err )
328
330
}
329
331
0 commit comments