Skip to content

Commit

Permalink
workload/indexes: add --cycle-length flag
Browse files Browse the repository at this point in the history
Controls the number of keys repeatedly accessed by each
writer through upserts. Mirrors the same flag in `kv`.
  • Loading branch information
nvanbenschoten committed Aug 20, 2020
1 parent 7a79922 commit d67890c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/workload/indexes/indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ type indexes struct {
flags workload.Flags
connFlags *workload.ConnFlags

seed int64
idxs int
unique bool
payload int
seed int64
idxs int
unique bool
payload int
cycleLength uint64
}

func init() {
Expand All @@ -68,6 +69,8 @@ var indexesMeta = workload.Meta{
g.flags.IntVar(&g.idxs, `secondary-indexes`, 1, `Number of indexes to add to the table.`)
g.flags.BoolVar(&g.unique, `unique-indexes`, false, `Use UNIQUE secondary indexes.`)
g.flags.IntVar(&g.payload, `payload`, 64, `Size of the unindexed payload column.`)
g.flags.Uint64Var(&g.cycleLength, `cycle-length`, math.MaxUint64,
`Number of keys repeatedly accessed by each writer through upserts.`)
g.connFlags = workload.NewConnFlags(&g.flags)
return g
},
Expand Down Expand Up @@ -184,10 +187,10 @@ type indexesOp struct {
}

func (o *indexesOp) run(ctx context.Context) error {
keyHi, keyLo := o.rand.Uint64(), o.rand.Uint64()
keyLo := o.rand.Uint64() % o.config.cycleLength
_, _ = o.rand.Read(o.buf[:])
args := []interface{}{
uuid.FromUint128(uint128.FromInts(keyHi, keyLo)).String(), // key
uuid.FromUint128(uint128.FromInts(0, keyLo)).String(), // key
int64(keyLo + 0), // col0
int64(keyLo + 1), // col1
int64(keyLo + 2), // col2
Expand Down

0 comments on commit d67890c

Please sign in to comment.