Uh oh!
There was an error while loading. Please reload this page.
Implement append for b-trees. - #32466
Conversation
rust-highfive
commented
Mar 24, 2016
(rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Is it possible to use this instead (i.e. without explicitly getting a reference to the fields)?
match(self.left_cur,self.right_cur){(Some((ref left_key, _)),Some((ref right_key, _))) => {
...EDIT: Never mind, I expect not.
alexcrichton
commented
Mar 24, 2016
r? @apasel422 |
There was a problem hiding this comment.
This unreachable branch seems a bit ugly to me. It would be better if cur_node just explicitly stored a Leaf node. The loop for descending to a leaf node would just need to use a separate variable for its internal state.
gereeter
commented
Mar 26, 2016
This looks excellent on the correctness and algorithmic fronts. The code could use some mostly cosmetic restructuring and possibly some optimization (though that could wait to a later PR), but otherwise everything seems good to me. Thank you, @jooert! |
apasel422
commented
Mar 26, 2016
@alexcrichton Does this need to be gated? |
alexcrichton
commented
Mar 27, 2016
Ah yeah let's add all new methods as |
jooert
commented
Apr 1, 2016
Thanks for all your comments! I just pushed a new commit that should fix all of the issues mentioned. I'm not satisifed with the |
apasel422
commented
Apr 1, 2016
This looks good to me, pending a final review by @gereeter. |
There was a problem hiding this comment.
This return is the same, regardless of whether is_left is true or not, so it can be moved out of the if statement.
apasel422
commented
Apr 17, 2016
@jooert What's the status of this? |
bors
commented
Apr 17, 2016
☔ The latest upstream changes (presumably #33049) made this pull request unmergeable. Please resolve the merge conflicts. |
jooert
commented
Apr 19, 2016
Sorry for the long delay, I resolved the merge conflicts and fixed the remaining issues. |
I have finally found time to revive #26227, this time only with an
appendimplementation.The algorithm implemented here is linear in the size of the two b-trees. It firsts creates
a
MergeIterfrom the two b-trees and then builds a new b-tree by pushingkey-value pairs from the
MergeIterinto nodes at the right heights.Three functions for stealing have been added to the implementation of
Handleaswell as a getter for the height of a
NodeRef.The docs have been updated with performance information about
BTreeMap::appendandthe remark about B has been removed now that it is the same for all instances of
BTreeMap.cc @gereeter@gankro@apasel422