ckb_db::db

Struct RocksDB

Source
pub struct RocksDB { /* private fields */ }
Expand description

Implementations§

Source§

impl RocksDB

Source

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

Open a database with the given configuration and columns count.

Source

pub fn open_in<P: AsRef<Path>>(path: P, columns: u32) -> Self

Open a database in the given directory with the default configuration and columns count.

Source

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

Set appropriate parameters for bulk loading.

Source

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

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

Source

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

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

Source

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

Insert a value into the database under the given key.

Source

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

Traverse database column with the given callback function.

Source

pub fn traverse<F>( &self, col: Col, callback: &mut F, mode: IteratorMode<'_>, limit: usize, ) -> Result<(usize, Vec<u8>)>
where F: FnMut(&[u8], &[u8]) -> Result<()>,

Traverse database column with the given callback function.

Source

pub fn transaction(&self) -> RocksDBTransaction

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

Source

pub fn new_write_batch(&self) -> RocksDBWriteBatch

Construct RocksDBWriteBatch with default option.

Source

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

Write batch into transaction db.

Source

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

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

Source

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

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.

Source

pub fn get_snapshot(&self) -> RocksDBSnapshot

Return RocksDBSnapshot.

Source

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

Return rocksdb OptimisticTransactionDB.

Source

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

Create a new column family for the database.

Source

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

Delete column family.

Trait Implementations§

Source§

impl Clone for RocksDB

Source§

fn clone(&self) -> RocksDB

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl DBIterator for RocksDB

Source§

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

Opens an iterator using the provided IteratorMode and ReadOptions. This is used when you want to iterate over a specific ColumnFamily with a modified ReadOptions
Source§

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

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

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

Cast to trait Any
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T