pub(crate) struct LimitManager {
    scan_limiter: ScanLimiter,
    halted_due_to_keyvalue_scan_limit: bool,
    halted_due_to_byte_scan_limit: bool,
    halted_due_to_time_scan_limit: bool,
}
Expand description

Handles the logic of tracking out-of-band limits.

Out-of-band limits are:

  1. Keyvalue limit
  2. Byte Limit
  3. Time Limit

The limit manager merely tracks the limit state and provides coherent answers to the questions:

  1. Can the cursor advance without exceeding the limit?
  2. What limit has been exceeded?

Unlike Java RecordLayer, we do not have a notion of “free initial pass”. This is because in our cursor implementation, we can return a begin continuation in case a out-of-band limit was reached before the cursor could make any progress. The client can then return the begin continuation back and the cursor will start from the beginning.

Fields§

§scan_limiter: ScanLimiter§halted_due_to_keyvalue_scan_limit: bool§halted_due_to_byte_scan_limit: bool§halted_due_to_time_scan_limit: bool

Implementations§

source§

impl LimitManager

source

pub(crate) fn new(scan_limiter: ScanLimiter) -> LimitManager

Create a new LimitManager from a value of ScanLimiter.

source

pub(crate) fn try_keyvalue_scan( &mut self ) -> Result<(), LimitManagerStoppedReason>

Return true if keyvalue can be read otherwise return false.

If we have a Some(KeyValueScanLimiter) in ScanLimiter, it also increments its keyvalues_scanned field.

Used by <KeyValueCursor as Cursor<KeyValue>>::next.

source

pub(crate) fn register_scanned_bytes(&self, byte_size: usize)

Increment the number of bytes scanned by the given number of bytes.

Used by <KeyValueCursor as Cursor<KeyValue>>::next.

Trait Implementations§

source§

impl Debug for LimitManager

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.