pub struct LogBatch { /* private fields */ }
Expand description
A batch of log items.
Encoding format:
- header = { u56 len | u8 compression type | u64 item offset }
- entries = { [entry..] (optionally compressed) | crc32 }
- footer = { item batch }
Size restriction:
- The total size of log entries must not exceed 2GiB.
Error will be raised if a to-be-added log item cannot fit within those limits.
Implementations§
Source§impl LogBatch
impl LogBatch
Sourcepub fn with_capacity(cap: usize) -> Self
pub fn with_capacity(cap: usize) -> Self
Creates a new, empty log batch capable of holding at least cap
log
items.
Sourcepub fn merge(&mut self, rhs: &mut Self) -> Result<()>
pub fn merge(&mut self, rhs: &mut Self) -> Result<()>
Moves all log items of rhs
into Self
, leaving rhs
empty.
Sourcepub fn add_entries<M: MessageExt>(
&mut self,
region_id: u64,
entries: &[M::Entry],
) -> Result<()>
pub fn add_entries<M: MessageExt>( &mut self, region_id: u64, entries: &[M::Entry], ) -> Result<()>
Adds some protobuf log entries into the log batch.
Sourcepub fn add_command(&mut self, region_id: u64, cmd: Command)
pub fn add_command(&mut self, region_id: u64, cmd: Command)
Adds a command into the log batch.
Sourcepub fn delete(&mut self, region_id: u64, key: Vec<u8>)
pub fn delete(&mut self, region_id: u64, key: Vec<u8>)
Removes a key value pair from the log batch.
Sourcepub fn put_message<S: Message>(
&mut self,
region_id: u64,
key: Vec<u8>,
s: &S,
) -> Result<()>
pub fn put_message<S: Message>( &mut self, region_id: u64, key: Vec<u8>, s: &S, ) -> Result<()>
Adds a protobuf key value pair into the log batch.
Sourcepub fn put(
&mut self,
region_id: u64,
key: Vec<u8>,
value: Vec<u8>,
) -> Result<()>
pub fn put( &mut self, region_id: u64, key: Vec<u8>, value: Vec<u8>, ) -> Result<()>
Adds a key value pair into the log batch.
Sourcepub fn approximate_size(&self) -> usize
pub fn approximate_size(&self) -> usize
Returns approximate encoded size of this log batch. Might be larger than the actual size.
Trait Implementations§
Source§impl ReactiveBytes for LogBatch
impl ReactiveBytes for LogBatch
impl Eq for LogBatch
impl StructuralPartialEq for LogBatch
Auto Trait Implementations§
impl Freeze for LogBatch
impl RefUnwindSafe for LogBatch
impl Send for LogBatch
impl Sync for LogBatch
impl Unpin for LogBatch
impl UnwindSafe for LogBatch
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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