Skip to main content

WriteBatch

Struct WriteBatch 

Source
pub struct WriteBatch<'db, K: StoreKey + Send, S: ParallelScheduler, const FAMILIES: usize> { /* private fields */ }
Expand description

A write batch.

Implementations§

Source§

impl<'db, K: StoreKey + Send + Sync, S: ParallelScheduler, const FAMILIES: usize> WriteBatch<'db, K, S, FAMILIES>

Source

pub fn put(&self, family: u32, key: K, value: ValueBuffer<'_>) -> Result<()>

Puts a key-value pair into the write batch.

Source

pub fn delete(&self, family: u32, key: K) -> Result<()>

Puts a delete operation into the write batch. This deletes all values for key.

Combining this with a WriteBatch::put of the same key in the same batch is not supported: which one wins is undefined, and callers are expected to resolve the intent themselves before writing.

Source

pub fn delete_value( &self, family: u32, key: K, value: ValueBuffer<'_>, ) -> Result<()>

Deletes a single key-value pair, leaving any other values for key intact.

Only valid for FamilyKind::MultiValue families: in a SingleValue family a key has one value and WriteBatch::delete already removes it exactly.

Deleting a pair that is written in the same batch — by this or any other operation on the key — is not supported, for the reason given on WriteBatch::delete: which one wins is undefined, and it is the caller’s job to resolve that before writing.

Only values of at most MAX_INLINE_VALUE_SIZE bytes can be deleted this way. This is a simplifying limitation that could be relaxed if needed. Of course in general the storage overhead of deleting large values by value makes it apriori inefficient.

Source

pub unsafe fn flush(&self, family: u32) -> Result<()>

Flushes a family of the write batch, reducing the amount of buffered memory used. Does not commit any data persistently.

§Safety

Caller must ensure that no concurrent put or delete operation is happening on the flushed family.

Auto Trait Implementations§

§

impl<'db, K, S, const FAMILIES: usize> !Freeze for WriteBatch<'db, K, S, FAMILIES>

§

impl<'db, K, S, const FAMILIES: usize> !RefUnwindSafe for WriteBatch<'db, K, S, FAMILIES>

§

impl<'db, K, S, const FAMILIES: usize> !UnwindSafe for WriteBatch<'db, K, S, FAMILIES>

§

impl<'db, K, S, const FAMILIES: usize> Send for WriteBatch<'db, K, S, FAMILIES>

§

impl<'db, K, S, const FAMILIES: usize> Sync for WriteBatch<'db, K, S, FAMILIES>

§

impl<'db, K, S, const FAMILIES: usize> Unpin for WriteBatch<'db, K, S, FAMILIES>
where S: Unpin, K: Unpin,

§

impl<'db, K, S, const FAMILIES: usize> UnsafeUnpin for WriteBatch<'db, K, S, FAMILIES>
where S: UnsafeUnpin,

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, 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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<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