Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
An underflow in some node has occured and we want to merge node L into node R. L is left sibling to R and vice versa. It is done like this: Phase 1 (Move data) 1. Left sibling of L is LL. Set right sibling of LL to be R and left sibling of R to be LL. Effectively removing L from the leaf chain. 2. Set new generation of L to be R. 3. Add L to freelist. 4. Copy all keys and values from L to R. 5. Update partent pointers to match changes, new pointer to both L and R. Phase 2 (Update splitter key in internal nodes) Parent of L and R (potentially same internal node) now both hold pointer to the same leaf, R. This is ok for now, because it just means we have to different paths to the same leaf. We do however want to remove one of those paths together with some key to not store more than what we need among the internal nodes. L and R are part of different subtrees, subL and subR. (Note that it is possible that subL and subR only contain L och R respectively.) Because L and R are sibling, we know that subL and subR are splitted by exactly one key, the 'splitter', which is located in the closest common parent of subL and subR. subL is located just to the left of splitter and subR just to the right. splitter should be replaced by the key that previously would guide a search towards L. This key is the rightmost key in subL. If no such key can be found, if subL only contains L or if none of the internal nodes in subL has any keys, then splitter is removed together with subL. So: 6. Bubble up rightmost key from subL. 7. Every internal node on the bubble path that contains zero keys can be added to freelist. 8. Replace splitter with bubble key or remove if no bubble key could be found. 9. If root end up with zero keys, shrink the tree.
- Loading branch information
Showing
9 changed files
with
392 additions
and
60 deletions.
There are no files selected for viewing
This file contains 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
388 changes: 345 additions & 43 deletions
388
community/index/src/main/java/org/neo4j/index/internal/gbptree/InternalTreeLogic.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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