pub struct KeyValueCursorBuilder {
    subspace: Option<Subspace>,
    scan_properties: Option<ScanProperties>,
    key_range: Option<KeyRange>,
    continuation: Option<Bytes>,
}
Expand description

A builder for KeyValueCursor. A value of KeyValueCursor can be built as shown below.

let kv_cursor = {
    let mut kv_cursor_builder = KeyValueCursorBuilder::new();

    kv_cursor_builder
        .subspace(Subspace::new(Bytes::new()).subspace(&{
            let tup: (&str, &str) = ("sub", "space");

            let mut t = Tuple::new();
            t.push_back::<String>(tup.0.to_string());
            t.push_back::<String>(tup.1.to_string());

            t
        }))
        .key_range(TupleRange::all().into_key_range(&None))
        .continuation(continuation_bytes)
        .scan_properties(ScanPropertiesBuilder::default().build());

    kv_cursor_builder.build(&tr)
}?;

Methods KeyValueCursorBuilder::subspace and KeyValueCursorBuilder::continuation can be used when needed, and are not needed to build a value of type KeyValueCursor.

Note: Please make sure you read about the limitation mentioned in the documentation for KeyValueCursorBuilder::scan_properties. As a heads-up, setting in-band limit is unsafe only for KeyValueCursor. This limitation does not exist for other cursors because it does not directly use RangeOptions API.

Fields§

§subspace: Option<Subspace>§scan_properties: Option<ScanProperties>§key_range: Option<KeyRange>§continuation: Option<Bytes>

Implementations§

source§

impl KeyValueCursorBuilder

source

pub fn new() -> KeyValueCursorBuilder

Return a new builder.

source

pub fn subspace(&mut self, subspace: Subspace) -> &mut KeyValueCursorBuilder

Sets the Subspace.

Note: If you intend to set a continuation, then you must use the same Subspace used to build the KeyValueCursor that returned the continuation.

source

pub fn scan_properties( &mut self, scan_properties: ScanProperties ) -> &mut KeyValueCursorBuilder

Sets the ScanProperties.

Note

There is no way in the RangeOptions API (within ScanProperties) to set a limit of 0. Infact if you set the limit to 0, you are indicating that you want unlimited rows, which almost always is not the behavior that you want.

The correct way to handle this is not to create the KeyValueCursor, when you want a limit of 0. If you provide a limit of 0 or less, the behavior that you will actually get is that you will be requesting i32::MAX key values.

Since KeyValueCursor is a low-level API we expect the users of this API to be aware of this limitation if you are using this API.

If you intend to set a continuation, then you must use the same RangeOptions (within ScanProperties) used to build the KeyValueCursor that returned the continuation and if limit is used adjust then its value accordingly.

source

pub fn key_range(&mut self, key_range: KeyRange) -> &mut KeyValueCursorBuilder

Sets the KeyRange.

Note: If you intend to set a continuation, then you must use the same KeyRange used to build the KeyValueCursor that returned the continuation.

source

pub fn continuation( &mut self, continuation: Bytes ) -> &mut KeyValueCursorBuilder

Sets the continuation bytes that was previously returned.

source

pub fn build<Tr>(self, read_transaction: &Tr) -> FdbResult<KeyValueCursor>where Tr: ReadTransaction,

Creates the configured KeyValueCursor.

source

pub(crate) fn build_range( maybe_subspace: &Option<Subspace>, key_range: KeyRange, maybe_continuation_internal: Option<KeyValueContinuationInternal>, reverse: bool ) -> FdbResult<Range>

Build a range with an optional continuation.

Note: This method along with bytes_endpoint::build_range_continuation and bytes_endpoint::build_range_bytes has extensive integration tests to verify its correctness. Exercise care when refactoring this code.

Trait Implementations§

source§

impl Clone for KeyValueCursorBuilder

source§

fn clone(&self) -> KeyValueCursorBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for KeyValueCursorBuilder

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for KeyValueCursorBuilder

source§

fn default() -> KeyValueCursorBuilder

Returns the “default value” for a type. 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.