Skip to content

Commit 3330d65

Browse files
committed
tests for varbit adaptive encoding
1 parent ac98998 commit 3330d65

1 file changed

Lines changed: 25 additions & 13 deletions

File tree

testing/go/adaptive_encoding_test.go

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ func makeTestBytes(size int, firstbyte byte) []byte {
3333
return bytes
3434
}
3535

36+
func makeTestVarbit(size int) []byte {
37+
bytes := make([]byte, size)
38+
for i := 0; i < size; i++ {
39+
if i%2 == 0 {
40+
bytes[i] = '1'
41+
} else {
42+
bytes[i] = '0'
43+
}
44+
}
45+
return bytes
46+
}
47+
3648
// A 4000 byte file starting with 0x01 and then consisting of all zeros.
3749
// This is larger than default target tuple size for outlining adaptive types.
3850
// We expect a tuple to always store this value out-of-band
@@ -51,17 +63,17 @@ var tinyString = string(makeTestBytes(10, 3))
5163
// A 4000 byte file starting with ascii byte 1 and then consisting of all zeros.
5264
// This is larger than default target tuple size for outlining adaptive types.
5365
// We expect a tuple to always store this value out-of-band
54-
var fullSizeVarbit = string(makeTestBytes(4000, '1'))
66+
var fullSizeVarbit = string(makeTestVarbit(4000))
5567

5668
// A 2000 byte file starting with ascii byte 1 and then consisting of all zeros.
5769
// This is over half of the default target tuple size for outlining adaptive types.
5870
// We expect a tuple to be able to store this value inline once, but not twice.
59-
var halfSizeVarbit = string(makeTestBytes(2000, '1'))
71+
var halfSizeVarbit = string(makeTestVarbit(2000))
6072

6173
// A 10 byte file starting with ascii byte 1 and then consisting of 10 zero bytes.
6274
// This is file is smaller than an address hash.
6375
// We expect a tuple to never store this value out-of-band.
64-
var tinyVarbit = string(makeTestBytes(10, '1'))
76+
var tinyVarbit = string(makeTestVarbit(10))
6577

6678
func TestAdaptiveEncodingText(t *testing.T) {
6779
fullSizeOutOfLineRepr := fullSizeString
@@ -244,15 +256,15 @@ func TestAdaptiveEncodingVarbit(t *testing.T) {
244256
SetUpScript: setup.SetupScript{
245257
fmt.Sprintf(`create table blobt2 (i char(2) primary key, b1 %s, b2 %s);`, columnType, columnType),
246258
`insert into blobt2 values
247-
('FF', LOAD_FILE('testdata/fullSize'), LOAD_FILE('testdata/fullSize')),
248-
('HF', LOAD_FILE('testdata/halfSize'), LOAD_FILE('testdata/fullSize')),
249-
('TF', LOAD_FILE('testdata/tinyFile'), LOAD_FILE('testdata/fullSize')),
250-
('FH', LOAD_FILE('testdata/fullSize'), LOAD_FILE('testdata/halfSize')),
251-
('HH', LOAD_FILE('testdata/halfSize'), LOAD_FILE('testdata/halfSize')),
252-
('TH', LOAD_FILE('testdata/tinyFile'), LOAD_FILE('testdata/halfSize')),
253-
('FT', LOAD_FILE('testdata/fullSize'), LOAD_FILE('testdata/tinyFile')),
254-
('HT', LOAD_FILE('testdata/halfSize'), LOAD_FILE('testdata/tinyFile')),
255-
('TT', LOAD_FILE('testdata/tinyFile'), LOAD_FILE('testdata/tinyFile'))`,
259+
('FF', LOAD_FILE('testdata/fullSizeVarbit'), LOAD_FILE('testdata/fullSizeVarbit')),
260+
('HF', LOAD_FILE('testdata/halfSizeVarbit'), LOAD_FILE('testdata/fullSizeVarbit')),
261+
('TF', LOAD_FILE('testdata/tinyFileVarbit'), LOAD_FILE('testdata/fullSizeVarbit')),
262+
('FH', LOAD_FILE('testdata/fullSizeVarbit'), LOAD_FILE('testdata/halfSizeVarbit')),
263+
('HH', LOAD_FILE('testdata/halfSizeVarbit'), LOAD_FILE('testdata/halfSizeVarbit')),
264+
('TH', LOAD_FILE('testdata/tinyFileVarbit'), LOAD_FILE('testdata/halfSizeVarbit')),
265+
('FT', LOAD_FILE('testdata/fullSizeVarbit'), LOAD_FILE('testdata/tinyFileVarbit')),
266+
('HT', LOAD_FILE('testdata/halfSizeVarbit'), LOAD_FILE('testdata/tinyFileVarbit')),
267+
('TT', LOAD_FILE('testdata/tinyFileVarbit'), LOAD_FILE('testdata/tinyFileVarbit'))`,
256268
},
257269
Assertions: []ScriptTestAssertion{
258270
{
@@ -310,7 +322,7 @@ func TestAdaptiveEncodingVarbit(t *testing.T) {
310322
// And adaptive values are always outlined starting from the left.
311323
// This means that in a table with two adaptive columns where both columns were previously stored out-of line,
312324
// Decreasing the size of the second column may allow both columns to be stored inline.
313-
Query: "UPDATE blobt2 SET b2 = LOAD_FILE('testdata/tinyFile') WHERE i = 'HH'",
325+
Query: "UPDATE blobt2 SET b2 = LOAD_FILE('testdata/tinyFileVarbit') WHERE i = 'HH'",
314326
},
315327
{
316328
Query: "select i, b1, b2 from blobt2 where i = 'HH'",

0 commit comments

Comments
 (0)