Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ART: Fix a few issues around lower bound / erase (#563)
* ART: Fix a few issues around lower bound / erase 1. Leaf keys were written to the wrong location. 2. In `art_node_iterator_lower_bound`, we did not check if the key chunk for the lower bound child was greater than the key chunk we searched for. 3. In `art_iterator_erase` there were a few issues that would lead to an incorrect location. I've somewhat sidestepped the most tricky bit by doing a lower bound search from the root instead. Added tests for 1 and 2. * Improve art_printf * Makes the representation more compact * Uses 2-wide hex representation for key chunks Before: ``` { type: Node4 prefix_size: 2 prefix: 3030 key: 30 { type: Node4 prefix_size: 2 prefix: 3030 key: 31 { type: Leaf key: 303030303031 } key: 32 { type: Leaf key: 303030303032 } key: 33 { type: Leaf key: 303030303033 } key: 34 { type: Leaf key: 303030303034 } } key: 31 { type: Leaf key: 303031303035 } } ``` After: ``` { type: Node4 prefix_size: 2 prefix: 3030 key: 30 { type: Node4 prefix_size: 2 prefix: 3030 key: 31 { type: Leaf, key: 303030303031 } key: 32 { type: Leaf, key: 303030303032 } key: 33 { type: Leaf, key: 303030303033 } key: 34 { type: Leaf, key: 303030303034 } } key: 31 { type: Leaf, key: 303031303035 } } ``` * ART: Fix lower bound search within a node's children Previously when doing a lower bound search on a node where the prefix was equal and there was no child with an equal key chunk, we would move to the first child. The correct thing to do is to move to the first _larger_ child. * ART: Fix lower bound for equal prefix but smaller key Previously we would assume a leaf had a key equal to the search key when the parent prefix was equal, however this is not always the case.
- Loading branch information