Struct tetsy_kvdb_rocksdb::Database[][src]

pub struct Database { /* fields omitted */ }

Key-Value database.

Implementations

impl Database[src]

pub fn open(config: &DatabaseConfig, path: &str) -> Result<Database>[src]

Open database file. Creates if it does not exist.

Safety

The number of config.columns must not be zero.

pub fn transaction(&self) -> DBTransaction[src]

Helper to create new transaction for this database.

pub fn write(&self, tr: DBTransaction) -> Result<()>[src]

Commit transaction to database.

pub fn get(&self, col: u32, key: &[u8]) -> Result<Option<DBValue>>[src]

Get value by key.

pub fn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Option<Box<[u8]>>[src]

Get value by partial key. Prefix size should match configured prefix size.

pub fn iter<'a>(
    &'a self,
    col: u32
) -> impl Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a
[src]

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.

pub fn restore(&self, new_db: &str) -> Result<()>[src]

Restore the database from a copy at given path.

pub fn num_columns(&self) -> u32[src]

The number of column families in the db.

pub fn num_keys(&self, col: u32) -> Result<u64>[src]

The number of keys in a column (estimated).

pub fn remove_last_column(&self) -> Result<()>[src]

Remove the last column family in the database. The deletion is definitive.

pub fn add_column(&self) -> Result<()>[src]

Add a new column family to the DB.

pub fn get_statistics(&self) -> HashMap<String, RocksDbStatsValue>[src]

Get RocksDB statistics.

pub fn try_catch_up_with_primary(&self) -> Result<()>[src]

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

impl KeyValueDB for Database[src]

impl MallocSizeOf for Database[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erased for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> MallocSizeOfExt for T where
    T: MallocSizeOf
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.