Skip to main content

HummockIterator

Trait HummockIterator 

Source
pub trait HummockIterator: Send {
    type Direction: HummockIteratorDirection;

    // Required methods
    fn next(&mut self) -> impl Future<Output = HummockResult<()>> + Send + '_;
    fn key(&self) -> FullKey<&[u8]>;
    fn value(&self) -> HummockValue<&[u8]>;
    fn is_valid(&self) -> bool;
    fn rewind(&mut self) -> impl Future<Output = HummockResult<()>> + Send + '_;
    fn seek<'a>(
        &'a mut self,
        key: FullKey<&'a [u8]>,
    ) -> impl Future<Output = HummockResult<()>> + Send;
    fn collect_local_statistic(&self, _stats: &mut StoreLocalStatistic);
    fn value_meta(&self) -> ValueMeta;
}
Expand description

HummockIterator defines the interface of all iterators, including SstableIterator, MergeIterator, UserIterator and ConcatIterator.

After creating the iterator instance,

  • if you want to iterate from the beginning, you need to then call its rewind method.
  • if you want to iterate from some specific position, you need to then call its seek method.

Required Associated Types§

Required Methods§

Source

fn next(&mut self) -> impl Future<Output = HummockResult<()>> + Send + '_

Moves a valid iterator to the next key.

Note:

  • Before calling this function, makes sure the iterator is_valid.
  • After calling this function, you may first check whether the iterator is_valid again, then get the new data by calling key and value.
  • If the position after calling this is invalid, this function WON’T return an Err. You should check is_valid before continuing the iteration.
§Panics

This function will panic if the iterator is invalid.

Source

fn key(&self) -> FullKey<&[u8]>

Retrieves the current key.

Note:

  • Before calling this function, makes sure the iterator is_valid.
  • This function should be straightforward and return immediately.
§Panics

This function will panic if the iterator is invalid.

Source

fn value(&self) -> HummockValue<&[u8]>

Retrieves the current value, decoded as HummockValue.

Note:

  • Before calling this function, makes sure the iterator is_valid.
  • This function should be straightforward and return immediately.
§Panics

This function will panic if the iterator is invalid, or the value cannot be decoded into HummockValue.

Source

fn is_valid(&self) -> bool

Indicates whether the iterator can be used.

Note:

  • ONLY call key, value, and next if is_valid returns true.
  • This function should be straightforward and return immediately.
Source

fn rewind(&mut self) -> impl Future<Output = HummockResult<()>> + Send + '_

Resets the position of the iterator.

Note:

  • Do not decide whether the position is valid or not by checking the returned error of this function. This function WON’T return an Err if invalid. You should check is_valid before starting iteration.
Source

fn seek<'a>( &'a mut self, key: FullKey<&'a [u8]>, ) -> impl Future<Output = HummockResult<()>> + Send

Resets iterator and seeks to the first position where the key >= provided key, or key <= provided key if this is a backward iterator.

Note:

  • Do not decide whether the position is valid or not by checking the returned error of this function. This function WON’T return an Err if invalid. You should check is_valid before starting iteration.
Source

fn collect_local_statistic(&self, _stats: &mut StoreLocalStatistic)

take local statistic info from iterator to report metrics.

Source

fn value_meta(&self) -> ValueMeta

Returns value meta.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<I: HummockIterator> HummockIterator for Box<I>

Source§

type Direction = <I as HummockIterator>::Direction

Source§

async fn next(&mut self) -> HummockResult<()>

Source§

fn key(&self) -> FullKey<&[u8]>

Source§

fn value(&self) -> HummockValue<&[u8]>

Source§

fn is_valid(&self) -> bool

Source§

async fn rewind(&mut self) -> HummockResult<()>

Source§

async fn seek<'a>(&'a mut self, key: FullKey<&'a [u8]>) -> HummockResult<()>

Source§

fn collect_local_statistic(&self, stats: &mut StoreLocalStatistic)

Source§

fn value_meta(&self) -> ValueMeta

Implementors§

Source§

impl HummockIterator for BackwardSstableIterator

Source§

impl HummockIterator for ConcatSstableIterator

Source§

impl HummockIterator for SstableIterator

Source§

impl<B: RustIteratorBuilder> HummockIterator for FromRustIterator<'_, B>

Source§

impl<D: HummockIteratorDirection, I1: HummockIterator<Direction = D>, I2: HummockIterator<Direction = D>, I3: HummockIterator<Direction = D>, I4: HummockIterator<Direction = D>> HummockIterator for HummockIteratorUnion<D, I1, I2, I3, I4>

Source§

impl<D: HummockIteratorDirection, const IS_NEW_VALUE: bool> HummockIterator for SharedBufferBatchIterator<D, IS_NEW_VALUE>

Source§

impl<D: HummockIteratorDirection> HummockIterator for PhantomHummockIterator<D>

Source§

impl<I: HummockIterator<Direction = Forward>, S: SkipWatermarkState> HummockIterator for SkipWatermarkIterator<I, S>

Source§

impl<I: HummockIterator<Direction = Forward>> HummockIterator for MonitoredCompactorIterator<I>

Source§

impl<I: HummockIterator> HummockIterator for MergeIterator<I>
where Node<I>: Ord,

Source§

impl<TI: SstableIteratorType> HummockIterator for ConcatIteratorInner<TI>