TwoLevelIterator

Struct TwoLevelIterator 

Source
pub struct TwoLevelIterator {
    table: Arc<Table>,
    read_options: ReadOptions,
    index_block_iter: BlockIter<InternalKey>,
    maybe_data_block_iter: Option<BlockIter<InternalKey>>,
    data_block_handle: Option<BlockHandle>,
}
Expand description

A two-level iterator that first iterates the index block and then iterates a corresponding data block. NOTE: This iterator is initially invalid until an operation is performed with it.

This iterator yields the concatenation of all key-value pairs in a sequence of blocks (e.g. in a table file).

Fields§

§table: Arc<Table>

The table the iterator is for.

§read_options: ReadOptions

Options for configuring the behavior of reads done by the iterator.

§index_block_iter: BlockIter<InternalKey>

Iterator for the index block.

§maybe_data_block_iter: Option<BlockIter<InternalKey>>

Iterator for a data block.

§data_block_handle: Option<BlockHandle>

The block handle used to get the data block in the [TwoLevelIterator::data_block] field.

Implementations§

Source§

impl TwoLevelIterator

Private methods

Source

fn new(table: Arc<Table>, read_options: ReadOptions) -> Self

Create a new instance of TwoLevelIterator.

Source

fn init_data_block(&mut self) -> Result<(), ReadError>

Source

fn skip_empty_data_blocks_forward(&mut self) -> Result<(), ReadError>

Move the index iterator and data iterator forward until we find a non-empty block.

Source

fn skip_empty_data_blocks_backward(&mut self) -> Result<(), ReadError>

Move the index iterator and data iterator backward until we find a non-empty block.

If a data block is found, this will set the data block iterator to the last entry of the data block.

Trait Implementations§

Source§

impl RainDbIterator for TwoLevelIterator

Source§

type Key = InternalKey

The type of key that is iterated over.
Source§

type Error = RainDBError

The type of error returned when there is an error during iteration.
Source§

fn is_valid(&self) -> bool

The iterator is only valid if the cursor is currently positioned at a key-value pair.
Source§

fn seek(&mut self, target: &Self::Key) -> Result<(), Self::Error>

Position cursor to the first key that is at or past the target. Read more
Source§

fn seek_to_first(&mut self) -> Result<(), Self::Error>

Position cursor to the first element. Read more
Source§

fn seek_to_last(&mut self) -> Result<(), Self::Error>

Position cursor to the last element. Read more
Source§

fn next(&mut self) -> Option<(&Self::Key, &Vec<u8>)>

Move to the next element. Read more
Source§

fn prev(&mut self) -> Option<(&Self::Key, &Vec<u8>)>

Move to the previous element. Read more
Source§

fn current(&self) -> Option<(&Self::Key, &Vec<u8>)>

Return the key and value at the current cursor position. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V