refactor(bkd): flatten BKDWriter::write to (points, doc_ids) buffers#307
Merged
mosuka merged 1 commit intofeat/bkd-3d-geofrom Apr 26, 2026
Merged
refactor(bkd): flatten BKDWriter::write to (points, doc_ids) buffers#307mosuka merged 1 commit intofeat/bkd-3d-geofrom
mosuka merged 1 commit intofeat/bkd-3d-geofrom
Conversation
Replace the nested `Vec<(Vec<f64>, u64)>` parameter with flat row-major `points: &[f64]` and `doc_ids: &[u64]` slices, plus a size validation that rejects mismatched buffers up-front. Internally, the builder now sorts a `Vec<u32>` index permutation rather than the data itself, so the per-point inner-Vec allocation that scaled with point count is eliminated. The writer accumulator in the lexical index is updated to feed flat buffers directly via `extend_from_slice`, removing the intermediate `Vec<(Vec<f64>, u64)>` bucket. Tests cover the empty case, the dimension/size validation error, and a 1D multi-block case that exercises the recursive build path with a non-default leaf block size. Refs #289 Closes #290
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Vec<(Vec<f64>, u64)>parameter onBKDWriter::writewith flat row-majorpoints: &[f64]anddoc_ids: &[u64]slices, plus a size validation that rejects mismatched buffers up-front.Vec<u32>index permutation rather than the data itself, eliminating the per-point inner-Vecallocation that previously scaled with point count.extend_from_slice, removing the intermediate nested bucket.Why
Step 1 of #289. The flat I/O API is a prerequisite for the BKD core redesign (per-node AABB,
IntersectVisitor, etc.) — every later phase reads from / builds on this shape.Test plan
cargo test -p laurus— 701 lib tests + all integration tests pass (0 failures).cargo fmt --check— pass.cargo clippy -p laurus --tests -- -D warnings— no warnings.Refs #289
Closes #290