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]) -> Result<Option<DBValue>>
pub fn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Result<Option<DBValue>>
Get value by partial key. Prefix size should match configured prefix size.
sourcepub fn iter<'a>(
&'a self,
col: u32
) -> impl Iterator<Item = Result<DBKeyValue>> + 'a
pub fn iter<'a>( &'a self, col: u32 ) -> impl Iterator<Item = Result<DBKeyValue>> + '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 num_columns(&self) -> u32
pub fn num_columns(&self) -> u32
The number of column families in the db.
sourcepub fn remove_last_column(&mut self) -> Result<()>
pub fn remove_last_column(&mut self) -> Result<()>
Remove the last column family in the database. The deletion is definitive.
sourcepub fn add_column(&mut self) -> Result<()>
pub fn add_column(&mut 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.