Trait engine_traits::write_batch::WriteBatch [−][src]
Batches of multiple writes that are committed atomically
Each write batch consists of a series of commands: put, delete delete_range, and their column-family-specific equivalents.
Because write batches are atomic, once written to disk all their effects are visible as if all other writes in the system were written either before or after the batch. This includes range deletes.
The exact strategy used by WriteBatch is up to the implementation. RocksDB though seems to serialize the writes to an in-memory buffer, and then write the whole serialized batch to disk at once.
Write batches may be reused after being written. In that case they write exactly the same data as previously, Replacing any keys that may have changed in between the two batch writes.
Commands issued to write batches can be rolled back prior to being committed
by use of save points. At any point in the life of a write batch a save
point can be recorded. Any number of save points can be recorded to a stack.
Calling rollback_to_save_point
reverts all commands issued since the last
save point, and pops the save point from the stack.
Required methods
fn with_capacity(e: &E, cap: usize) -> Self
[src]
Create a WriteBatch with a given command capacity
fn write_opt(&self, opts: &WriteOptions) -> Result<()>
[src]
Commit the WriteBatch to disk with the given options
fn data_size(&self) -> usize
[src]
The data size of a write batch
This is necessarily engine-dependent. In RocksDB though it appears to represent the byte length of all write commands in the batch, as serialized in memory, prior to being written to disk.
fn count(&self) -> usize
[src]
The number of commands in this batch
fn is_empty(&self) -> bool
[src]
Whether any commands have been issued to this batch
fn should_write_to_engine(&self) -> bool
[src]
Whether the number of commands exceeds WRITE_BATCH_MAX_KEYS
If so, the write
method should be called.
fn clear(&mut self)
[src]
Clears the WriteBatch of all commands
It may be reused afterward as an empty batch.
fn set_save_point(&mut self)
[src]
Push a save point onto the save point stack
fn pop_save_point(&mut self) -> Result<()>
[src]
Pop a save point from the save point stack
This has no effect on the commands already issued to the write batch
fn rollback_to_save_point(&mut self) -> Result<()>
[src]
Revert all commands issued since the last save point
Additionally pops the last save point from the save point stack.