Skip to main content

PooledIterator

Struct PooledIterator 

Source
pub struct PooledIterator { /* private fields */ }
Expand description

A pooled iterator that automatically returns to the global pool on drop.

Wraps a DBIterator and implements Deref/DerefMut so it can be used identically. When dropped, the iterator is reset (releasing Arc<TableReader> references) and returned to the global pool for reuse by any thread.

Implementations§

Source§

impl PooledIterator

Source

pub fn new(iter: DBIterator) -> Self

Wrap a DBIterator for automatic pool return on drop.

Source

pub fn into_inner(self) -> DBIterator

Take ownership of the inner iterator, disabling automatic pool return.

Methods from Deref<Target = DBIterator>§

Source

pub fn reset(&mut self, sources: Vec<IterSource>, sequence: SequenceNumber)

Reset the iterator with new sources and sequence, reusing allocated memory. Used by the iterator pool to avoid per-iteration allocation overhead.

Source

pub fn reset_with_prefix( &mut self, sources: Vec<IterSource>, sequence: SequenceNumber, prefix: Vec<u8>, )

Reset with prefix-bounded iteration, reusing allocated memory.

Source

pub fn set_range_tombstones( &mut self, tombstones: Vec<(Vec<u8>, Vec<u8>, SequenceNumber)>, )

Set pre-collected range tombstones. Called by the DB layer after collecting tombstones from all memtables and SST files.

Source

pub fn set_range_tombstones_with_levels( &mut self, tombstones: Vec<(Vec<u8>, Vec<u8>, SequenceNumber, usize)>, )

Set range tombstones with level info for cross-level pruning. A tombstone from level L can only delete keys from levels > L.

Source

pub fn set_no_range_deletions(&mut self)

No-op: tombstones are loaded upfront; emptiness is checked via is_empty().

Source

pub fn set_upper_bound(&mut self, bound: Vec<u8>)

Set an exclusive upper bound on user keys. Iteration stops when user key >= this bound. Models RocksDB’s ReadOptions::iterate_upper_bound.

Source

pub fn set_lower_bound(&mut self, bound: Vec<u8>)

Set an inclusive lower bound on user keys.

Source

pub fn set_bounds(&mut self, lower: Option<Vec<u8>>, upper: Option<Vec<u8>>)

Set both lower (inclusive) and upper (exclusive) bounds on user keys.

Source

pub fn error(&self) -> Option<String>

Return the first error from any underlying source iterator. Use after iteration returns None to distinguish normal exhaustion from I/O failures.

Source

pub fn set_skip_point(&mut self, f: SkipPointFn)

Set a skip-point callback. During iteration, any user key for which the callback returns true is silently skipped.

Source

pub fn next_prefix(&mut self, prefix_len: usize)

Jump to the first key of the next prefix, skipping all remaining keys under the current prefix in O(log N) instead of O(keys_in_prefix). prefix_len is the number of bytes that define a prefix.

Source

pub fn valid(&mut self) -> bool

Source

pub fn key(&mut self) -> Option<&[u8]>

Source

pub fn value(&mut self) -> Option<&[u8]>

Source

pub fn advance(&mut self)

Source

pub fn seek(&mut self, target: &[u8])

Seek to the first key >= target.

Source

pub fn seek_to_first(&mut self)

Source

pub fn reset_and_seek_to_first(&mut self)

Fully reset internal deduplication/tombstone state, then seek to first. Used by BidiIterator when materializing after a seek_to_last().

Source

pub fn seek_for_prev(&mut self, target: &[u8])

Seek to the last visible user key <= target.

Uses a single backward seek + inline resolution. No redundant forward seek.

Source

pub fn prev(&mut self)

Move to the previous visible user key.

Uses inline backward resolution: O(1) amortized per call.

Source

pub fn seek_to_last(&mut self)

Seek to the last visible key. Positions the iterator on the very last entry.

If a prefix is set, seeks to the last key within the prefix. Uses merger backward seek to find the last user key efficiently, then resolves visibility inline (no forward re-seek).

Source

pub fn last_user_key(&self) -> Option<&[u8]>

Return the last user key seen by next_visible(), if any. Used by BidiIterator for re-seeking on direction change.

Source

pub fn collect_remaining(&mut self) -> Vec<(Vec<u8>, Vec<u8>)>

Source

pub fn count(&mut self) -> usize

Source

pub fn next_lazy(&mut self) -> Option<(Vec<u8>, LazyValue)>

Advance to the next visible entry, returning LazyValue without materializing it. Avoids the into_vec() copy that Iterator::next() must perform.

Source

pub fn take_current(&mut self) -> Option<(Vec<u8>, LazyValue)>

Take ownership of the current buffered entry without advancing. After this call, valid() returns false until the next seek/advance.

Trait Implementations§

Source§

impl Deref for PooledIterator

Source§

type Target = DBIterator

The resulting type after dereferencing.
Source§

fn deref(&self) -> &DBIterator

Dereferences the value.
Source§

impl DerefMut for PooledIterator

Source§

fn deref_mut(&mut self) -> &mut DBIterator

Mutably dereferences the value.
Source§

impl Drop for PooledIterator

Source§

fn drop(&mut self)

Executes the destructor for this type. 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more