Fix #196: honour minChildren when deleting from non-leaf nodes - #288
Open
pangwangshu wants to merge 2 commits into
Open
Fix #196: honour minChildren when deleting from non-leaf nodes#288pangwangshu wants to merge 2 commits into
pangwangshu wants to merge 2 commits into
Conversation
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
NonLeafHelper.deletepreviously only dissolved a non-leaf node when it became completely empty, so a node could survive deletion with fewer thanminChildrenchildren — violating the R-tree's structural invariant (Honour minChildren with delete operation #196).LeafHelper.deletebehavior: when a non-leaf's remaining children drop belowminChildren, 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.getEntries/addEntrieshelpers to recursively collect entries from a node's children during dissolution.Test plan
testDeleteIssue196toRTreeTest, 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 leastminChildrenchildren.non-leaf node has 1 children, less than minChildren=2) and passes with the fix.mvn test— 312 tests, 0 failures, 0 errors.