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

Closed
wants to merge 2 commits into 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

@jbowens jbowens force-pushed the colblk-indexprefixsuffix branch from 0fda49a to cfaf7fd Compare October 18, 2024 15:43
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

@jbowens jbowens force-pushed the colblk-indexprefixsuffix branch from cfaf7fd to 6e68b61 Compare October 18, 2024 15:59
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

@jbowens jbowens force-pushed the colblk-indexprefixsuffix branch from 6e68b61 to d4aa43e Compare October 20, 2024 15:16
@jbowens jbowens force-pushed the colblk-indexprefixsuffix branch from d4aa43e to e7c95e2 Compare October 20, 2024 15:22
@jbowens jbowens closed this Nov 27, 2024
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