feat(bkd): record per-child AABB on internal nodes and leaf blocks#308
Merged
mosuka merged 1 commit intofeat/bkd-3d-geofrom Apr 26, 2026
Merged
feat(bkd): record per-child AABB on internal nodes and leaf blocks#308mosuka merged 1 commit intofeat/bkd-3d-geofrom
mosuka merged 1 commit intofeat/bkd-3d-geofrom
Conversation
Bump the BKD on-disk format to version 2 so every internal index node carries left_min/left_max/right_min/right_max and every leaf block carries leaf_min/leaf_max for all `num_dims` axes. The writer threads a `SubtreeInfo` up the recursion: leaves contribute their scanned AABB, internal nodes union their children's. The new metadata is materialized in both the leaf bytes and the index section, and `node_size` is now a helper that knows the dimensionality-dependent size (28 + 32 * num_dims bytes). Reader changes are minimal in this PR: BKDReader::open rejects any version != 2 (no V1 dual-support since laurus is pre-release), and visit_node / visit_leaf_block consume the new AABB bytes without yet using them for pruning. Inside/Outside/Crosses pruning lands in #292 when IntersectVisitor is introduced. Tests cover a 3D multi-block round-trip, a 2D single-leaf round-trip, and explicit rejection of a hand-crafted V1 header. Refs #289 Closes #291
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
left_min/left_max/right_min/right_max, and every leaf block storesleaf_min/leaf_max, for allnum_dimsaxes.SubtreeInfovalue up the recursion — leaves contribute their scanned AABB, internal nodes union their children's — and back-patches the AABBs onto eachIndexNodeslot.node_sizeis now a helper that knows the dimensionality-dependent size (28 + 32 * num_dimsbytes), used in both the root-offset calculation and the index serialization loop.BKDReader::openrejects anyversion != 2(no V1 dual-support, since laurus is pre-release), andvisit_node/visit_leaf_blockconsume the new AABB bytes so the on-disk offsets stay aligned.Why
Per the parent issue #289, recording AABBs on every node is the prerequisite for the Inside/Outside/Crosses pruning that #292 will introduce via
IntersectVisitor. Without per-node AABBs, 3D distance / sphere queries would degenerate to per-leaf full scans.Out of scope
range_searchon top ofIntersectVisitor, where the AABBs become load-bearing.Test plan
cargo test -p laurus— 704 lib tests + all integration tests pass (was 701; +3 new BKD tests).cargo clippy -p laurus --tests -- -D warnings— no warnings.cargo fmt --check— pass.Refs #289
Closes #291