pub struct BatchedTransaction<E: StorageEngine> { /* private fields */ }Expand description
A transaction that buffers writes for batch commit.
This transaction maintains its own write buffer for isolation - each transaction sees its own uncommitted writes. On commit, all writes are submitted to the batch writer for group commit.
Implementations§
Source§impl<E: StorageEngine> BatchedTransaction<E>
impl<E: StorageEngine> BatchedTransaction<E>
Sourcepub fn get(
&self,
table: &str,
key: &[u8],
) -> Result<Option<Vec<u8>>, TransactionError>
pub fn get( &self, table: &str, key: &[u8], ) -> Result<Option<Vec<u8>>, TransactionError>
Read a value, checking the local buffer first.
This provides read-your-own-writes semantics.
Sourcepub fn put(
&mut self,
table: &str,
key: &[u8],
value: &[u8],
) -> Result<(), TransactionError>
pub fn put( &mut self, table: &str, key: &[u8], value: &[u8], ) -> Result<(), TransactionError>
Buffer a put operation.
Sourcepub fn delete(
&mut self,
table: &str,
key: &[u8],
) -> Result<bool, TransactionError>
pub fn delete( &mut self, table: &str, key: &[u8], ) -> Result<bool, TransactionError>
Buffer a delete operation.
Sourcepub fn commit(self) -> Result<(), TransactionError>
pub fn commit(self) -> Result<(), TransactionError>
Commit the transaction through the batch writer.
This submits all buffered writes to the batch writer for group commit. The method blocks until the batch containing this transaction is committed.
Sourcepub fn rollback(self) -> Result<(), TransactionError>
pub fn rollback(self) -> Result<(), TransactionError>
Rollback the transaction, discarding all buffered writes.
Sourcepub fn buffered_ops(&self) -> usize
pub fn buffered_ops(&self) -> usize
Get the number of buffered operations.
Trait Implementations§
Source§impl<E: StorageEngine> Drop for BatchedTransaction<E>
impl<E: StorageEngine> Drop for BatchedTransaction<E>
Auto Trait Implementations§
impl<E> Freeze for BatchedTransaction<E>
impl<E> RefUnwindSafe for BatchedTransaction<E>where
E: RefUnwindSafe,
impl<E> Send for BatchedTransaction<E>
impl<E> Sync for BatchedTransaction<E>
impl<E> Unpin for BatchedTransaction<E>
impl<E> UnwindSafe for BatchedTransaction<E>where
E: RefUnwindSafe,
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
Mutably borrows from an owned value. Read more
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more