Struct kvdb_rocksdb::Database
source · pub struct Database { /* private fields */ }
Expand description
Key-Value database.
Implementations§
source§impl Database
impl Database
sourcepub fn transaction(&self) -> DBTransaction
pub fn transaction(&self) -> DBTransaction
Helper to create new transaction for this database.
sourcepub fn write(&self, tr: DBTransaction) -> Result<()>
pub fn write(&self, tr: DBTransaction) -> Result<()>
Commit transaction to database.
sourcepub fn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Option<Box<[u8]>>
pub fn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Option<Box<[u8]>>
Get value by partial key. Prefix size should match configured prefix size.
sourcepub fn iter<'a>(
&'a self,
col: u32
) -> impl Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a
pub fn iter<'a>(
&'a self,
col: u32
) -> impl Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a
Iterator over the data in the given database column index. Will hold a lock until the iterator is dropped preventing the database from being closed.
sourcepub fn restore<P: AsRef<Path>>(&self, new_db: P) -> Result<()>
pub fn restore<P: AsRef<Path>>(&self, new_db: P) -> Result<()>
Restore the database from a copy at given path.
sourcepub fn num_columns(&self) -> u32
pub fn num_columns(&self) -> u32
The number of column families in the db.
sourcepub fn remove_last_column(&self) -> Result<()>
pub fn remove_last_column(&self) -> Result<()>
Remove the last column family in the database. The deletion is definitive.
sourcepub fn add_column(&self) -> Result<()>
pub fn add_column(&self) -> Result<()>
Add a new column family to the DB.
sourcepub fn get_statistics(&self) -> HashMap<String, RocksDbStatsValue>
pub fn get_statistics(&self) -> HashMap<String, RocksDbStatsValue>
Get RocksDB statistics.
sourcepub fn try_catch_up_with_primary(&self) -> Result<()>
pub fn try_catch_up_with_primary(&self) -> Result<()>
Try to catch up a secondary instance with the primary by reading as much from the logs as possible.
Guaranteed to have changes up to the the time that try_catch_up_with_primary
is called
if it finishes succesfully.
Blocks until the MANIFEST file and any state changes in the corresponding Write-Ahead-Logs are applied to the secondary instance. If the manifest files are very large this method could take a long time.
If Write-Ahead-Logs have been purged by the primary instance before the secondary is able to open them, the secondary will not be caught up until this function is called again and new Write-Ahead-Logs are identified.
If called while the primary is writing, the catch-up may fail.
If the secondary is unable to catch up because of missing logs, this method fails silently and no error is returned.
Calling this as primary will return an error.
Trait Implementations§
source§impl KeyValueDB for Database
impl KeyValueDB for Database
source§fn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Option<Box<[u8]>>
fn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Option<Box<[u8]>>
source§fn write(&self, transaction: DBTransaction) -> Result<()>
fn write(&self, transaction: DBTransaction) -> Result<()>
source§fn iter<'a>(
&'a self,
col: u32
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>
fn iter<'a>(
&'a self,
col: u32
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>
source§fn iter_with_prefix<'a>(
&'a self,
col: u32,
prefix: &'a [u8]
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>
fn iter_with_prefix<'a>(
&'a self,
col: u32,
prefix: &'a [u8]
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>
source§fn restore(&self, new_db: &str) -> Result<()>
fn restore(&self, new_db: &str) -> Result<()>
source§fn transaction(&self) -> DBTransaction
fn transaction(&self) -> DBTransaction
source§impl MallocSizeOf for Database
impl MallocSizeOf for Database
Auto Trait Implementations§
impl !RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl UnwindSafe for Database
Blanket Implementations§
source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
source§impl<T> MallocSizeOfExt for Twhere
T: MallocSizeOf,
impl<T> MallocSizeOfExt for Twhere
T: MallocSizeOf,
source§fn malloc_size_of(&self) -> usize
fn malloc_size_of(&self) -> usize
source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds. Read moresource§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds. Read moresource§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read moresource§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds. Read moresource§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more