Struct fdb_rl::cursor::KeyValueCursorBuilder
source · 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
impl KeyValueCursorBuilder
sourcepub fn new() -> KeyValueCursorBuilder
pub fn new() -> KeyValueCursorBuilder
Return a new builder.
sourcepub fn subspace(&mut self, subspace: Subspace) -> &mut KeyValueCursorBuilder
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.
sourcepub fn scan_properties(
&mut self,
scan_properties: ScanProperties
) -> &mut KeyValueCursorBuilder
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.
sourcepub fn key_range(&mut self, key_range: KeyRange) -> &mut KeyValueCursorBuilder
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.
sourcepub fn continuation(
&mut self,
continuation: Bytes
) -> &mut KeyValueCursorBuilder
pub fn continuation( &mut self, continuation: Bytes ) -> &mut KeyValueCursorBuilder
Sets the continuation bytes that was previously returned.
sourcepub fn build<Tr>(self, read_transaction: &Tr) -> FdbResult<KeyValueCursor>where
Tr: ReadTransaction,
pub fn build<Tr>(self, read_transaction: &Tr) -> FdbResult<KeyValueCursor>where Tr: ReadTransaction,
Creates the configured KeyValueCursor
.
sourcepub(crate) fn build_range(
maybe_subspace: &Option<Subspace>,
key_range: KeyRange,
maybe_continuation_internal: Option<KeyValueContinuationInternal>,
reverse: bool
) -> FdbResult<Range>
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
impl Clone for KeyValueCursorBuilder
source§fn clone(&self) -> KeyValueCursorBuilder
fn clone(&self) -> KeyValueCursorBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more