Skip to content

Commit 7608143

Browse files
committed
workload/bank: rename --num-tables flag to --tables
This patch renames the `--num-tables` flag to `--tables` to be consistent with the existing `--rows` and `--ranges` flags. Release note: None
1 parent a4981fb commit 7608143

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

pkg/cmd/roachtest/tests/cdc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,7 +1825,7 @@ func runCDCMultiTablePTSBenchmark(
18251825
}
18261826
}
18271827

1828-
initCmd := fmt.Sprintf("./cockroach workload init bank --rows=%d --ranges=%d --num-tables=%d {pgurl%s}",
1828+
initCmd := fmt.Sprintf("./cockroach workload init bank --rows=%d --ranges=%d --tables=%d {pgurl%s}",
18291829
params.numRows, numRanges, params.numTables, ct.crdbNodes.RandNode())
18301830
if err := c.RunE(ctx, option.WithNodes(ct.workloadNode), initCmd); err != nil {
18311831
t.Fatalf("failed to initialize bank tables: %v", err)
@@ -1834,7 +1834,7 @@ func runCDCMultiTablePTSBenchmark(
18341834
ct.workloadWg.Add(1)
18351835
ct.mon.Go(func(ctx context.Context) error {
18361836
defer ct.workloadWg.Done()
1837-
workloadCmd := fmt.Sprintf("./cockroach workload run bank --rows=%d --duration=%s --num-tables=%d {pgurl%s}",
1837+
workloadCmd := fmt.Sprintf("./cockroach workload run bank --rows=%d --duration=%s --tables=%d {pgurl%s}",
18381838
params.numRows, params.duration, params.numTables, ct.crdbNodes)
18391839
return c.RunE(ctx, option.WithNodes(ct.workloadNode), workloadCmd)
18401840
})

pkg/workload/bank/bank.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const (
3434
defaultBatchSize = 1000
3535
defaultPayloadBytes = 100
3636
defaultRanges = 10
37-
defaultNumTables = 1
37+
defaultTables = 1
3838
maxTransfer = 999
3939
)
4040

@@ -46,7 +46,7 @@ type bank struct {
4646

4747
rows, batchSize int
4848
payloadBytes, ranges int
49-
numTables int
49+
tables int
5050
}
5151

5252
func init() {
@@ -68,7 +68,7 @@ var bankMeta = workload.Meta{
6868
g.flags.IntVar(&g.batchSize, `batch-size`, defaultBatchSize, `Number of rows in each batch of initial data.`)
6969
g.flags.IntVar(&g.payloadBytes, `payload-bytes`, defaultPayloadBytes, `Size of the payload field in each initial row.`)
7070
g.flags.IntVar(&g.ranges, `ranges`, defaultRanges, `Initial number of ranges in bank table.`)
71-
g.flags.IntVar(&g.numTables, `num-tables`, defaultNumTables, `Number of bank tables to create.`)
71+
g.flags.IntVar(&g.tables, `tables`, defaultTables, `Initial number of bank tables to create.`)
7272
RandomSeed.AddFlag(&g.flags)
7373
g.connFlags = workload.NewConnFlags(&g.flags)
7474
// Because this workload can create a large number of objects, the import
@@ -123,8 +123,8 @@ func (b *bank) Hooks() workload.Hooks {
123123
if b.batchSize <= 0 {
124124
return errors.Errorf(`Value of batch-size must be greater than zero; was %d`, b.batchSize)
125125
}
126-
if b.numTables <= 0 {
127-
return errors.Errorf(`Value of num-tables must be greater than zero; was %d`, b.numTables)
126+
if b.tables <= 0 {
127+
return errors.Errorf(`Value of tables must be greater than zero; was %d`, b.tables)
128128
}
129129
return nil
130130
},
@@ -133,7 +133,7 @@ func (b *bank) Hooks() workload.Hooks {
133133

134134
// tableName returns the table name with optional schema prefix and table number.
135135
func (b *bank) tableName(baseName string, tableIdx int) string {
136-
if b.numTables > 1 {
136+
if b.tables > 1 {
137137
return fmt.Sprintf("%s_%d", baseName, tableIdx)
138138
}
139139
return baseName
@@ -149,8 +149,8 @@ var bankTypes = []*types.T{
149149
func (b *bank) Tables() []workload.Table {
150150
numBatches := (b.rows + b.batchSize - 1) / b.batchSize // ceil(b.rows/b.batchSize)
151151

152-
tables := make([]workload.Table, b.numTables)
153-
for tableIdx := range b.numTables {
152+
tables := make([]workload.Table, b.tables)
153+
for tableIdx := range b.tables {
154154
table := workload.Table{
155155
Name: b.tableName(`bank`, tableIdx),
156156
Schema: bankSchema,
@@ -208,8 +208,8 @@ func (b *bank) Ops(
208208
db.SetMaxIdleConns(b.connFlags.Concurrency + 1)
209209

210210
// TODO(dan): Move the various queries in the backup/restore tests here.
211-
updateStmts := make([]*gosql.Stmt, b.numTables)
212-
for tableIdx := range b.numTables {
211+
updateStmts := make([]*gosql.Stmt, b.tables)
212+
for tableIdx := range b.tables {
213213
updateStmt, err := db.Prepare(fmt.Sprintf(`
214214
UPDATE %s
215215
SET balance = CASE id WHEN $1 THEN balance-$3 WHEN $2 THEN balance+$3 END
@@ -233,7 +233,7 @@ func (b *bank) Ops(
233233
hists := reg.GetHandle()
234234

235235
workerFn := func(ctx context.Context) error {
236-
tableIdx := rng.IntN(b.numTables)
236+
tableIdx := rng.IntN(b.tables)
237237
updateStmt := updateStmts[tableIdx]
238238

239239
from := rng.IntN(b.rows)

0 commit comments

Comments
 (0)