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
impl Table
sourcepub async fn get<K, V>(&self, k: &K) -> Result<Option<(V, Version)>, TableError>
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.
sourcepub async fn insert<K, V>(
&self,
k: &K,
v: &V,
offset: i64
) -> Result<Version, TableError>
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.
sourcepub async fn insert_conditionally<K, V>(
&self,
k: &K,
v: &V,
key_version: Version,
offset: i64
) -> Result<Version, TableError>
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.
sourcepub async fn remove<K: Serialize + DeserializeOwned>(
&self,
k: &K,
offset: i64
) -> Result<(), TableError>
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.
sourcepub async fn remove_conditionally<K>(
&self,
k: &K,
key_version: Version,
offset: i64
) -> Result<(), TableError>where
K: Serialize + DeserializeOwned,
pub async fn remove_conditionally<K>(
&self,
k: &K,
key_version: Version,
offset: i64
) -> Result<(), TableError>where
K: Serialize + DeserializeOwned,
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.
sourcepub async fn get_all<K, V>(
&self,
keys: Vec<&K>
) -> Result<Vec<Option<(V, Version)>>, TableError>
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
sourcepub async fn insert_all<K, V>(
&self,
kvps: Vec<(&K, &V)>,
offset: i64
) -> Result<Vec<Version>, TableError>
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.
sourcepub async fn insert_conditionally_all<K, V>(
&self,
kvps: Vec<(&K, &V, Version)>,
offset: i64
) -> Result<Vec<Version>, TableError>
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.
sourcepub async fn remove_all<K>(
&self,
keys: Vec<&K>,
offset: i64
) -> Result<(), TableError>where
K: Serialize + DeserializeOwned,
pub async fn remove_all<K>(
&self,
keys: Vec<&K>,
offset: i64
) -> Result<(), TableError>where
K: Serialize + DeserializeOwned,
Unconditionally remove the provided keys from the table.
sourcepub async fn remove_conditionally_all<K>(
&self,
keys: Vec<(&K, Version)>,
offset: i64
) -> Result<(), TableError>where
K: Serialize + DeserializeOwned,
pub async fn remove_conditionally_all<K>(
&self,
keys: Vec<(&K, Version)>,
offset: i64
) -> Result<(), TableError>where
K: Serialize + DeserializeOwned,
Conditionally remove keys after checking the key version. In case of a failure none of the keys are removed.
sourcepub fn read_keys_stream<'stream, 'map: 'stream, K>(
&'map self,
max_keys_at_once: i32
) -> impl Stream<Item = Result<(K, Version), TableError>> + 'stream
pub fn read_keys_stream<'stream, 'map: 'stream, K>( &'map self, max_keys_at_once: i32 ) -> impl Stream<Item = Result<(K, Version), TableError>> + 'stream
Read keys as an Async Stream. This method deserializes the Key based on the type.
sourcepub fn read_entries_stream<'stream, 'map: 'stream, K, V>(
&'map self,
max_entries_at_once: i32
) -> impl Stream<Item = Result<(K, V, Version), TableError>> + 'streamwhere
K: Serialize + DeserializeOwned + Unpin + 'map,
V: Serialize + DeserializeOwned + Unpin + 'map,
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>> + 'streamwhere
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.
sourcepub 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>> + 'streamwhere
K: Serialize + DeserializeOwned + Unpin + 'map,
V: Serialize + DeserializeOwned + Unpin + 'map,
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>> + 'streamwhere
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request