Struct pravega_client::sync::Table

source ·
pub struct Table { /* private fields */ }
Expand description

Table is the client implementation of Table Segment in Pravega. Table Segment is a key-value table based on Pravega segment.

§Examples

let map = client_factory.create_table(scope, "table".into()).await;
let k: String = "key".into();
let v: String = "val".into();
let result = map.insert(&k, &v, -1).await;
assert!(result.is_ok());
let result: Result<Option<(String, Version)>, TableError> = map.get(&k).await;
assert!(result.is_ok());

Implementations§

source§

impl Table

source

pub async fn get<K, V>(&self, k: &K) -> Result<Option<(V, Version)>, TableError>

Return the latest value corresponding to the key.

If the map does not have the key None is returned. The version number of the Value is returned by the API.

source

pub async fn insert<K, V>( &self, k: &K, v: &V, offset: i64 ) -> Result<Version, TableError>

Unconditionally insert a new or update an existing entry for the given key. Once the update is performed the newer version is returned.

source

pub async fn insert_conditionally<K, V>( &self, k: &K, v: &V, key_version: Version, offset: i64 ) -> Result<Version, TableError>

Conditionally insert a key-value pair into the table map. The Key and Value are serialized to bytes using cbor.

The insert is performed after checking the key_version passed. Once the update is done the newer version is returned. TableError::BadKeyVersion is returned in case of an incorrect key version.

source

pub async fn remove<K: Serialize + DeserializeOwned>( &self, k: &K, offset: i64 ) -> Result<(), TableError>

Unconditionally remove a key from the Table. If the key does not exist an Ok(()) is returned.

source

pub async fn remove_conditionally<K>( &self, k: &K, key_version: Version, offset: i64 ) -> Result<(), TableError>

Conditionally remove a key from the Table if it matches the provided key version. TableError::BadKeyVersion is returned in case the version does not exist.

source

pub async fn get_all<K, V>( &self, keys: Vec<&K> ) -> Result<Vec<Option<(V, Version)>>, TableError>

Return the latest values for a given list of keys. If the table does not have a key a None is returned for the corresponding key. The version number of the Value is also returned by the API

source

pub async fn insert_all<K, V>( &self, kvps: Vec<(&K, &V)>, offset: i64 ) -> Result<Vec<Version>, TableError>

Unconditionally insert a new or updates an existing entry for the given keys. Once the update is performed the newer versions are returned.

source

pub async fn insert_conditionally_all<K, V>( &self, kvps: Vec<(&K, &V, Version)>, offset: i64 ) -> Result<Vec<Version>, TableError>

Conditionally insert key-value pairs into the table. The Key and Value are serialized to to bytes using cbor

The insert is performed after checking the key_version passed, in case of a failure none of the key-value pairs are persisted. Once the update is done the newer version is returned. TableError::BadKeyVersion is returned in case of an incorrect key version.

source

pub async fn remove_all<K>( &self, keys: Vec<&K>, offset: i64 ) -> Result<(), TableError>

Unconditionally remove the provided keys from the table.

source

pub async fn remove_conditionally_all<K>( &self, keys: Vec<(&K, Version)>, offset: i64 ) -> Result<(), TableError>

Conditionally remove keys after checking the key version. In case of a failure none of the keys are removed.

source

pub fn read_keys_stream<'stream, 'map: 'stream, K>( &'map self, max_keys_at_once: i32 ) -> impl Stream<Item = Result<(K, Version), TableError>> + 'stream
where K: Serialize + DeserializeOwned + Unpin + 'stream,

Read keys as an Async Stream. This method deserializes the Key based on the type.

source

pub fn read_entries_stream<'stream, 'map: 'stream, K, V>( &'map self, max_entries_at_once: i32 ) -> impl Stream<Item = Result<(K, V, Version), TableError>> + 'stream
where K: Serialize + DeserializeOwned + Unpin + 'map, V: Serialize + DeserializeOwned + Unpin + 'map,

Read entries as an Async Stream. This method deserialized the Key and Value based on the inferred type.

source

pub fn read_entries_stream_from_position<'stream, 'map: 'stream, K, V>( &'map self, max_entries_at_once: i32, from_position: i64 ) -> impl Stream<Item = Result<(K, V, Version, i64), TableError>> + 'stream
where K: Serialize + DeserializeOwned + Unpin + 'map, V: Serialize + DeserializeOwned + Unpin + 'map,

Read entries as an Async Stream from a given position. This method deserialized the Key and Value based on the inferred type.

Auto Trait Implementations§

§

impl !Freeze for Table

§

impl !RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl !UnwindSafe for Table

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where 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> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more