Struct fdb_rl::cursor::limit_manager::LimitManager
source · 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:
- Keyvalue limit
- Byte Limit
- Time Limit
The limit manager merely tracks the limit state and provides coherent answers to the questions:
- Can the cursor advance without exceeding the limit?
- 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
impl LimitManager
sourcepub(crate) fn new(scan_limiter: ScanLimiter) -> LimitManager
pub(crate) fn new(scan_limiter: ScanLimiter) -> LimitManager
Create a new LimitManager
from a value of ScanLimiter
.
sourcepub(crate) fn try_keyvalue_scan(
&mut self
) -> Result<(), LimitManagerStoppedReason>
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
.
sourcepub(crate) fn register_scanned_bytes(&self, byte_size: usize)
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
.