Skip to content

Commit

Permalink
sstable: fix TestBlockProperties[BoundLimited] to use testkeys.Comparer
Browse files Browse the repository at this point in the history
This test used testkeys.Comparer in some instances but not all.
  • Loading branch information
jbowens committed Aug 21, 2024
1 parent de53a98 commit 9f97b7b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 46 deletions.
1 change: 1 addition & 0 deletions sstable/block_property_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,7 @@ func runTablePropsCmd(r *Reader, td *datadriven.TestData) string {

func runBlockPropertiesBuildCmd(td *datadriven.TestData) (r *Reader, out string) {
opts := WriterOptions{
Comparer: testkeys.Comparer,
TableFormat: TableFormatPebblev2,
IndexBlockSize: math.MaxInt32, // Default to a single level index for simplicity.
}
Expand Down
2 changes: 1 addition & 1 deletion sstable/reader_iter_two_lvl.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ func (i *twoLevelIterator[D, PD]) NextPrefix(succKey []byte) *base.InternalKV {
if ikv := i.secondLevel.NextPrefix(succKey); ikv != nil {
return ikv
}
// key == nil
// ikv == nil
if i.secondLevel.err != nil {
return nil
}
Expand Down
79 changes: 43 additions & 36 deletions sstable/testdata/block_properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ table-props
# is printed, along with the properties for the block, keyed by the shortID.
block-props
----
d#inf,SEPARATOR:
c#3,SET:
0: [1, 4)

# Multiple collectors.
Expand All @@ -56,7 +56,7 @@ table-props

block-props
----
d#inf,SEPARATOR:
c#3,SET:
0: [1, 4)
1: [7, 10)

Expand Down Expand Up @@ -97,7 +97,7 @@ d#4,SET:
f#6,SET:
0: [4, 6)
1: [4, 8)
i#inf,SEPARATOR:
h#8,SET:
0: [3, 7)
1: [3, 9)

Expand Down Expand Up @@ -205,9 +205,9 @@ collectors

block-props
----
b#inf,SEPARATOR:
a@5#1,SET:
0: [5, 6)
c#inf,SEPARATOR:
b@10#2,SET:
0: [10, 11)
d#inf,SEPARATOR:
0: [15, 16)
Expand Down Expand Up @@ -307,25 +307,25 @@ table-props

block-props
----
b#inf,SEPARATOR:
a@1#1,SET:
0: [1, 2)
b#inf,SEPARATOR:
a@1#1,SET:
0: [1, 2)
c#inf,SEPARATOR:
b@10#2,SET:
0: [10, 11)
c#inf,SEPARATOR:
b@10#2,SET:
0: [10, 11)
d#inf,SEPARATOR:
c@15#3,SET:
0: [15, 16)
d#inf,SEPARATOR:
c@15#3,SET:
0: [15, 16)
e#inf,SEPARATOR:
d@25#4,SET:
0: [25, 26)
e#inf,SEPARATOR:
d@25#4,SET:
0: [25, 26)
f#inf,SEPARATOR:
e@3#5,SET:
0: [3, 4)
f#inf,SEPARATOR:
e@3#5,SET:
0: [3, 4)
g#inf,SEPARATOR:
0: [5, 6)
Expand Down Expand Up @@ -353,23 +353,30 @@ collectors

block-props
----
d#inf,SEPARATOR:
c@15#3,SET:
0: [1, 16)
b#inf,SEPARATOR:
a@1#1,SET:
0: [1, 2)
c#inf,SEPARATOR:
b@10#2,SET:
0: [10, 11)
d#inf,SEPARATOR:
c@15#3,SET:
0: [15, 16)
g#inf,SEPARATOR:
0: [3, 26)
e#inf,SEPARATOR:
d@25#4,SET:
0: [25, 26)
f#inf,SEPARATOR:
e@3#5,SET:
0: [3, 4)
g#inf,SEPARATOR:
0: [5, 6)

iter upper=f point-key-filter=(suffix-point-keys-only,1,2)
first
next-prefix
----
<a@1:1>
.

# Regression test for a bug in boundary checking when skipping over irrelevant
# index blocks in a two-level indexed sstable.

Expand Down Expand Up @@ -397,21 +404,21 @@ seqnums: [1-5]

block-props
----
c#inf,SEPARATOR:
b@10#2,SET:
0: [1, 11)
b#inf,SEPARATOR:
a@1#1,SET:
0: [1, 2)
c#inf,SEPARATOR:
b@10#2,SET:
0: [10, 11)
e#inf,SEPARATOR:
d@25#4,SET:
0: [15, 26)
d#inf,SEPARATOR:
c@15#3,SET:
0: [15, 16)
e#inf,SEPARATOR:
d@25#4,SET:
0: [25, 26)
g#inf,SEPARATOR:
0: [3, 6)
f#inf,SEPARATOR:
e@3#5,SET:
0: [3, 4)
g#inf,SEPARATOR:
0: [5, 6)
Expand Down Expand Up @@ -572,8 +579,8 @@ seek-ge c@19 true
<b@10:2>
<b@10:2>
<c@15:3>
.
.
<c@15:3>
<c@15:3>

# Test another case of monotonically increasing bounds optimization, with a
# different index block structure. The first seek down below should filter keys,
Expand All @@ -593,9 +600,9 @@ seqnums: [1-5]

block-props
----
d#inf,SEPARATOR:
c@15#3,SET:
0: [1, 16)
d#inf,SEPARATOR:
c@15#3,SET:
0: [1, 16)
g#inf,SEPARATOR:
0: [3, 26)
Expand Down Expand Up @@ -632,9 +639,9 @@ seqnums: [1-5]

block-props
----
c#inf,SEPARATOR:
b@10#2,SET:
0: [1, 11)
e#inf,SEPARATOR:
d@25#4,SET:
0: [15, 26)
g#inf,SEPARATOR:
0: [3, 6)
Expand Down Expand Up @@ -667,9 +674,9 @@ collectors

block-props
----
b#inf,SEPARATOR:
a@5#1,SET:
0: [5, 6)
c#inf,SEPARATOR:
b@8#2,SET:
0: [8, 9)
d#inf,SEPARATOR:
0: [7, 8)
Expand Down
18 changes: 9 additions & 9 deletions sstable/testdata/block_properties_boundlimited
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ table-props

block-props
----
c#inf,SEPARATOR:
b@2#2,SET:
0: [2, 6)
e#inf,SEPARATOR:
d@3#4,SET:
0: [3, 10)
g#inf,SEPARATOR:
f@0#6,SET:
0: [0, 3)
i#inf,SEPARATOR:
0: [3, 9)
Expand Down Expand Up @@ -77,7 +77,7 @@ next
<c@9:3>
<d@3:4>
filter.Intersects([0, 3)) = (false, <nil>)
filter.KeyIsWithinUpperBound(g) = true
filter.KeyIsWithinUpperBound(f@0) = true
filter.Intersects([3, 9)) = (true, <nil>)
<g@8:7>
<h@3:8>
Expand All @@ -104,7 +104,7 @@ next
<c@9:3>
<d@3:4>
filter.Intersects([0, 3)) = (false, <nil>)
filter.KeyIsWithinUpperBound(g) = false
filter.KeyIsWithinUpperBound(f@0) = false
<e@2:5>
<f@0:6>
filter.Intersects([3, 9)) = (true, <nil>)
Expand Down Expand Up @@ -148,9 +148,9 @@ next
next
----
filter.Intersects([2, 6)) = (false, <nil>)
filter.KeyIsWithinUpperBound(c) = true
filter.KeyIsWithinUpperBound(b@2) = true
filter.Intersects([3, 10)) = (false, <nil>)
filter.KeyIsWithinUpperBound(e) = true
filter.KeyIsWithinUpperBound(d@3) = true
filter.Intersects([0, 3)) = (true, <nil>)
<e@2:5>
<f@0:6>
Expand All @@ -174,9 +174,9 @@ prev
prev
----
filter.Intersects([3, 9)) = (false, <nil>)
filter.KeyIsWithinLowerBound(g) = true
filter.KeyIsWithinLowerBound(f@0) = true
filter.Intersects([0, 3)) = (false, <nil>)
filter.KeyIsWithinLowerBound(e) = true
filter.KeyIsWithinLowerBound(d@3) = true
filter.Intersects([3, 10)) = (true, <nil>)
<d@3:4>
<c@9:3>
Expand Down

0 comments on commit 9f97b7b

Please sign in to comment.