@@ -389,6 +389,12 @@ func splitFinder(i, splits int, r keyRange, k keyTransformer) interface{} {
389389 return k .getKey (splitPoint )
390390}
391391
392+ func insertCountKey (idx , count int64 , kr keyRange ) int64 {
393+ stride := kr .max / (count + 1 ) - kr .min / (count + 1 )
394+ key := kr .min + (idx + 1 )* stride
395+ return key
396+ }
397+
392398// Tables implements the Generator interface.
393399func (w * kv ) Tables () []workload.Table {
394400 // Tables should only run on initialized workload, safe to call create without
@@ -430,9 +436,6 @@ func (w *kv) Tables() []workload.Table {
430436 // INSERT ... ON CONFLICT DO NOTHING statements.
431437 MayContainDuplicates : ! w .sequential ,
432438 FillBatch : func (batchIdx int , cb coldata.Batch , a * bufalloc.ByteAllocator ) {
433- // Grab a new state for each batch, under the assumption that
434- // FillBatch may be called concurrently.
435- ks := kg .newState ()
436439 rowBegin , rowEnd := batchIdx * batchSize , (batchIdx + 1 )* batchSize
437440 if rowEnd > w .insertCount {
438441 rowEnd = w .insertCount
@@ -448,11 +451,11 @@ func (w *kv) Tables() []workload.Table {
448451 {
449452 seq := rowBegin
450453 kg .transformer .fillColumnBatch (cb , a , func () (s int64 , ok bool ) {
451- if seq >= rowEnd {
452- return 0 , false
454+ if seq < rowEnd {
455+ seq ++
456+ return insertCountKey (int64 (seq - 1 ), int64 (w .insertCount ), kg .kr ), true
453457 }
454- seq ++
455- return ks .mapKey .mapKey (int64 (seq )), true
458+ return 0 , false
456459 })
457460 }
458461
0 commit comments