-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
node48 children can have holes (#565)
* fix(art): node48 children can have holes This matches the [java implementation][1] in Roaring. When removing from a node48, the child is simply set to NULL. For example, if the state is (ignoring that it actually needs at least 17 items to not be a node16): ``` keys: {[0]=0, [1]=1} children: {[0]=child1, [1]=child2} count: 2 ``` After removing key 0, the state will be: ``` keys: {[0]=48, [1]=1} children: {[0]=NULL, [1]=child2} count: 1 ``` If we then try to insert at key 3, the item at `children[count]` is already in use: we have to find and reuse the 0th child. This also has some fixes for `art_printf`: * When printing keys, don't cast to char, if char is signed, when integer promoted, a 0xFF char will be printed as `FFFFFFFF` * Correctly output keys for node48 * Include child index for node48 * Correct child output for node48 [1]: https://github.com/RoaringBitmap/RoaringBitmap/blob/1ed0242d1f298cf93d3666a754eb4bb4c5180c4c/RoaringBitmap/src/main/java/org/roaringbitmap/art/Node48.java#L181-L187 * Keep track of used children for node48 in a bitset Rather than searching for an unset child, we can just use the first set bit in a bitset of available children. Also, when freeing the node, rather than iterating through all 256 possible keys, just iterate through all set children directly. This slightly increases the size of the node48 struct, but it means: * We don't have to initialize all children to null at init time * We don't have to loop looking for a child (sometimes) on insert * Move test for node48 into `art_unit`
- Loading branch information
Showing
3 changed files
with
82 additions
and
23 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
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