Skip to content

refactor(bkd): flatten BKDWriter::write to (points, doc_ids) buffers#307

Merged
mosuka merged 1 commit intofeat/bkd-3d-geofrom
feat/bkd-flatten-io
Apr 26, 2026
Merged

refactor(bkd): flatten BKDWriter::write to (points, doc_ids) buffers#307
mosuka merged 1 commit intofeat/bkd-3d-geofrom
feat/bkd-flatten-io

Conversation

@mosuka
Copy link
Copy Markdown
Owner

@mosuka mosuka commented Apr 26, 2026

Summary

  • Replace the nested Vec<(Vec<f64>, u64)> parameter on BKDWriter::write with flat row-major points: &[f64] and doc_ids: &[u64] slices, plus a size validation that rejects mismatched buffers up-front.
  • Internally sort a Vec<u32> index permutation rather than the data itself, eliminating the per-point inner-Vec allocation that previously scaled with point count.
  • Update the lexical index writer's BKD accumulator to feed flat buffers directly via 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.
  • New unit tests cover: empty input, dimension/size mismatch validation, and a 1D multi-block case that exercises the recursive build path with a non-default leaf block size.

Refs #289
Closes #290

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
@mosuka mosuka merged commit 76790d8 into feat/bkd-3d-geo Apr 26, 2026
6 checks passed
@mosuka mosuka deleted the feat/bkd-flatten-io branch April 26, 2026 12:15
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.

1 participant