@@ -14,6 +14,7 @@ import (
1414 "github.com/cockroachdb/cockroach/pkg/util/bufalloc"
1515 "github.com/cockroachdb/cockroach/pkg/util/uuid"
1616 "github.com/cockroachdb/cockroach/pkg/workload"
17+ randold "golang.org/x/exp/rand"
1718)
1819
1920// These constants are all set by the spec - they're not knobs. Don't change
@@ -57,6 +58,7 @@ const (
5758
5859type generateLocals struct {
5960 rng tpccRand
61+ rngOld tpccRandOld
6062 uuidAlloc uuid.UUID
6163}
6264
@@ -480,8 +482,8 @@ func (w *tpcc) tpccOrderInitialRowBatch(rowIdx int, cb coldata.Batch, a *bufallo
480482
481483 // NB: numOrderLines is not allowed to use precomputed random data, make sure
482484 // it stays that way. See 4.3.2.1.
483- l .rng . Rand = rand . New ( rand . NewPCG ( RandomSeed .Seed (), uint64 (rowIdx ) ))
484- numOrderLines := randInt (l .rng .Rand , minOrderLinesPerOrder , maxOrderLinesPerOrder )
485+ l .rngOld . Seed ( RandomSeed .Seed () + uint64 (rowIdx ))
486+ numOrderLines := randIntOld (l .rngOld .Rand , minOrderLinesPerOrder , maxOrderLinesPerOrder )
485487
486488 oID := (rowIdx % numOrdersPerDistrict ) + 1
487489 dID := ((rowIdx / numOrdersPerDistrict ) % numDistrictsPerWarehouse ) + 1
@@ -500,7 +502,7 @@ func (w *tpcc) tpccOrderInitialRowBatch(rowIdx int, cb coldata.Batch, a *bufallo
500502 // We need a random permutation of customers that stable for all orders in a
501503 // district, so use the district ID to seed the random permutation.
502504 w .randomCIDsCache .values [dID ] = make ([]int , numCustomersPerDistrict )
503- for i , cID := range rand .New (rand . NewPCG (uint64 (dID ), 0 )).Perm (numCustomersPerDistrict ) {
505+ for i , cID := range randold .New (randold . NewSource (uint64 (dID ))).Perm (numCustomersPerDistrict ) {
504506 w .randomCIDsCache .values [dID ][i ] = cID + 1
505507 }
506508 }
@@ -512,7 +514,7 @@ func (w *tpcc) tpccOrderInitialRowBatch(rowIdx int, cb coldata.Batch, a *bufallo
512514 var carrierID int64
513515 if oID < 2101 {
514516 carrierSet = true
515- carrierID = randInt (l .rng .Rand , 1 , 10 )
517+ carrierID = randIntOld (l .rngOld .Rand , 1 , 10 )
516518 }
517519
518520 cb .Reset (orderTypes , 1 , coldata .StandardColumnFactory )
@@ -601,15 +603,15 @@ func (w *tpcc) tpccOrderLineInitialRowBatch(
601603
602604 // NB: numOrderLines is not allowed to use precomputed random data, make sure
603605 // it stays that way. See 4.3.2.1.
604- l .rng . Rand = rand . New ( rand . NewPCG ( RandomSeed .Seed (), uint64 (orderRowIdx ) ))
605- numOrderLines := int (randInt (l .rng .Rand , minOrderLinesPerOrder , maxOrderLinesPerOrder ))
606+ l .rngOld . Seed ( RandomSeed .Seed () + uint64 (orderRowIdx ))
607+ numOrderLines := int (randIntOld (l .rngOld .Rand , minOrderLinesPerOrder , maxOrderLinesPerOrder ))
606608
607609 // NB: There is one batch of order_line rows per order
608610 oID := (orderRowIdx % numOrdersPerDistrict ) + 1
609611 dID := ((orderRowIdx / numOrdersPerDistrict ) % numDistrictsPerWarehouse ) + 1
610612 wID := (orderRowIdx / numOrdersPerWarehouse )
611613
612- ao := aCharsOffset (l .rng . IntN (len (aCharsAlphabet )))
614+ ao := aCharsOffset (l .rngOld . Intn (len (aCharsAlphabet )))
613615 cb .Reset (orderLineTypes , numOrderLines , coldata .StandardColumnFactory )
614616 olOIDCol := cb .ColVec (0 ).Int64 ()
615617 olDIDCol := cb .ColVec (1 ).Int64 ()
@@ -634,14 +636,14 @@ func (w *tpcc) tpccOrderLineInitialRowBatch(
634636 amount = 0
635637 deliveryDSet = true
636638 } else {
637- amount = float64 (randInt (l .rng .Rand , 1 , 999999 )) / 100.0
639+ amount = float64 (randIntOld (l .rngOld .Rand , 1 , 999999 )) / 100.0
638640 }
639641
640642 olOIDCol [rowIdx ] = int64 (oID )
641643 olDIDCol [rowIdx ] = int64 (dID )
642644 olWIDCol [rowIdx ] = int64 (wID )
643645 olNumberCol [rowIdx ] = int64 (olNumber )
644- olIIDCol [rowIdx ] = randInt (l .rng .Rand , 1 , 100000 )
646+ olIIDCol [rowIdx ] = randIntOld (l .rngOld .Rand , 1 , 100000 )
645647 olSupplyWIDCol [rowIdx ] = int64 (wID )
646648 if deliveryDSet {
647649 olDeliveryDCol .Set (rowIdx , w .nowTime )
@@ -650,7 +652,7 @@ func (w *tpcc) tpccOrderLineInitialRowBatch(
650652 }
651653 olQuantityCol [rowIdx ] = 5
652654 olAmountCol [rowIdx ] = amount
653- olDistInfoCol .Set (rowIdx , randAStringInitialDataOnly (& l .rng , & ao , a , 24 , 24 ))
655+ olDistInfoCol .Set (rowIdx , randAStringInitialDataOnlyOld (& l .rngOld , & ao , a , 24 , 24 ))
654656 }
655657}
656658
0 commit comments