Struct rocksdb::WriteBatch [−][src]
An atomic batch of write operations.
Making an atomic commit of several writes:
use rocksdb::{DB, Options, WriteBatch}; let path = "_path_for_rocksdb_storage1"; { let db = DB::open_default(path).unwrap(); let mut batch = WriteBatch::default(); batch.put(b"my key", b"my value"); batch.put(b"key2", b"value2"); batch.put(b"key3", b"value3"); db.write(batch); // Atomically commits the batch } let _ = DB::destroy(&Options::default(), path);
Implementations
impl WriteBatch
[src]
pub fn len(&self) -> usize
[src]
pub fn size_in_bytes(&self) -> usize
[src]
Return WriteBatch serialized size (in bytes).
pub fn is_empty(&self) -> bool
[src]
pub fn iterate(&self, callbacks: &mut dyn WriteBatchIterator)
[src]
Iterate the put and delete operations within this write batch. Note that
this does not return an Iterator
but instead will invoke the put()
and delete()
member functions of the provided WriteBatchIterator
trait implementation.
pub fn put<K, V>(&mut self, key: K, value: V) where
K: AsRef<[u8]>,
V: AsRef<[u8]>,
[src]
K: AsRef<[u8]>,
V: AsRef<[u8]>,
Insert a value into the database under the given key.
pub fn put_cf<K, V>(&mut self, cf: &ColumnFamily, key: K, value: V) where
K: AsRef<[u8]>,
V: AsRef<[u8]>,
[src]
K: AsRef<[u8]>,
V: AsRef<[u8]>,
pub fn merge<K, V>(&mut self, key: K, value: V) where
K: AsRef<[u8]>,
V: AsRef<[u8]>,
[src]
K: AsRef<[u8]>,
V: AsRef<[u8]>,
pub fn merge_cf<K, V>(&mut self, cf: &ColumnFamily, key: K, value: V) where
K: AsRef<[u8]>,
V: AsRef<[u8]>,
[src]
K: AsRef<[u8]>,
V: AsRef<[u8]>,
pub fn delete<K: AsRef<[u8]>>(&mut self, key: K)
[src]
Removes the database entry for key. Does nothing if the key was not found.
pub fn delete_cf<K: AsRef<[u8]>>(&mut self, cf: &ColumnFamily, key: K)
[src]
pub fn delete_range<K: AsRef<[u8]>>(&mut self, from: K, to: K)
[src]
Remove database entries from start key to end key.
Removes the database entries in the range [“begin_key”, “end_key”), i.e., including “begin_key” and excluding “end_key”. It is not an error if no keys exist in the range [“begin_key”, “end_key”).
pub fn delete_range_cf<K: AsRef<[u8]>>(
&mut self,
cf: &ColumnFamily,
from: K,
to: K
)
[src]
&mut self,
cf: &ColumnFamily,
from: K,
to: K
)
Remove database entries in column family from start key to end key.
Removes the database entries in the range [“begin_key”, “end_key”), i.e., including “begin_key” and excluding “end_key”. It is not an error if no keys exist in the range [“begin_key”, “end_key”).
pub fn clear(&mut self)
[src]
Clear all updates buffered in this batch.
Trait Implementations
impl Default for WriteBatch
[src]
fn default() -> WriteBatch
[src]
impl Drop for WriteBatch
[src]
impl Send for WriteBatch
[src]
Auto Trait Implementations
impl RefUnwindSafe for WriteBatch
impl !Sync for WriteBatch
impl Unpin for WriteBatch
impl UnwindSafe for WriteBatch
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,