Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OrdMap removal/range logic #154

Merged
merged 3 commits into from Apr 29, 2022
Merged

Fix OrdMap removal/range logic #154

merged 3 commits into from Apr 29, 2022

Conversation

arthurprs
Copy link
Contributor

@arthurprs arthurprs commented Oct 16, 2020

Pulling predecessor/successor must be ruled out before merge can be done.

btree::Node::path_{next/prev} weren't considering going up to find next/prev.

Might fix #124
Fix #152
Fix #143

Pulling predecessor/successor must be ruled out before merge can be done
@arthurprs arthurprs changed the title Fix removal logic Fix removal/range logic Oct 16, 2020
Copy link

@danielhenrymantilla danielhenrymantilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!!

src/ord/map.rs Outdated
#[test]
fn range_iter_big() {
use std::ops::Bound::Included;
let n = 25_000; // enough for a sizeable 3 level tree

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you have this number depend on crate::nodes::btree::NODE_SIZE?

Something like NODE_SIZE * NODE_SIZE * 6?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I hesitated because it was not public. But it can be solved with a pub(crate)

src/nodes/btree.rs Outdated Show resolved Hide resolved
@arthurprs
Copy link
Contributor Author

@bodil friendly ping. The crates.io version of OrdMap is significantly impaired without these fixes.

It must pull the highest or lowest item in the subtree and
not just from the next level
@arthurprs arthurprs changed the title Fix removal/range logic Fix OrdMap removal/range logic Feb 1, 2021
}
}
path
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix seems to be needed in lookup_prev and lookup_next as well. Currently, OrdMap::get_prev and OrdMap::get_next may return None when they are not supposed to.

Copy link

@xu-cheng xu-cheng Feb 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem I described above can be demonstrated using a test case similar to the one in the below:

assert_eq!(omap.range(..=i).next_back(), omap.get_prev(&i));
assert_eq!(omap.range(i..).next(), omap.get_next(&i));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Good observation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arthurprs Any chance to update this PR to address it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not right now.

The author seemingly abandoned this project so eventually I switched to https://github.com/orium/rpds instead. It has an arguably worse API but at least it's correct/maintained.

@xu-cheng
Copy link

xu-cheng commented Feb 7, 2021

@bodil Any chance to review this PR and possible publish a new release of im crate? Thanks

@TonalidadeHidrica
Copy link

I also hope that this PR will be merged. I highly rely on this im crate as a part of druid. This issue makes it "just doesn't work." @bodil

@jneem
Copy link

jneem commented Aug 8, 2021

Ah, I should have taken a closer look at this PR yesterday... I redid a chunk of it in my fork, but this PR is mostly nicer, so I'll cherry-pick it and add the missing bits in lookup_{next,prev}.

@bodil bodil merged commit e600841 into bodil:master Apr 29, 2022
@bodil
Copy link
Owner

bodil commented Apr 29, 2022

Merged. Sorry it took a while. I'll tag a bugfix release shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants