pub struct RocksDB { /* private fields */ }
Expand description
RocksDB wrapper base on OptimisticTransactionDB
https://github.com/facebook/rocksdb/wiki/Transactions#optimistictransactiondb
Implementations§
Source§impl RocksDB
impl RocksDB
Sourcepub fn open(config: &DBConfig, columns: u32) -> Self
pub fn open(config: &DBConfig, columns: u32) -> Self
Open a database with the given configuration and columns count.
Sourcepub fn open_in<P: AsRef<Path>>(path: P, columns: u32) -> Self
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.
Sourcepub fn prepare_for_bulk_load_open<P: AsRef<Path>>(
path: P,
columns: u32,
) -> Result<Option<Self>>
pub fn prepare_for_bulk_load_open<P: AsRef<Path>>( path: P, columns: u32, ) -> Result<Option<Self>>
Set appropriate parameters for bulk loading.
Sourcepub fn get_pinned(
&self,
col: Col,
key: &[u8],
) -> Result<Option<DBPinnableSlice<'_>>>
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.
Sourcepub fn get_pinned_default(
&self,
key: &[u8],
) -> Result<Option<DBPinnableSlice<'_>>>
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.
Sourcepub fn put_default<K, V>(&self, key: K, value: V) -> Result<()>
pub fn put_default<K, V>(&self, key: K, value: V) -> Result<()>
Insert a value into the database under the given key.
Sourcepub fn full_traverse<F>(&self, col: Col, callback: &mut F) -> Result<()>
pub fn full_traverse<F>(&self, col: Col, callback: &mut F) -> Result<()>
Traverse database column with the given callback function.
Sourcepub fn traverse<F>(
&self,
col: Col,
callback: &mut F,
mode: IteratorMode<'_>,
limit: usize,
) -> Result<(usize, Vec<u8>)>
pub fn traverse<F>( &self, col: Col, callback: &mut F, mode: IteratorMode<'_>, limit: usize, ) -> Result<(usize, Vec<u8>)>
Traverse database column with the given callback function.
Sourcepub fn transaction(&self) -> RocksDBTransaction
pub fn transaction(&self) -> RocksDBTransaction
Set a snapshot at start of transaction by setting set_snapshot=true
Sourcepub fn new_write_batch(&self) -> RocksDBWriteBatch
pub fn new_write_batch(&self) -> RocksDBWriteBatch
Construct RocksDBWriteBatch
with default option.
Sourcepub fn write(&self, batch: &RocksDBWriteBatch) -> Result<()>
pub fn write(&self, batch: &RocksDBWriteBatch) -> Result<()>
Write batch into transaction db.
Sourcepub fn write_sync(&self, batch: &RocksDBWriteBatch) -> Result<()>
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
Sourcepub fn compact_range(
&self,
col: Col,
start: Option<&[u8]>,
end: Option<&[u8]>,
) -> Result<()>
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.
Sourcepub fn get_snapshot(&self) -> RocksDBSnapshot
pub fn get_snapshot(&self) -> RocksDBSnapshot
Return RocksDBSnapshot
.
Sourcepub fn inner(&self) -> Arc<OptimisticTransactionDB>
pub fn inner(&self) -> Arc<OptimisticTransactionDB>
Return rocksdb OptimisticTransactionDB
.
Trait Implementations§
Source§impl DBIterator for RocksDB
impl DBIterator for RocksDB
Source§fn iter_opt(
&self,
col: Col,
mode: IteratorMode<'_>,
readopts: &ReadOptions,
) -> Result<DBIter<'_>>
fn iter_opt( &self, col: Col, mode: IteratorMode<'_>, readopts: &ReadOptions, ) -> Result<DBIter<'_>>
Auto Trait Implementations§
impl Freeze for RocksDB
impl RefUnwindSafe for RocksDB
impl Send for RocksDB
impl Sync for RocksDB
impl Unpin for RocksDB
impl UnwindSafe for RocksDB
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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