Skip to content

Commit

Permalink
workload: remove initial prefix from bank workload payload
Browse files Browse the repository at this point in the history
An `initial-` prefix is added to the payload column of the `bank`
table when the workload is initialized. It was introduced about 6
years ago [1] and its purpose at the time is not clear. There are two
main problems with it:

* the `initial-` prefix suggests the payload may be updated, but that
actually never happens.
* as currently implemented, it assumes that the `payload-bytes`
command line flag is at least `len([]byte("initial-"))`. Passing a
lower value to that command line flag leads to a panic. This is an
implicit assumption that should not exist.

This changes the row generation function so that `payload-bytes` bytes
are randomly generated and inserted into the `payload` column, without
the `initial-` prefix.

[1] d49d535

Epic: none

Release note: None
  • Loading branch information
renatolabs committed May 9, 2023
1 parent 2973e83 commit 90a9904
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/ccl/workloadccl/allccl/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func TestDeterministicInitialData(t *testing.T) {
// TODO(dan): We're starting to accumulate these various lists, bigInitialData
// is another. Consider moving them to be properties on the workload.Meta.
fingerprintGoldens := map[string]uint64{
`bank`: 0x7b4d519ed8bd07ce,
`bank`: 0xb9065bb21c3594a2,
`bulkingest`: 0xcf3e4028ac084aea,
`indexes`: 0xcbf29ce484222325,
`intro`: 0x81c6a8cfd9c3452a,
Expand Down
4 changes: 1 addition & 3 deletions pkg/workload/bank/bank.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ func (b *bank) Tables() []workload.Table {
for rowIdx := rowBegin; rowIdx < rowEnd; rowIdx++ {
var payload []byte
*a, payload = a.Alloc(b.payloadBytes, 0 /* extraCap */)
const initialPrefix = `initial-`
copy(payload[:len(initialPrefix)], []byte(initialPrefix))
randStringLetters(rng, payload[len(initialPrefix):])
randStringLetters(rng, payload)

rowOffset := rowIdx - rowBegin
idCol[rowOffset] = int64(rowIdx)
Expand Down
10 changes: 5 additions & 5 deletions pkg/workload/csv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ func TestHandleCSV(t *testing.T) {
}{
{
`?rows=1`, `
0,0,initial-dTqnRurXztAPkykhZWvsCmeJkMwRNcJAvTlNbgUEYfagEQJaHmfPsquKZUBOGwpAjPtATpGXFJkrtQCEJODSlmQctvyh`,
0,0,dTqnRurXztAPkykhZWvsCmeJkMwRNcJAvTlNbgUEYfagEQJaHmfPsquKZUBOGwpAjPtATpGXFJkrtQCEJODSlmQctvyhWevfEafP`,
},
{
`?rows=5&row-start=1&row-end=3&batch-size=1`, `
1,0,initial-vOpikzTTWxvMqnkpfEIVXgGyhZNDqvpVqpNnHawruAcIVltgbnIEIGmCDJcnkVkfVmAcutkMvRACFuUBPsZTemTDSfZT
2,0,initial-qMvoPeRiOBXvdVQxhZUfdmehETKPXyBaVWxzMqwiStIkxfoDFygYxIDyXiaVEarcwMboFhBlCAapvKijKAyjEAhRBNZz`,
1,0,vOpikzTTWxvMqnkpfEIVXgGyhZNDqvpVqpNnHawruAcIVltgbnIEIGmCDJcnkVkfVmAcutkMvRACFuUBPsZTemTDSfZTLdqDkrhj
2,0,qMvoPeRiOBXvdVQxhZUfdmehETKPXyBaVWxzMqwiStIkxfoDFygYxIDyXiaVEarcwMboFhBlCAapvKijKAyjEAhRBNZzvGuJkQXu`,
},
}

Expand Down Expand Up @@ -123,8 +123,8 @@ func TestCSVRowsReader(t *testing.T) {
b, err := io.ReadAll(r)
require.NoError(t, err)
expected := `
1,0,initial-vOpikzTTWxvMqnkpfEIVXgGyhZNDqvpVqpNnHawruAcIVltgbnIEIGmCDJcnkVkfVmAcutkMvRACFuUBPsZTemTDSfZT
2,0,initial-qMvoPeRiOBXvdVQxhZUfdmehETKPXyBaVWxzMqwiStIkxfoDFygYxIDyXiaVEarcwMboFhBlCAapvKijKAyjEAhRBNZz
1,0,vOpikzTTWxvMqnkpfEIVXgGyhZNDqvpVqpNnHawruAcIVltgbnIEIGmCDJcnkVkfVmAcutkMvRACFuUBPsZTemTDSfZTLdqDkrhj
2,0,qMvoPeRiOBXvdVQxhZUfdmehETKPXyBaVWxzMqwiStIkxfoDFygYxIDyXiaVEarcwMboFhBlCAapvKijKAyjEAhRBNZzvGuJkQXu
`
require.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(string(b)))
}
Expand Down

0 comments on commit 90a9904

Please sign in to comment.