Skip to content

Commit

Permalink
colblk: add some minor comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RaduBerinde committed Aug 21, 2024
1 parent d4348d0 commit 94561af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions sstable/colblk/cockroach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ type cockroachKeySeeker struct {
sharedPrefix []byte
}

var _ KeySeeker = (*cockroachKeySeeker)(nil)

// Init is part of the KeySeeker interface.
func (ks *cockroachKeySeeker) Init(r *DataBlockReader) error {
ks.reader = r
ks.prefixes = r.r.PrefixBytes(cockroachColPrefix)
Expand All @@ -178,6 +181,7 @@ func (ks *cockroachKeySeeker) Init(r *DataBlockReader) error {
return nil
}

// SeekGE is part of the KeySeeker interface.
func (ks *cockroachKeySeeker) SeekGE(key []byte, currRow int, dir int8) (row int) {
// TODO(jackson): Inline crdbtest.Split.
si := crdbtest.Split(key)
Expand Down Expand Up @@ -258,6 +262,7 @@ func (ks *cockroachKeySeeker) seekGEOnSuffix(index int, seekSuffix []byte) (row
return l
}

// MaterializeUserKey is part of the KeySeeker interface.
func (ks *cockroachKeySeeker) MaterializeUserKey(ki *PrefixBytesIter, prevRow, row int) []byte {
if prevRow+1 == row && prevRow >= 0 {
ks.prefixes.SetNext(ki)
Expand Down Expand Up @@ -286,6 +291,7 @@ func (ks *cockroachKeySeeker) MaterializeUserKey(ki *PrefixBytesIter, prevRow, r
return unsafe.Slice((*byte)(ki.ptr), ki.len+13)
}

// Release is part of the KeySeeker interface.
func (ks *cockroachKeySeeker) Release() {
*ks = cockroachKeySeeker{}
cockroachKeySeekerPool.Put(ks)
Expand Down
9 changes: 6 additions & 3 deletions sstable/colblk/data_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ type KeySeeker interface {
// may be set in practice.
SeekGE(key []byte, boundRow int, searchDir int8) (row int)
// MaterializeUserKey materializes the user key of the specified row,
// returning a slice of the materialized user key. The caller may use the
// provided keyIter and its buffer to avoid allocations and reduce work. The
// prevRow parameter is the row MaterializeUserKey was last invoked with.
// returning a slice of the materialized user key.
//
// The provided keyIter must have a buffer large enough to hold the key.
//
// The prevRow parameter is the row MaterializeUserKey was last invoked with.
// Implementations may take advantage of that knowledge to reduce work.
MaterializeUserKey(keyIter *PrefixBytesIter, prevRow, row int) []byte
// Release releases the KeySeeker. It's called when the seeker is no longer
Expand Down Expand Up @@ -317,6 +319,7 @@ func (ks *defaultKeySeeker) seekGEOnSuffix(index int, suffix []byte) (row int) {
return l
}

// MaterializeUserKey is part of the colblk.KeySeeker interface.
func (ks *defaultKeySeeker) MaterializeUserKey(keyIter *PrefixBytesIter, prevRow, row int) []byte {
if row == prevRow+1 && prevRow >= 0 {
ks.prefixes.SetNext(keyIter)
Expand Down

0 comments on commit 94561af

Please sign in to comment.