pub struct UserIterator<I: HummockIterator<Direction = Forward>> {
iterator: I,
full_key_tracker: FullKeyTracker<Vec<u8>, true>,
key_range: UserKeyRange,
read_epoch: HummockEpoch,
min_epoch: HummockEpoch,
_version: Option<PinnedVersion>,
stats: StoreLocalStatistic,
is_current_pos_valid: bool,
}
Expand description
UserIterator
can be used by user directly.
Fields§
§iterator: I
Inner table iterator.
full_key_tracker: FullKeyTracker<Vec<u8>, true>
§key_range: UserKeyRange
Start and end bounds of user key.
read_epoch: HummockEpoch
Only reads values if ts <= self.read_epoch
.
min_epoch: HummockEpoch
Only reads values if ts > self.min_epoch
. use for ttl
_version: Option<PinnedVersion>
Ensures the SSTs needed by iterator
won’t be vacuumed.
stats: StoreLocalStatistic
§is_current_pos_valid: bool
Whether the iterator is pointing to a valid position
Implementations§
source§impl<I: HummockIterator<Direction = Forward>> UserIterator<I>
impl<I: HummockIterator<Direction = Forward>> UserIterator<I>
sourcepub(crate) fn new(
iterator: I,
key_range: UserKeyRange,
read_epoch: u64,
min_epoch: u64,
version: Option<PinnedVersion>,
) -> Self
pub(crate) fn new( iterator: I, key_range: UserKeyRange, read_epoch: u64, min_epoch: u64, version: Option<PinnedVersion>, ) -> Self
Create UserIterator
with given read_epoch
.
sourcepub fn for_test(iterator: I, key_range: UserKeyRange) -> Self
pub fn for_test(iterator: I, key_range: UserKeyRange) -> Self
Create UserIterator
with maximum epoch.
sourcepub async fn next(&mut self) -> HummockResult<()>
pub async fn next(&mut self) -> HummockResult<()>
Gets the iterator move to the next step.
See IteratorState
for the state machine details.
Returned result:
- if
Ok(())
is returned, it means that the iterator successfully move to the next position (may reach to the end and thus not valid) - if
Err(_)
is returned, it means that some error happened.
sourcepub fn key(&self) -> FullKey<&[u8]>
pub fn key(&self) -> FullKey<&[u8]>
Returns the key with the newest version. Thus no version in it, and only the user_key
will
be returned.
The returned key is de-duplicated and thus it will not output the same key, unless the
rewind
or seek
methods are called.
Note: before call the function you need to ensure that the iterator is valid.
sourcepub fn value(&self) -> &[u8] ⓘ
pub fn value(&self) -> &[u8] ⓘ
The returned value is in the form of user value.
Note: before call the function you need to ensure that the iterator is valid.
sourcepub async fn rewind(&mut self) -> HummockResult<()>
pub async fn rewind(&mut self) -> HummockResult<()>
Resets the iterating position to the beginning.
sourcepub async fn seek(&mut self, user_key: UserKey<&[u8]>) -> HummockResult<()>
pub async fn seek(&mut self, user_key: UserKey<&[u8]>) -> HummockResult<()>
Resets the iterating position to the first position where the key >= provided key.
pub fn collect_local_statistic(&self, stats: &mut StoreLocalStatistic)
sourceasync fn try_advance_to_next_valid(&mut self) -> HummockResult<()>
async fn try_advance_to_next_valid(&mut self) -> HummockResult<()>
Advance the inner iterator to a valid position, in which the entry can be exposed. Iterator will not be advanced if it already pointed to a valid position.
fn user_key_out_of_range(&self, user_key: UserKey<&[u8]>) -> bool
Auto Trait Implementations§
impl<I> !Freeze for UserIterator<I>
impl<I> !RefUnwindSafe for UserIterator<I>
impl<I> Send for UserIterator<I>
impl<I> Sync for UserIterator<I>where
I: Sync,
impl<I> Unpin for UserIterator<I>where
I: Unpin,
impl<I> !UnwindSafe for UserIterator<I>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
source§impl<M> MetricVecRelabelExt for M
impl<M> MetricVecRelabelExt for M
source§fn relabel(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level
.source§fn relabel_n(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
relabel_num: usize,
) -> RelabeledMetricVec<M>
fn relabel_n( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, relabel_num: usize, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n
.source§fn relabel_debug_1(
self,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel_debug_1( self, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n
with metric_level
set to
MetricLevel::Debug
and relabel_num
set to 1.