-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b49c44
commit 61cac02
Showing
5 changed files
with
70 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::snapshot_nonce::SnapshotNonce; | ||
|
||
/// A wrapper around iterators to hold a snapshot moment | ||
/// | ||
/// We need to hold the snapshot nonce so the GC watermark does not | ||
/// move past this snapshot moment, removing data that may still be read. | ||
/// | ||
/// This may not be strictly needed because an iterator holds a read lock to a memtable anyway | ||
/// but for correctness it's probably better. | ||
pub struct Iter<T, I: DoubleEndedIterator<Item = crate::Result<T>>> { | ||
iter: I, | ||
|
||
#[allow(unused)] | ||
nonce: SnapshotNonce, | ||
} | ||
|
||
impl<T, I: DoubleEndedIterator<Item = crate::Result<T>>> Iter<T, I> { | ||
pub fn new(nonce: SnapshotNonce, iter: I) -> Self { | ||
Self { iter, nonce } | ||
} | ||
} | ||
|
||
impl<T, I: DoubleEndedIterator<Item = crate::Result<T>>> Iterator for Iter<T, I> { | ||
type Item = crate::Result<T>; | ||
|
||
fn next(&mut self) -> Option<Self::Item> { | ||
self.iter.next() | ||
} | ||
} | ||
|
||
impl<T, I: DoubleEndedIterator<Item = crate::Result<T>>> DoubleEndedIterator for Iter<T, I> { | ||
fn next_back(&mut self) -> Option<Self::Item> { | ||
self.iter.next_back() | ||
} | ||
} |
This file contains 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 |
---|---|---|
|
@@ -93,6 +93,7 @@ mod error; | |
mod file; | ||
mod flush; | ||
mod gc; | ||
mod iter; | ||
mod journal; | ||
mod keyspace; | ||
mod monitor; | ||
|
This file contains 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 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 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