Skip to content

BTree: add drain methods - #81075

Closed
ssomers wants to merge 2 commits into
rust-lang:masterfrom
ssomers:btree_drain
Closed

BTree: add drain methods#81075
ssomers wants to merge 2 commits into
rust-lang:masterfrom
ssomers:btree_drain

Conversation

@ssomers

@ssomersssomers commented Jan 16, 2021

Copy link
Copy Markdown
Contributor

Implements #81074.
Builds on #93989.

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 16, 2021
@Mark-Simulacrum

Copy link
Copy Markdown
Member

Is there a chance we can split this up into more commits? Reviewing a diff in a couple thousand lines is going to be quite challenging. It would be good to document any design decisions or otherwise guide my review, too.

@Mark-SimulacrumMark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 16, 2021
@ssomers

Copy link
Copy Markdown
ContributorAuthor

I can split off a few refactorings of existing functions, to open up for new use, but they seemed a bit pointless on their own (apart from one thing that I actually postponed).

@Mark-Simulacrum

Copy link
Copy Markdown
Member

I don't really know what you postponed, but I will likely not be able to effectively review this diff without at least some guidance as to where to start or the overall vision in adding these methods.

@ssomers

ssomers commented Jan 16, 2021

Copy link
Copy Markdown
ContributorAuthor

The item I postponed is that steal_X functions (apart from their return value) are basically a hand-written optimization of the generic bulk_steal_X functions for count=1 (in reality, it went the other way around of course). It comes up here because one of the functions needed for drain is identical to handle_shrunk_node_recursively apart from that alleged optimization.

@ssomers

Copy link
Copy Markdown
ContributorAuthor

The overall vision in adding these methods is to not copy any existing functionality, but break it up in order to reuse parts. I'll feed those refactings in a few separate PRs now.

@bors

bors commented Jan 17, 2021

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #81083) made this pull request unmergeable. Please resolve the merge conflicts.

@bors

bors commented Jan 19, 2021

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #81169) made this pull request unmergeable. Please resolve the merge conflicts.

@bors

bors commented Jan 29, 2021

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #81073) made this pull request unmergeable. Please resolve the merge conflicts.

@bors

bors commented Feb 9, 2021

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #81361) made this pull request unmergeable. Please resolve the merge conflicts.

@bors

bors commented Feb 13, 2021

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #81494) made this pull request unmergeable. Please resolve the merge conflicts.

@bors

bors commented Feb 15, 2021

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #82103) made this pull request unmergeable. Please resolve the merge conflicts.

@bors

bors commented Feb 21, 2021

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #82359) made this pull request unmergeable. Please resolve the merge conflicts.

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 22, 2021
…rk-Simulacrum
BTreeMap: gather and decompose reusable tree fixing functions
This is kind of pushing it as a standalone refactor, probably only useful for rust-lang#81075 (or similar).
r? `@Mark-Simulacrum`
@bors

bors commented Feb 22, 2021

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #81362) made this pull request unmergeable. Please resolve the merge conflicts.

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 1, 2021
…rk-Simulacrum
BTreeMap: split up range_search into two stages
`range_search` expects the caller to pass the same root twice and starts searching a node for both bounds of a range. It's not very clear that in the early iterations, it searches twice in the same node. This PR splits that search up in an initial `find_leaf_edges_spanning_range` that postpones aliasing until the last second, and a second phase for continuing the search for the range in the each subtree independently (`find_lower_bound_edge` & `find_upper_bound_edge`), which greatly helps for use in rust-lang#81075. It also moves those functions over to the search module.
r? `@Mark-Simulacrum`
@ssomers

Copy link
Copy Markdown
ContributorAuthor

@rustbot label: -S-waiting-on-author +S-waiting-on-review

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 1, 2021
@rustbotrustbot removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 16, 2021
@ssomersssomers changed the title BTree: add drain and split_off_range methodsBTree: add remove_range and split_off_range methodsJan 4, 2022
@ssomers

ssomers commented Jan 4, 2022

Copy link
Copy Markdown
ContributorAuthor

To stir up things, yanked the drain interface. I added remove_range instead just to have something that drops key-value pairs. Which only now makes me realize the drop_panic_leak test case for split_off_range is stupid: nothing is dropped before the split is finished.

PS also formatted code with stable instead of nightly and did not test tidy like a good boy should

@rust-log-analyzer

This comment has been minimized.

@ssomersssomers changed the title BTree: add remove_range and split_off_range methodsBTree: add split_off_range methodsJan 7, 2022
@JohnCSimonJohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 6, 2022
@ssomersssomers changed the title BTree: add split_off_range methodsBTree: add drain methodsFeb 14, 2022
@bors

bors commented Feb 25, 2022

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #94350) made this pull request unmergeable. Please resolve the merge conflicts.

@JohnCSimonJohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 20, 2022
@Dylan-DPC

Copy link
Copy Markdown
Member

r? @yaahc

@rust-highfiverust-highfive assigned yaahc and unassigned m-ou-seMar 26, 2022
@JohnCSimonJohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 24, 2022
@yaahc

Copy link
Copy Markdown
Member

r? rust-lang/libs-api

@joshtriplett

Copy link
Copy Markdown
Member

r? rust-lang/libs-api

@bors

bors commented Jun 16, 2022

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #98103) made this pull request unmergeable. Please resolve the merge conflicts.

@ssomersssomers closed this Jun 18, 2022
@kekeimiku

This comment was marked as spam.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-reviewStatus: Awaiting review from the assignee but also interested parties.T-libs-api[DEPRECATED; DO NOT USE]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

18 participants

@ssomers@Mark-Simulacrum@bors@crlf0710@jeffparsons@JohnCSimon@apiraino@rust-log-analyzer@Dylan-DPC@yaahc@joshtriplett@kekeimiku@the8472@m-ou-se@dtolnay@KodrAus@rust-highfive@rustbot