Skip to main content

PushCursor

Trait PushCursor 

Source
pub trait PushCursor<K, V, T, R>
where K: ?Sized, V: ?Sized, R: ?Sized,
{ // Required methods fn key(&self) -> Result<Option<&K>, Pending>; fn val(&self) -> Result<Option<&V>, Pending>; fn map_times(&mut self, logic: &mut dyn FnMut(&T, &R)); fn weight(&mut self) -> &R where T: PartialEq<()>; fn step_key(&mut self); fn step_val(&mut self); fn run(&mut self); }
Expand description

Cursor for non-blocking I/O.

Other implementations of cursors do not have a notion of whether data is in memory, which means that operations to retrieve data can block on I/O. A PushCursor on the other hand, reports Pending if the data currently to be retrieved is not yet available because of pending I/O. This allows merging using such a cursor to be more efficient.

PushCursor is optimized for reading all of the data in a batch.

Required Methods§

Source

fn key(&self) -> Result<Option<&K>, Pending>

Returns the current key as Ok(Some(key)), or Ok(None) if the batch is exhausted, or Err(Pending) if this key exists but isn’t available yet.

Source

fn val(&self) -> Result<Option<&V>, Pending>

Returns the current value as Ok(Some(key)), or Ok(None) if the key’s values are exhausted, or Err(Pending) if this value exists but isn’t available yet.

It is an error if the batch is exhausted or the current key is not available. The implementation might panic or return an incorrect value in this case (but it is not undefined behavior).

Source

fn map_times(&mut self, logic: &mut dyn FnMut(&T, &R))

Applies logic to each pair of time and difference for the current key-value pair.

When a key-value pair is available, all its time-diff pairs are available.

It is an error if the current key and value are not available. The implementation might panic or pass incorrect time-diff pairs to logic in this case (but it is not undefined behavior).

Source

fn weight(&mut self) -> &R
where T: PartialEq<()>,

Returns the weight associated with the current key/value pair.

When a key-value pair is available, its weight is available.

It is an error if the current key and value are not available. The implementation might panic or pass incorrect time-diff pairs to logic in this case (but it is not undefined behavior).

Source

fn step_key(&mut self)

Advances to the next key.

It is an error if the batch is exhausted or the current key is not available. The implementation might panic in this case (but it is not undefined behavior).

Source

fn step_val(&mut self)

Advances to the next value.

It is an error if the batch is exhausted or the current key or value is not available. The implementation might panic in this case (but it is not undefined behavior).

Source

fn run(&mut self)

Gives the implementation an opportunity to process I/O results and launch further I/O. Implementations need this to called periodically.

Implementations on Foreign Types§

Source§

impl<K, V, T, R, C> PushCursor<K, V, T, R> for Box<C>
where C: PushCursor<K, V, T, R> + ?Sized, K: ?Sized, V: ?Sized, R: ?Sized,

Source§

fn key(&self) -> Result<Option<&K>, Pending>

Source§

fn val(&self) -> Result<Option<&V>, Pending>

Source§

fn map_times(&mut self, logic: &mut dyn FnMut(&T, &R))

Source§

fn weight(&mut self) -> &R
where T: PartialEq<()>,

Source§

fn step_key(&mut self)

Source§

fn step_val(&mut self)

Source§

fn run(&mut self)

Implementors§

Source§

impl<'s, K, V, R> PushCursor<K, V, (), R> for FileIndexedWSetPushCursor<'s, K, V, R>
where K: DataTrait + ?Sized, V: DataTrait + ?Sized, R: WeightTrait + ?Sized,

Source§

impl<K, V, T, R, C> PushCursor<K, V, T, R> for DefaultPushCursor<K, V, T, R, C>
where K: ?Sized, V: ?Sized, R: ?Sized, C: Cursor<K, V, T, R>,