Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sstable: add range keys to sstable.Layout #1410

Merged
merged 1 commit into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sstable/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ type Properties struct {
// Total raw key size.
RawKeySize uint64 `prop:"rocksdb.raw.key.size"`
// Total raw rangekey key size.
RawRangeKeyKeySize uint64 `prop:"pebble.raw.rangekey.key.size"`
RawRangeKeyKeySize uint64 `prop:"pebble.raw.range-key.key.size"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two changes are purely cosmetic, and make the range key property names consistent (i.e. hyphenated).

// Total raw rangekey value size.
RawRangeKeyValueSize uint64 `prop:"pebble.raw.rangekey.value.size"`
RawRangeKeyValueSize uint64 `prop:"pebble.raw.range-key.value.size"`
// Total raw value size.
RawValueSize uint64 `prop:"rocksdb.raw.value.size"`
// Size of the top-level index if kTwoLevelIndexSearch is used.
Expand Down
9 changes: 7 additions & 2 deletions sstable/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2414,6 +2414,7 @@ func (r *Reader) Layout() (*Layout, error) {
Data: make([]BlockHandle, 0, r.Properties.NumDataBlocks),
Filter: r.filterBH,
RangeDel: r.rangeDelBH,
RangeKey: r.rangeKeyBH,
Properties: r.propertiesBH,
MetaIndex: r.metaIndexBH,
Footer: r.footerBH,
Expand Down Expand Up @@ -2478,7 +2479,7 @@ func (r *Reader) ValidateBlockChecksums() error {
var blocks []BlockHandle
blocks = append(blocks, l.Data...)
blocks = append(blocks, l.Index...)
blocks = append(blocks, l.TopIndex, l.Filter, l.RangeDel, l.Properties, l.MetaIndex)
blocks = append(blocks, l.TopIndex, l.Filter, l.RangeDel, l.RangeKey, l.Properties, l.MetaIndex)

// Sorting by offset ensures we are performing a sequential scan of the
// file.
Expand Down Expand Up @@ -2719,6 +2720,7 @@ type Layout struct {
TopIndex BlockHandle
Filter BlockHandle
RangeDel BlockHandle
RangeKey BlockHandle
Properties BlockHandle
MetaIndex BlockHandle
Footer BlockHandle
Expand Down Expand Up @@ -2750,6 +2752,9 @@ func (l *Layout) Describe(
if l.RangeDel.Length != 0 {
blocks = append(blocks, block{l.RangeDel, "range-del"})
}
if l.RangeKey.Length != 0 {
blocks = append(blocks, block{l.RangeKey, "range-key"})
}
if l.Properties.Length != 0 {
blocks = append(blocks, block{l.Properties, "properties"})
}
Expand Down Expand Up @@ -2861,7 +2866,7 @@ func (l *Layout) Describe(

var lastKey InternalKey
switch b.name {
case "data", "range-del":
case "data", "range-del", "range-key":
iter, _ := newBlockIter(r.Compare, h.Get())
for key, value := iter.First(); key != nil; key, value = iter.Next() {
ptr := unsafe.Pointer(uintptr(iter.ptr) + uintptr(iter.offset))
Expand Down
22 changes: 22 additions & 0 deletions sstable/testdata/writer
Original file line number Diff line number Diff line change
Expand Up @@ -361,3 +361,25 @@ layout
813 meta-index (33)
851 leveldb-footer (48)
899 EOF

# Range keys, if present, are shown in the layout.

build
a.RANGEKEYSET.3:b [(@t3=foo)]
b.RANGEKEYSET.2:c [(@t2=bar)]
c.RANGEKEYSET.1:d [(@t1=baz)]
----
point: [#0,0,#0,0]
rangedel: [#0,0,#0,0]
rangekey: [a#3,21,d#72057594037927935,21]
seqnums: [1,3]

layout
----
0 data (8)
13 index (21)
39 range-key (82)
126 properties (765)
896 meta-index (57)
958 footer (53)
1011 EOF