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

colblk: separate prefixes and suffixes in index blocks #4069

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jbowens
Copy link
Collaborator

@jbowens jbowens commented Oct 18, 2024

No description provided.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

Very cool! I know it's still a draft but posted some early comments.

Reviewable status: 0 of 22 files reviewed, 6 unresolved discussions (waiting on @jbowens)


sstable/colblk/index_block.go line 104 at r2 (raw file):

	// Decompose the separator into prefix and suffix.
	s := w.split(separator)
	commonPrefixLen := s

[nit] feels like a strange value to pass to the first one, shouldn't 0 also work? It doesn't look like we care about its value for the first key.


sstable/colblk/index_block.go line 119 at r2 (raw file):

// UnsafeSeparator returns the separator of the i'th entry. If r is the number
// of rows, it is required that r-2 <= i < r.

[nit] i=r-2 or i=r-1 is more clea


sstable/colblk/index_block.go line 121 at r2 (raw file):

// of rows, it is required that r-2 <= i < r.
func (w *IndexBlockWriter) UnsafeSeparator(i int) []byte {
	if i < w.rows-2 || i >= w.rows {

[nit] we already have this check in UnsafeGet


sstable/colblk/index_block.go line 382 at r2 (raw file):

				return i.row < i.n
			}
			i.row = i.d.bd.Rows()

i.row = n; return false


sstable/colblk/index_block.go line 411 at r2 (raw file):

	// Fall back to a slow scan forward.
	//
	// TODO(jackson): This can be improved by adding a PrefixBytes.NextUniqueKey

Maybe we should always include a prefixChanged bitmap inside the prefix bytes?


sstable/colblk/index_block.go line 416 at r2 (raw file):

	// with offset indexes, so it's deferred for now.
	for i.row++; i.row < i.d.bd.Rows(); i.row++ {
		if i.SeparatorGT(key, true /* orEqual */) {

We want to compare just the suffix, no? SeparatorGT checks the prefix again

Copy link
Collaborator Author

@jbowens jbowens left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 54 files reviewed, 6 unresolved discussions (waiting on @RaduBerinde)


sstable/colblk/index_block.go line 416 at r2 (raw file):

Previously, RaduBerinde wrote…

We want to compare just the suffix, no? SeparatorGT checks the prefix again

Unfortunately as long as we don't know when the prefix changes, we have to do a prefix comparison too

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 54 files reviewed, 6 unresolved discussions (waiting on @jbowens)


sstable/colblk/index_block.go line 416 at r2 (raw file):

Previously, jbowens (Jackson Owens) wrote…

Unfortunately as long as we don't know when the prefix changes, we have to do a prefix comparison too

Yeah, sorry, I meant to delete that comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants