-
Notifications
You must be signed in to change notification settings - Fork 3
Implementation of KVStore::remove #4
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
Open
vidyasilai
wants to merge
10
commits into
mathworks:main
Choose a base branch
from
vidyasilai:remove_impl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
47a4572
Initial commit
vidyasilai 47dc604
Added some more comments
vidyasilai 99d750f
Remove conan file changes
vidyasilai 969c140
Some bug fixes; new test case
vidyasilai ca5b89b
More bug fixes
vidyasilai 51a4e02
KVStoreScanner updates
vidyasilai b126c03
Subtree test config change
vidyasilai afa9940
First round of feedback
vidyasilai 8dbab04
Improvements to Subtree test
vidyasilai 969efc0
More feedback
vidyasilai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -435,15 +435,37 @@ Status KVStoreScanner::set_next_item() | |
| ScanLevel* scan_level = this->heap_.first(); | ||
|
|
||
| if (!this->next_item_) { | ||
| this->next_item_.emplace(scan_level->item(this->keys_only_)); | ||
| this->next_item_.emplace(scan_level->item()); | ||
|
|
||
| } else if (this->next_item_->key == scan_level->key) { | ||
| if (!this->keys_only_ && this->next_item_->needs_combine()) { | ||
| // If this->next_item_->key == scan_level->key, we need to search for a terminal value for | ||
| // the item, so combine it if necessary. | ||
| // | ||
| if (this->next_item_->needs_combine()) { | ||
| this->next_item_->value = combine(this->next_item_->value, scan_level->value()); | ||
| } | ||
|
|
||
| } else { | ||
| break; | ||
| // If the item stored in this->next_item_ does not have the same key as the first key in | ||
| // the current scan_level, we have reached a terminal value for this->next_item_. Now, | ||
| // we have to decide whether we want to keep this->next_item_ and break from the loop | ||
| // (returning the item to the function's caller) OR discard it, because the terminal value | ||
| // represents a deleted item. | ||
| // | ||
| if (this->next_item_->value == ValueView::deleted()) { | ||
| // The terminal value represents a deleted item, so discard it by setting this->next_item_ | ||
| // to None. Then, continue on to the next iteration of the loop, skipping the logic to | ||
| // advance the current scan_level. We do this because we now need to set the first key | ||
| // in the current scan_level to this->next_item_ to examine it next. | ||
| // | ||
| this->next_item_ = None; | ||
| if (this->needs_resume_) { | ||
| BATT_REQUIRE_OK(this->resume()); | ||
| } | ||
| continue; | ||
tonyastolfi marked this conversation as resolved.
Show resolved
Hide resolved
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here should be the if needs resume, resume. And we can keep the flag, just call resume once when going from key to different key. |
||
| } else { | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (scan_level->advance()) { | ||
|
|
@@ -567,66 +589,45 @@ Status KVStoreScanner::set_next_item() | |
|
|
||
| //==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - - | ||
| // | ||
| EditView KVStoreScanner::ScanLevel::item(bool key_only) const | ||
| EditView KVStoreScanner::ScanLevel::item() const | ||
| { | ||
| return batt::case_of( | ||
| this->state_impl, | ||
| [](NoneType) -> EditView { | ||
| BATT_PANIC() << "illegal state"; | ||
| BATT_UNREACHABLE(); | ||
| }, | ||
| [this, key_only](const MemTableScanState<ARTBase::Synchronized::kTrue>& state) -> EditView { | ||
| [this](const MemTableScanState<ARTBase::Synchronized::kTrue>& state) -> EditView { | ||
| MemTableEntry entry; | ||
| const bool found = state.mem_table_->hash_index().find_key(this->key, entry); | ||
| BATT_CHECK(found); | ||
|
|
||
| if (key_only) { | ||
| return EditView{entry.key_, ValueView{}}; | ||
| } | ||
| return EditView{entry.key_, entry.value_}; | ||
| }, | ||
| [this, key_only](const MemTableScanState<ARTBase::Synchronized::kFalse>& state) -> EditView { | ||
| [this](const MemTableScanState<ARTBase::Synchronized::kFalse>& state) -> EditView { | ||
| const MemTableEntry* entry = state.mem_table_->hash_index().unsynchronized_find_key(key); | ||
| BATT_CHECK_NOT_NULLPTR(entry); | ||
|
|
||
| if (key_only) { | ||
| return EditView{entry->key_, ValueView{}}; | ||
| } | ||
| return EditView{entry->key_, entry->value_}; | ||
| }, | ||
| [key_only](const MemTableValueScanState<ARTBase::Synchronized::kTrue>& state) -> EditView { | ||
| [](const MemTableValueScanState<ARTBase::Synchronized::kTrue>& state) -> EditView { | ||
| const MemTableValueEntry& entry = state.art_scanner_->get_value(); | ||
| if (key_only) { | ||
| return EditView{entry.key_view(), ValueView{}}; | ||
| } | ||
| return EditView{entry.key_view(), entry.value_view()}; | ||
| }, | ||
| [key_only](const MemTableValueScanState<ARTBase::Synchronized::kFalse>& state) -> EditView { | ||
| [](const MemTableValueScanState<ARTBase::Synchronized::kFalse>& state) -> EditView { | ||
| const MemTableValueEntry& entry = state.art_scanner_->get_value(); | ||
| if (key_only) { | ||
| return EditView{entry.key_view(), ValueView{}}; | ||
| } | ||
| return EditView{entry.key_view(), entry.value_view()}; | ||
| }, | ||
| [](const Slice<const EditView>& state) -> EditView { | ||
| return state.front(); | ||
| }, | ||
| [this, key_only](const TreeLevelScanState& state) -> EditView { | ||
| if (key_only) { | ||
| return EditView{this->key, ValueView{}}; | ||
| } | ||
| [this](const TreeLevelScanState& state) -> EditView { | ||
| return EditView{this->key, get_value(state.kv_slice.front())}; | ||
| }, | ||
| [this, key_only](const TreeLevelScanShardedState& state) -> EditView { | ||
| if (key_only) { | ||
| return EditView{this->key, ValueView{}}; | ||
| } | ||
| [this](const TreeLevelScanShardedState& state) -> EditView { | ||
| return EditView{this->key, state.kv_slice.front_value()}; | ||
| }, | ||
| [this, key_only](const ShardedLeafScanState& state) -> EditView { | ||
| if (key_only) { | ||
| return EditView{this->key, ValueView{}}; | ||
| } | ||
| [this](const ShardedLeafScanState& state) -> EditView { | ||
| return EditView{this->key, BATT_OK_RESULT_OR_PANIC(state.leaf_scanner_->front_value())}; | ||
| }); | ||
| } | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add regression test for this fix.