Skip to content

Commit 1dc0749

Browse files
committed
sstable: clean up tests to use new key format
Clean up the sstable tests to use the newer internal key format. Update some test code to increase reuse.
1 parent 04cf5d8 commit 1dc0749

File tree

31 files changed

+1073
-1092
lines changed

31 files changed

+1073
-1092
lines changed

sstable/copier_test.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,8 @@ func TestCopySpan(t *testing.T) {
8686
t.Fatal(err)
8787
}
8888
w := NewWriter(objstorageprovider.NewFileWritable(f), writerOpts)
89-
for _, key := range strings.Split(d.Input, "\n") {
90-
j := strings.Index(key, ":")
91-
ikey := base.ParseInternalKey(key[:j])
92-
value := []byte(key[j+1:])
93-
if err := w.Set(ikey.UserKey, value); err != nil {
94-
return err.Error()
95-
}
89+
if err := ParseTestSST(w.rw, d.Input, nil /* bv */); err != nil {
90+
t.Fatal(err)
9691
}
9792
if err := w.Close(); err != nil {
9893
return err.Error()

sstable/data_test.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/cockroachdb/pebble/internal/base"
1919
"github.com/cockroachdb/pebble/internal/blobtest"
2020
"github.com/cockroachdb/pebble/internal/cache"
21-
"github.com/cockroachdb/pebble/internal/keyspan"
2221
"github.com/cockroachdb/pebble/internal/sstableinternal"
2322
"github.com/cockroachdb/pebble/internal/testkeys"
2423
"github.com/cockroachdb/pebble/objstorage"
@@ -130,21 +129,8 @@ func runBuildRawCmd(
130129
_ = w.Close()
131130
}
132131
}()
133-
for _, data := range strings.Split(td.Input, "\n") {
134-
if strings.HasPrefix(data, "Span:") {
135-
data = strings.TrimPrefix(data, "Span:")
136-
if err := w.EncodeSpan(keyspan.ParseSpan(data)); err != nil {
137-
return nil, nil, err
138-
}
139-
continue
140-
}
141-
142-
j := strings.Index(data, ":")
143-
key := base.ParseInternalKey(data[:j])
144-
value := []byte(data[j+1:])
145-
if err := w.Add(key, value, false); err != nil {
146-
return nil, nil, err
147-
}
132+
if err := ParseTestSST(w, td.Input, nil /* bv */); err != nil {
133+
return nil, nil, err
148134
}
149135
if err := w.Close(); err != nil {
150136
return nil, nil, err

sstable/testdata/block_properties

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
# Single collector.
1010

1111
build collectors=(value-first)
12-
a.SET.1:10
13-
b.SET.2:20
14-
c.SET.3:30
12+
a#1,SET:10
13+
b#2,SET:20
14+
c#3,SET:30
1515
----
1616
point: [a#1,SET-c#3,SET]
1717
seqnums: [1-3]
@@ -37,9 +37,9 @@ c:
3737
# Multiple collectors.
3838

3939
build collectors=(value-first,value-last)
40-
a.SET.1:17
41-
b.SET.2:29
42-
c.SET.3:38
40+
a#1,SET:17
41+
b#2,SET:29
42+
c#3,SET:38
4343
----
4444
point: [a#1,SET-c#3,SET]
4545
seqnums: [1-3]
@@ -64,14 +64,14 @@ c:
6464
# pairs.
6565

6666
build block-size=25 collectors=(value-first,value-last)
67-
a.SET.1:15
68-
b.SET.2:86
69-
c.SET.3:72
70-
d.SET.4:21
71-
e.SET.5:47
72-
f.SET.6:54
73-
g.SET.7:63
74-
h.SET.8:38
67+
a#1,SET:15
68+
b#2,SET:86
69+
c#3,SET:72
70+
d#4,SET:21
71+
e#5,SET:47
72+
f#6,SET:54
73+
g#7,SET:63
74+
h#8,SET:38
7575
----
7676
point: [a#1,SET-h#8,SET]
7777
seqnums: [1-8]
@@ -105,9 +105,9 @@ h:
105105
# data blocks.
106106

107107
build collectors=(suffix)
108-
a@5.SET.1:foo
109-
b@10.SET.2:bar
110-
c@15.SET.3:baz
108+
a@5#1,SET:foo
109+
b@10#2,SET:bar
110+
c@15#3,SET:baz
111111
Span: d@10-e@15:{(#4,RANGEKEYSET,@20,foo)}
112112
Span: e@15-f@20:{(#5,RANGEKEYUNSET,@25)}
113113
Span: f@20-z@25:{(#6,RANGEKEYDEL)}
@@ -132,9 +132,9 @@ table-props
132132
# Same as the above, but only collect point key properties.
133133

134134
build collectors=(suffix-point-keys-only)
135-
a@5.SET.1:foo
136-
b@10.SET.2:bar
137-
c@15.SET.3:baz
135+
a@5#1,SET:foo
136+
b@10#2,SET:bar
137+
c@15#3,SET:baz
138138
Span: d@10-e@15:{(#4,RANGEKEYSET,@20,foo)}
139139
Span: e@15-f@20:{(#5,RANGEKEYUNSET,@25)}
140140
Span: f@20-z@25:{(#6,RANGEKEYDEL)}
@@ -159,9 +159,9 @@ table-props
159159
# Same as the above, but only collect range key properties.
160160

161161
build collectors=(suffix-range-keys-only)
162-
a@5.SET.1:foo
163-
b@10.SET.2:bar
164-
c@15.SET.3:baz
162+
a@5#1,SET:foo
163+
b@10#2,SET:bar
164+
c@15#3,SET:baz
165165
Span: d@10-e@15:{(#4,RANGEKEYSET,@20,foo)}
166166
Span: e@15-f@20:{(#5,RANGEKEYUNSET,@25)}
167167
Span: f@20-z@25:{(#6,RANGEKEYDEL)}
@@ -187,9 +187,9 @@ table-props
187187
# acting independently.
188188

189189
build block-size=1 collectors=(suffix-point-keys-only,suffix-range-keys-only)
190-
a@5.SET.1:foo
191-
b@10.SET.2:bar
192-
c@15.SET.3:baz
190+
a@5#1,SET:foo
191+
b@10#2,SET:bar
192+
c@15#3,SET:baz
193193
Span: d@10-e@15:{(#4,RANGEKEYSET,@20,foo)}
194194
Span: e@15-f@20:{(#5,RANGEKEYUNSET,@25)}
195195
Span: f@20-z@25:{(#6,RANGEKEYDEL)}
@@ -283,12 +283,12 @@ mapper must be provided
283283
# and every index block points to one data block.
284284

285285
build collectors=(suffix-point-keys-only) index-block-size=1 block-size=1
286-
a@1.SET.1:foo
287-
b@10.SET.2:bar
288-
c@15.SET.3:baz
289-
d@25.SET.4:bax
290-
e@3.SET.5:box
291-
f@5.SET.3:mop
286+
a@1#1,SET:foo
287+
b@10#2,SET:bar
288+
c@15#3,SET:baz
289+
d@25#4,SET:bax
290+
e@3#5,SET:box
291+
f@5#3,SET:mop
292292
----
293293
point: [a@1#1,SET-f@5#3,SET]
294294
seqnums: [1-5]
@@ -337,12 +337,12 @@ g:
337337
# of all the data blocks' properties.
338338

339339
build collectors=(suffix-point-keys-only) index-block-size=64 block-size=1
340-
a@1.SET.1:foo
341-
b@10.SET.2:bar
342-
c@15.SET.3:baz
343-
d@25.SET.4:bax
344-
e@3.SET.5:box
345-
f@5.SET.3:mop
340+
a@1#1,SET:foo
341+
b@10#2,SET:bar
342+
c@15#3,SET:baz
343+
d@25#4,SET:bax
344+
e@3#5,SET:box
345+
f@5#3,SET:mop
346346
----
347347
point: [a@1#1,SET-f@5#3,SET]
348348
seqnums: [1-5]
@@ -392,12 +392,12 @@ last
392392
# instead of within SeekLT and Last.
393393

394394
build collectors=(suffix-point-keys-only) index-block-size=48 block-size=1
395-
a@1.SET.1:foo
396-
b@10.SET.2:bar
397-
c@15.SET.3:baz
398-
d@25.SET.4:bax
399-
e@3.SET.5:box
400-
f@5.SET.3:mop
395+
a@1#1,SET:foo
396+
b@10#2,SET:bar
397+
c@15#3,SET:baz
398+
d@25#4,SET:bax
399+
e@3#5,SET:box
400+
f@5#3,SET:mop
401401
----
402402
point: [a@1#1,SET-f@5#3,SET]
403403
seqnums: [1-5]
@@ -588,12 +588,12 @@ seek-ge c@19 true
588588
# subsequent seek must return MaybeFilteredKeys=true when keys were filtered.
589589

590590
build collectors=(suffix-point-keys-only) index-block-size=1 block-size=64
591-
a@1.SET.1:foo
592-
b@10.SET.2:bar
593-
c@15.SET.3:baz
594-
d@25.SET.4:bax
595-
e@3.SET.5:box
596-
f@5.SET.3:mop
591+
a@1#1,SET:foo
592+
b@10#2,SET:bar
593+
c@15#3,SET:baz
594+
d@25#4,SET:bax
595+
e@3#5,SET:box
596+
f@5#3,SET:mop
597597
----
598598
point: [a@1#1,SET-f@5#3,SET]
599599
seqnums: [1-5]
@@ -627,12 +627,12 @@ seek-ge ee
627627
# filtered.
628628

629629
build collectors=(suffix-point-keys-only) block-size=32
630-
a@1.SET.1:foo
631-
b@10.SET.2:bar
632-
c@15.SET.3:baz
633-
d@25.SET.4:bax
634-
e@3.SET.5:box
635-
f@5.SET.3:mop
630+
a@1#1,SET:foo
631+
b@10#2,SET:bar
632+
c@15#3,SET:baz
633+
d@25#4,SET:bax
634+
e@3#5,SET:box
635+
f@5#3,SET:mop
636636
----
637637
point: [a@1#1,SET-f@5#3,SET]
638638
seqnums: [1-5]
@@ -661,9 +661,9 @@ seek-ge ee
661661
# injection during block property filtering
662662

663663
build block-size=1 collectors=(suffix-point-keys-only)
664-
a@5.SET.1:foo
665-
b@8.SET.2:bar
666-
c@7.SET.3:baz
664+
a@5#1,SET:foo
665+
b@8#2,SET:bar
666+
c@7#3,SET:baz
667667
----
668668
point: [a@5#1,SET-c@7#3,SET]
669669
seqnums: [1-3]
@@ -698,13 +698,13 @@ points: false
698698
ranges: true (no filters provided)
699699

700700
build collectors=(suffix-point-keys-only) index-block-size=48 block-size=1
701-
a@10.SET.1:foo
702-
a@9.SET.2:bar
703-
a@8.SET.2:baz
704-
a@7.SET.2:bax
705-
aa@9.SET.3:mop
706-
aa@8.SET.3:box
707-
f@5.SET.3:mop
701+
a@10#1,SET:foo
702+
a@9#2,SET:bar
703+
a@8#2,SET:baz
704+
a@7#2,SET:bax
705+
aa@9#3,SET:mop
706+
aa@8#3,SET:box
707+
f@5#3,SET:mop
708708
----
709709
point: [a@10#1,SET-f@5#3,SET]
710710
seqnums: [1-3]

sstable/testdata/block_properties_boundlimited

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
build block-size=28 collectors=(suffix)
2-
a@5.SET.1:15
3-
b@2.SET.2:86
4-
c@9.SET.3:72
5-
d@3.SET.4:21
6-
e@2.SET.5:47
7-
f@0.SET.6:54
8-
g@8.SET.7:63
9-
h@3.SET.8:38
2+
a@5#1,SET:15
3+
b@2#2,SET:86
4+
c@9#3,SET:72
5+
d@3#4,SET:21
6+
e@2#5,SET:47
7+
f@0#6,SET:54
8+
g@8#7,SET:63
9+
h@3#8,SET:38
1010
----
1111
point: [a@5#1,SET-h@3#8,SET]
1212
seqnums: [1-8]

sstable/testdata/columnar_writer/simple_binary

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
build
2-
a.SET.1:a
3-
b.DEL.2:
2+
a#1,SET:a
3+
b#2,DEL:
44
----
55
point: [a#1,SET-b#2,DEL]
66
seqnums: [1-2]
@@ -140,9 +140,9 @@ obsolete-key: hex:01
140140
pebble.internal.testkeys.suffixes: hex:0000ffffffffffffffffff01
141141

142142
build block-size=310
143-
a.SET.1:apple
144-
b.SET.1:banana
145-
c.SET.1:cantelope
143+
a#1,SET:apple
144+
b#1,SET:banana
145+
c#1,SET:cantelope
146146
----
147147
point: [a#1,SET-c#1,SET]
148148
seqnums: [1-1]
@@ -264,27 +264,27 @@ sstable
264264
└── 045 magic number: 0xf09faab3f09faab3
265265

266266
build block-size=150
267-
a.SET.1:apple
268-
b.SET.1:banana
269-
c.SET.1:cantelope
270-
d.SET.1:dragonfruit
271-
e.SET.1:elderberry
272-
f.SET.1:fig
273-
g.SET.1:grapefruit
274-
h.SET.1:honeydew
275-
i.SET.1:imbe
276-
j.SET.1:jackfruit
277-
k.SET.1:kiwi
278-
l.SET.1:lemon
279-
m.SET.1:mango
280-
n.SET.1:nectarine
281-
o.SET.1:orange
282-
p.SET.1:pamplemousse
283-
q.SET.1:quince
284-
r.SET.1:raspberry
285-
s.SET.1:strawberry
286-
t.SET.1:tangerine
287-
u.SET.1:ume
267+
a#1,SET:apple
268+
b#1,SET:banana
269+
c#1,SET:cantelope
270+
d#1,SET:dragonfruit
271+
e#1,SET:elderberry
272+
f#1,SET:fig
273+
g#1,SET:grapefruit
274+
h#1,SET:honeydew
275+
i#1,SET:imbe
276+
j#1,SET:jackfruit
277+
k#1,SET:kiwi
278+
l#1,SET:lemon
279+
m#1,SET:mango
280+
n#1,SET:nectarine
281+
o#1,SET:orange
282+
p#1,SET:pamplemousse
283+
q#1,SET:quince
284+
r#1,SET:raspberry
285+
s#1,SET:strawberry
286+
t#1,SET:tangerine
287+
u#1,SET:ume
288288
----
289289
point: [a#1,SET-u#1,SET]
290290
seqnums: [1-1]

0 commit comments

Comments
 (0)