-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SeekLowerBound where tree contains keys that are prefixes of each…
… other (#39) * Fix SeekLowerBound where tree contains keys that are prefixes of each other. This seems like a trivial case to miss howevere it stemmed from some confusion (on my part) about whether iradix was ever intended to support keys that were prefixes. It's a long story and I don't even recall exactly why I thought this was the case now given that every other operation on iradix supports this and most even include this case in their test examples. We even had it in the README example! But some combination of: - I was working at the time on a related radix tree that did have the assumption of null-terminated keys - hashicorp/go-memdb always null terminates even for simpler string indexes Anyway the fix is simple and the examples now pass. In addition the fuzz test (which explicitly used the null-termination trick to never trigger this assuming it was necessary in general) now passes without null terminating keys every time I've run it. * Clean up other tests that copied the same assumptions and verify they work too. * Prevent panics in SeekLowerBound and SeekReverseLowerBound; Also adds support for SeekReverseLowerBound to work when keys are prefixes of each other. * Clarify some comments and remove unreachable code * Improve fuzz test coverage This also uncovered a couple of bugs: - Fuzz tests would break if empty strings are involved (which are valid) due to erroneously "de-duplicating" them - A panic in SeekLowerBound that only occured in specific tree configurations (fixed) * Fix reverse fuzz test and an example it caught that was a bug * Remove pointless assignments to i.node * Comment typos and test fixture refactor per PR comments * Clean up comment and ineffectual assignment
- Loading branch information
Showing
4 changed files
with
457 additions
and
177 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
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
Oops, something went wrong.