-
Notifications
You must be signed in to change notification settings - Fork 706
refactor(storage): make iterator interfaces epoch-aware #62
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #62 +/- ##
============================================
- Coverage 74.58% 74.57% -0.02%
Complexity 2654 2654
============================================
Files 838 837 -1
Lines 47795 47875 +80
Branches 1562 1562
============================================
+ Hits 35649 35703 +54
- Misses 11347 11373 +26
Partials 799 799
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
c1742e7 to
782fa8d
Compare
skyzh
left a comment
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.
Generally LGTM, some small changes commented below.
rust/storage/src/table/mview.rs
Outdated
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.
Should ignore the first key? If we include last key in the scanning key range, the last key will also appear in the buf.
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.
scan_with_start_key uses exclusive start_key so the last key will not appear in the buf.
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.
The function name doesn't seem straightforward 🤪
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.
Better to rename it to scan_with_exclusive_start_key
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.
Changed scan_with_start_key to take an inclusive start_key. The caller will calculate the next_key.
782fa8d to
57c4c25
Compare
MrCroxx
left a comment
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.
LSTM
77cbdb8 to
35488d4
Compare
rust/storage/src/table/mview.rs
Outdated
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.
Why need this? When there is no data from state store, it will return EOF by nature.
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.
- TableIter only has
nextmethod, novalidmethod so it relies on callingnextto know whether there is any data (Ok((None) means EOF)). - We don't want unnecessary seek to happen when there is no more data or there is a non-retriable error
f35eb76 to
09acbfd
Compare
| type Iter<'a> = MemoryStateStoreIter; | ||
|
|
||
| async fn get(&self, key: &[u8]) -> Result<Option<Bytes>> { | ||
| async fn get(&self, key: &[u8], _epoch: u64) -> Result<Option<Bytes>> { |
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.
InMemory engine should be epoch-aware. Otherwise it will be hard to write unit tests for checkpointing logic -- it's impossible to start a MinIO instance when running unit tests.
| if self.buf.is_empty() { | ||
| self.buf = self.keyspace.scan(Some(limit), self.epoch).await? | ||
| } else { | ||
| let next_key = next_key(self.buf.last().unwrap().0.to_vec().as_slice()); |
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.
This is incorrect?
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.
e.g., we have
- a
- ab
- bc
the last key we get is a. next_key(a) = b. We will miss ab.
| #[allow(dead_code)] | ||
| pub async fn iterate_store(&self) -> Result<Vec<(A::OwnedItem, ExtremePk)>> { | ||
| let all_data = self.keyspace.scan_strip_prefix(None).await?; | ||
| let epoch = u64::MAX; |
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.
I've disabled two tests in previous PRs. May need to fix them by removing #[ignore].
Checklist
Refer to a related PR or issue link (optional)
part of #39