pub trait ReadTransaction {
    // Required methods
    unsafe fn on_error(&self, e: FdbError) -> FdbFutureUnit;
    fn get(&self, key: impl Into<Key>) -> FdbFutureMaybeValue;
    fn get_addresses_for_key(
        &self,
        key: impl Into<Key>
    ) -> FdbFutureCStringArray;
    fn get_estimated_range_size_bytes(&self, range: Range) -> FdbFutureI64;
    fn get_key(&self, selector: KeySelector) -> FdbFutureKey;
    fn get_mapped_range(
        &self,
        begin: KeySelector,
        end: KeySelector,
        mapper: impl Into<Mapper>,
        options: RangeOptions
    ) -> FdbStreamMappedKeyValue;
    fn get_range(
        &self,
        begin: KeySelector,
        end: KeySelector,
        options: RangeOptions
    ) -> FdbStreamKeyValue;
    fn get_range_split_points(
        &self,
        begin: impl Into<Key>,
        end: impl Into<Key>,
        chunk_size: i64
    ) -> FdbFutureKeyArray;
    unsafe fn get_read_version(&self) -> FdbFutureI64;
    unsafe fn set_option(&self, option: TransactionOption) -> FdbResult<()>;
    unsafe fn set_read_version(&self, version: i64);
}
Expand description

A read-only subset of a FDB Transaction.

Required Methods§

source

unsafe fn on_error(&self, e: FdbError) -> FdbFutureUnit

Determines whether an error returned by a Transaction or ReadTransaction method is retryable. Waiting on the returned future will return the same error when fatal, or return () for retryable errors.

Typical code will not use this method directly. It is used by run and read methods when they need to implement correct retry loop.

Equivalent to:

async unsafe fn on_error(&self, e: FdbError) -> FdbResult<()>
Safety

See C API for more details.

source

fn get(&self, key: impl Into<Key>) -> FdbFutureMaybeValue

Gets a value from the database.

Equivalent to:

async fn get(&self, key: impl Into<Key>) -> FdbResult<Option<Value>>
source

fn get_addresses_for_key(&self, key: impl Into<Key>) -> FdbFutureCStringArray

Get a list of public network addresses as CString, one for each of the storage servers responsible for storing Key and its associated value.

Equivalent to:

async fn get_addresses_for_key(&self, key: impl Into<Key>) -> FdbResult<Vec<CString>>;
source

fn get_estimated_range_size_bytes(&self, range: Range) -> FdbFutureI64

Gets an estimate for the number of bytes stored in the given range.

Equivalent to:

async fn get_estimated_range_size_bytes(&self, range: Range) -> FdbResult<i64>
Note

The estimated size is calculated based on the sampling done by FDB server. The sampling algorithm roughly works this way: The sampling algorithm works roughly in this way: the lager the key-value pair is, the more likely it would be sampled and the more accurate its sampled size would be. And due to that reason, it is recommended to use this API to query against large ranges for accuracy considerations. For a rough reference, if the returned size is larger than 3MB, one can consider the size to be accurate.

source

fn get_key(&self, selector: KeySelector) -> FdbFutureKey

Returns the key referenced by the specificed KeySelector.

Equivalent to:

async fn get_key(&self, selector: KeySelector) -> FdbResult<Key>
source

fn get_mapped_range( &self, begin: KeySelector, end: KeySelector, mapper: impl Into<Mapper>, options: RangeOptions ) -> FdbStreamMappedKeyValue

WARNING: This feature is considered experimental at this time.

Gets an ordered range of mapped keys and values from the database.

The returned FdbStreamMappedKeyValue implements Stream trait that yields a MappedKeyValue item.

source

fn get_range( &self, begin: KeySelector, end: KeySelector, options: RangeOptions ) -> FdbStreamKeyValue

Gets an ordered range of keys and values from the database.

The returned FdbStreamKeyValue implements Stream trait that yields a KeyValue item.

source

fn get_range_split_points( &self, begin: impl Into<Key>, end: impl Into<Key>, chunk_size: i64 ) -> FdbFutureKeyArray

Gets a list of keys that can split the given range into (roughly) equally sized chunks based on chunk_size.

Equivalent to:

async fn get_range_split_points(
    &self,
    begin: impl Into<Key>,
    end: impl Into<Key>,
    chunk_size: i64,
) -> FdbResult<Vec<Key>>
source

unsafe fn get_read_version(&self) -> FdbFutureI64

Gets the version at which the reads for this Transaction or ReadTransaction will access the database.

Equivalent to:

async unsafe fn get_read_version(&self) -> FdbResult<i64>
Safety

The FdbFuture resolves to an i64 instead of a u64 because of internal representation. Even though it is an i64, the future will always return a positive number. Negative GRV numbers are used internally within FDB.

You only rely on GRV only for read-only transactions. For read-write transactions you should use commit version.

source

unsafe fn set_option(&self, option: TransactionOption) -> FdbResult<()>

Set options on a Transaction or ReadTransaction

Safety

Setting transaction timeout or retry limits can cause transactions to fail in an inconsistent state.

source

unsafe fn set_read_version(&self, version: i64)

Directly sets the version of the database at which to execute reads.

Safety

See C API for more details.

Implementors§