Skip to content

WIP for using page_start_offsets instead of new structure - #2

Open
alamb wants to merge 3 commits into
sdf-jkl:bitmask-skip-pagefrom
alamb:alamb/hack_on_chunks
Open

WIP for using page_start_offsets instead of new structure#2
alamb wants to merge 3 commits into
sdf-jkl:bitmask-skip-pagefrom
alamb:alamb/hack_on_chunks

Conversation

@alamb

@alamb alamb commented Jan 26, 2026

Copy link
Copy Markdown

This is a WIP targeting @sdf-jkl 's PR

The idea is that we already had the page offsets so we can reuse them when calculating mask offsets

It doesn't yet compile -- I need to update the tests and skipping logic but the basic idea I think is solid

@alamb alamb left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

My plan here is to get this PR to compile, then switch to focus on testing, perhaps as a separate PR to main

let Some(mask_chunk) =
mask_cursor.next_mask_chunk(batch_size, page_boundaries.as_deref())
else {
let Some(mask_chunk) = mask_cursor.next_mask_chunk(batch_size) else {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The idea is that the cursor how has all the information it needs to make the next decision

/// Optional page start offsets for each requested column.
///
/// See [`FetchRanges::page_start_offsets`] for more details
page_start_offsets: Option<Vec<Vec<u64>>>,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

instead of a new struct, I plumbed the offsets all the way through from where the data is requested

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

It seems like these page_start_offsets are byte, not row offsets so we can't really reuse them.

.with_offset_index_metadata(offset_index_metadata, &self.projection);

let plan = plan_builder.build();
let plan = plan_builder

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It also simplifies the logic here substantially

sdf-jkl pushed a commit that referenced this pull request Feb 3, 2026
# Which issue does this PR close?

small optimization

# Rationale for this change
key insight is the byte clone is cheap just a ref count compare to vec
clone is a alloc + memcopy.

before
```
let mut result = Vec::new();          // alloc #1
result.extend_from_slice(prefix);
result.extend_from_slice(suffix);

let data = Bytes::from(result.clone()); // alloc #2 + memcpy
item.set_from_bytes(data);
self.previous_value = result;          // keep Vec
```

after
```
let mut result = Vec::with_capacity(prefix_len + suffix.len()); // alloc #1
result.extend_from_slice(&self.previous_value[..prefix_len]);
result.extend_from_slice(suffix);

let data = Bytes::from(result);       // no alloc, takes Vec buffer
item.set_from_bytes(data.clone());    // cheap refcount bump
self.previous_value = data;           // move, no alloc
```

# What changes are included in this PR?
previous_value type changed to Bytes
preallocate result vec capacity.

# Are these changes tested?

the existing test should pass

# Are there any user-facing changes?

no
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.

2 participants