kvstore: iter_mut and for tables#265
Draft
nrc wants to merge 9 commits into
Draft
Conversation
Signed-off-by: Nick Cameron <[email protected]>
Signed-off-by: Nick Cameron <[email protected]>
…re efficient Signed-off-by: Nick Cameron <[email protected]>
Signed-off-by: Nick Cameron <[email protected]>
Signed-off-by: Nick Cameron <[email protected]>
…acro Signed-off-by: Nick Cameron <[email protected]>
Signed-off-by: Nick Cameron <[email protected]>
Signed-off-by: Nick Cameron <[email protected]>
Signed-off-by: Nick Cameron <[email protected]>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 PR replace the old
for_each_mutAPI with mutable iterator API (slightly different for different kinds of tables/accesses). The main difficulty here (as well as some interesting lifetime/borrow checker issues) is that after mutation we have to rebuild indexes. That requires some tracking. I've opted to track individual keys since that will be more efficient if a small minority of values are mutated (which might be the case for indexes in particular). However, if the common case is that a whole table is modified then rebuilding the whole index might be more efficient. The other interesting thing is that for the raw API, we need to do the implicit commit somewhere. I explored having this in the dtor of an iterator, but this ended up needing some complex self-referential stuff, so there is awith_iter_mutfunction rather thaniter_mut. If we really need the latter, we can probably do it, but it will require some unsafe code or pinning or something.Based on #263
Closes #217
AI decl: used Claude to generate tests and for implementing mutation tracking in TableIteratorMut (following similar code for IndexedIteratorMut). Code has been reviewed and refactored.