Struct raft_engine::LogBatch
source · 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 PartialEq<LogBatch> for LogBatch
impl PartialEq<LogBatch> for LogBatch
source§impl ReactiveBytes for LogBatch
impl ReactiveBytes for LogBatch
impl Eq for LogBatch
impl StructuralEq for LogBatch
impl StructuralPartialEq for LogBatch
Auto Trait Implementations§
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