Struct ckb_db::db::RocksDB[][src]

pub struct RocksDB { /* fields omitted */ }
Expand description

RocksDB wrapper base on OptimisticTransactionDB

https://github.com/facebook/rocksdb/wiki/Transactions#optimistictransactiondb

Implementations

impl RocksDB[src]

pub fn repair<P: AsRef<Path>>(path: P) -> Result<()>[src]

Repairer does best effort recovery to recover as much data as possible after a disaster without compromising consistency. It does not guarantee bringing the database to a time consistent state. Note: Currently there is a limitation that un-flushed column families will be lost after repair. This would happen even if the DB is in healthy state.

pub fn open(config: &DBConfig, columns: u32) -> Self[src]

Open a database with the given configuration and columns count.

pub fn open_tmp(columns: u32) -> Self[src]

Open a temporary database with the default configuration and columns count.

pub fn prepare_for_bulk_load_open<P: AsRef<Path>>(
    path: P,
    columns: u32
) -> Result<Option<Self>>
[src]

Set appropriate parameters for bulk loading.

pub fn get_pinned(
    &self,
    col: Col,
    key: &[u8]
) -> Result<Option<DBPinnableSlice<'_>>>
[src]

Return the value associated with a key using RocksDB’s PinnableSlice from the given column so as to avoid unnecessary memory copy.

pub fn get_pinned_default(
    &self,
    key: &[u8]
) -> Result<Option<DBPinnableSlice<'_>>>
[src]

Return the value associated with a key using RocksDB’s PinnableSlice from the default column so as to avoid unnecessary memory copy.

pub fn put_default<K, V>(&self, key: K, value: V) -> Result<()> where
    K: AsRef<[u8]>,
    V: AsRef<[u8]>, 
[src]

Insert a value into the database under the given key.

pub fn traverse<F>(&self, col: Col, callback: F) -> Result<()> where
    F: FnMut(&[u8], &[u8]) -> Result<()>, 
[src]

Traverse database column with the given callback function.

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

Set a snapshot at start of transaction by setting set_snapshot=true

pub fn new_write_batch(&self) -> RocksDBWriteBatch[src]

Construct RocksDBWriteBatch with default option.

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

Write batch into transaction db.

pub fn write_sync(&self, batch: &RocksDBWriteBatch) -> Result<()>[src]

WriteOptions set_sync true If true, the write will be flushed from the operating system buffer cache (by calling WritableFile::Sync()) before the write is considered complete. If this flag is true, writes will be slower.

If this flag is false, and the machine crashes, some recent writes may be lost. Note that if it is just the process that crashes (i.e., the machine does not reboot), no writes will be lost even if sync==false.

In other words, a DB write with sync==false has similar crash semantics as the “write()” system call. A DB write with sync==true has similar crash semantics to a “write()” system call followed by “fdatasync()”.

Default: false

pub fn compact_range(
    &self,
    col: Col,
    start: Option<&[u8]>,
    end: Option<&[u8]>
) -> Result<()>
[src]

The begin and end arguments define the key range to be compacted. The behavior varies depending on the compaction style being used by the db. In case of universal and FIFO compaction styles, the begin and end arguments are ignored and all files are compacted. Also, files in each level are compacted and left in the same level. For leveled compaction style, all files containing keys in the given range are compacted to the last level containing files. If either begin or end are NULL, it is taken to mean the key before all keys in the db or the key after all keys respectively.

If more than one thread calls manual compaction, only one will actually schedule it while the other threads will simply wait for the scheduled manual compaction to complete.

CompactRange waits while compaction is performed on the background threads and thus is a blocking call.

pub fn get_snapshot(&self) -> RocksDBSnapshot[src]

Return RocksDBSnapshot.

pub fn inner(&self) -> Arc<OptimisticTransactionDB>[src]

Return rocksdb OptimisticTransactionDB.

pub fn create_cf(&mut self, col: Col) -> Result<()>[src]

Create a new column family for the database.

pub fn drop_cf(&mut self, col: Col) -> Result<()>[src]

Delete column family.

Trait Implementations

impl Clone for RocksDB[src]

fn clone(&self) -> RocksDB[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl DBIterator for RocksDB[src]

fn iter_opt(
    &self,
    col: Col,
    mode: IteratorMode<'_>,
    readopts: &ReadOptions
) -> Result<DBIter<'_>>
[src]

Opens an interator using the provided IteratorMode and ReadOptions. This is used when you want to iterate over a specific ColumnFamily with a modified ReadOptions Read more

fn iter(&self, col: Col, mode: IteratorMode<'_>) -> Result<DBIter<'_>>[src]

Opens an interator using the provided IteratorMode. This is used when you want to iterate over a specific ColumnFamily Read more

Auto Trait Implementations

impl RefUnwindSafe for RocksDB

impl Send for RocksDB

impl Sync for RocksDB

impl Unpin for RocksDB

impl UnwindSafe for RocksDB

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> AsAny for T where
    T: Any

pub fn as_any(&self) -> &(dyn Any + 'static)

TODO(doc): @quake

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V