Skip to content

Fix #196: honour minChildren when deleting from non-leaf nodes - #288

Open
pangwangshu wants to merge 2 commits into
davidmoten:masterfrom
pangwangshu:wapang/issue196
Open

Fix #196: honour minChildren when deleting from non-leaf nodes#288
pangwangshu wants to merge 2 commits into
davidmoten:masterfrom
pangwangshu:wapang/issue196

Conversation

@pangwangshu

Copy link
Copy Markdown

Summary

  • NonLeafHelper.delete previously only dissolved a non-leaf node when it became completely empty, so a node could survive deletion with fewer than minChildren children — violating the R-tree's structural invariant (Honour minChildren with delete operation #196).
  • The fix mirrors the existing LeafHelper.delete behavior: when a non-leaf's remaining children drop below minChildren, the node is dissolved and all entries in its subtree (leaf and non-leaf descendants alike) are collected and bubbled up for re-insertion higher in the tree.
  • Added getEntries/addEntries helpers to recursively collect entries from a node's children during dissolution.

Test plan

  • Added testDeleteIssue196 to RTreeTest, which builds a multi-level tree (maxChildren=3, minChildren=2), deletes entries one at a time, and after each deletion walks the tree verifying every non-root non-leaf node still has at least minChildren children.
  • Verified this test fails against the pre-fix code (non-leaf node has 1 children, less than minChildren=2) and passes with the fix.
  • Full suite: mvn test — 312 tests, 0 failures, 0 errors.

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