bugfix: 'node_16<T>::grow()' partial_key index offset inconsistent #20
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.
This issue was discovered when using the iterator to traverse and output text.
The functions in
node_48.hpp
will all add an offset of128
when indexing usingpartial_key
, for example:However,
node_16<T>::grow()
ignores this point and directly uses thepartial_key
stored inkeys_
as the index, causing an offset in indexing when the node grows:For example, consider a
node_16
instance:When querying
a
innode_48
,find_child()
will indexindexes_[128 + 97]
, but the value there isEMPTY
. Moreover, this error will also affect the correctness of functions likenode_48<T>::next_partial_key
, causing iterators to obtain incorrect values ofkeys_
, and so on.The iterator in the figure obtained an incorrect value of -55 through
node_48<T>::next_partial_key
. This node was grown from anode_16
, where the original key stored at that position wasI
(73).node_48<T>::next_partial_key(-128)
start from-128+128
with an offset of73
to getI
, butpartial_key
remains-128+73=-55
.