pub type DBWithThreadMode<T> = DBCommon<T, DBWithThreadModeInner>;Expand description
A type alias to RocksDB database.
See crate level documentation for a simple usage example.
See DBCommon for full list of methods.
Aliased Type§
pub struct DBWithThreadMode<T> { /* private fields */ }Implementations§
Source§impl<T: ThreadMode> DBWithThreadMode<T>
Methods of DBWithThreadMode.
impl<T: ThreadMode> DBWithThreadMode<T>
Methods of DBWithThreadMode.
Sourcepub fn open_default<P: AsRef<Path>>(path: P) -> Result<Self, Error>
pub fn open_default<P: AsRef<Path>>(path: P) -> Result<Self, Error>
Opens a database with default options.
Sourcepub fn open<P: AsRef<Path>>(opts: &Options, path: P) -> Result<Self, Error>
pub fn open<P: AsRef<Path>>(opts: &Options, path: P) -> Result<Self, Error>
Opens the database with the specified options.
Sourcepub fn open_for_read_only<P: AsRef<Path>>(
opts: &Options,
path: P,
error_if_log_file_exist: bool,
) -> Result<Self, Error>
pub fn open_for_read_only<P: AsRef<Path>>( opts: &Options, path: P, error_if_log_file_exist: bool, ) -> Result<Self, Error>
Opens the database for read only with the specified options.
Sourcepub fn open_as_secondary<P: AsRef<Path>>(
opts: &Options,
primary_path: P,
secondary_path: P,
) -> Result<Self, Error>
pub fn open_as_secondary<P: AsRef<Path>>( opts: &Options, primary_path: P, secondary_path: P, ) -> Result<Self, Error>
Opens the database as a secondary.
Sourcepub fn open_with_ttl<P: AsRef<Path>>(
opts: &Options,
path: P,
ttl: Duration,
) -> Result<Self, Error>
pub fn open_with_ttl<P: AsRef<Path>>( opts: &Options, path: P, ttl: Duration, ) -> Result<Self, Error>
Opens the database with a Time to Live compaction filter.
This applies the given ttl to all column families created without an explicit TTL.
See DB::open_cf_descriptors_with_ttl for more control over individual column family TTLs.
RocksDB stores the TTL as a 32-bit second count, so a ttl longer than
i32::MAX seconds (about 68 years) is clamped to that maximum rather
than wrapping.
Sourcepub fn open_cf_with_ttl<P, I, N>(
opts: &Options,
path: P,
cfs: I,
ttl: Duration,
) -> Result<Self, Error>
pub fn open_cf_with_ttl<P, I, N>( opts: &Options, path: P, cfs: I, ttl: Duration, ) -> Result<Self, Error>
Opens the database with a Time to Live compaction filter and column family names.
Column families opened using this function will be created with default Options.
Sourcepub fn open_cf_descriptors_with_ttl<P, I>(
opts: &Options,
path: P,
cfs: I,
ttl: Duration,
) -> Result<Self, Error>
pub fn open_cf_descriptors_with_ttl<P, I>( opts: &Options, path: P, cfs: I, ttl: Duration, ) -> Result<Self, Error>
Opens a database with the given database with a Time to Live compaction filter and column family descriptors.
Applies the provided ttl as the default TTL for all column families.
Column families will inherit this TTL by default, unless their descriptor explicitly
sets a different TTL using ColumnFamilyTtl::Duration or opts out using ColumnFamilyTtl::Disabled.
NOTE: The default column family is opened with Options::default() unless
explicitly configured within the cfs iterator.
To customize the default column family’s options, include a ColumnFamilyDescriptor
with the name “default” in the cfs iterator.
If you want to open default cf with different options, set them explicitly in cfs.
Sourcepub fn open_cf_and_trim_history<P, I, N>(
opts: &Options,
path: P,
cfs: I,
trim_ts: &[u8],
) -> Result<Self, Error>
pub fn open_cf_and_trim_history<P, I, N>( opts: &Options, path: P, cfs: I, trim_ts: &[u8], ) -> Result<Self, Error>
Opens the database and drops everything written after trim_ts.
Column families opened using this function will be created with default
Options. See open_cf_descriptors_and_trim_history.
§Errors
Sourcepub fn open_cf_descriptors_and_trim_history<P, I>(
opts: &Options,
path: P,
cfs: I,
trim_ts: &[u8],
) -> Result<Self, Error>
pub fn open_cf_descriptors_and_trim_history<P, I>( opts: &Options, path: P, cfs: I, trim_ts: &[u8], ) -> Result<Self, Error>
Opens the database and drops everything written after trim_ts, given column
family descriptors.
This is for recovering a column family that uses user-defined timestamps, where
writes past a known good point have to be undone before anything reads them.
Entries with a timestamp greater than trim_ts are gone once this returns.
trim_ts is compared with the column family’s comparator, so it has to be
encoded the way that comparator expects. Column families without user-defined
timestamps are left alone.
The trim is permanent, so open a copy first if the discarded writes still matter.
RocksDB marks the underlying API experimental and subject to change.
NOTE: The default column family is opened with Options::default() unless
explicitly configured within the cfs iterator. A column family that uses
user-defined timestamps carries its comparator in its own options, so it has to
be named here with those options even when it is the default one. Opening it
with Options::default() instead fails with a comparator mismatch.
§Errors
Returns the RocksDB error if the database cannot be opened, which includes leaving out a column family that exists on disk. Also errors if a column family name contains an interior NUL byte, or if the directory cannot be created.
Sourcepub fn open_cf<P, I, N>(opts: &Options, path: P, cfs: I) -> Result<Self, Error>
pub fn open_cf<P, I, N>(opts: &Options, path: P, cfs: I) -> Result<Self, Error>
Opens a database with the given database options and column family names.
Column families opened using this function will be created with default Options.
Sourcepub fn open_cf_with_opts<P, I, N>(
opts: &Options,
path: P,
cfs: I,
) -> Result<Self, Error>
pub fn open_cf_with_opts<P, I, N>( opts: &Options, path: P, cfs: I, ) -> Result<Self, Error>
Opens a database with the given database options and column family names.
Column families opened using given Options.
Sourcepub fn open_cf_for_read_only<P, I, N>(
opts: &Options,
path: P,
cfs: I,
error_if_log_file_exist: bool,
) -> Result<Self, Error>
pub fn open_cf_for_read_only<P, I, N>( opts: &Options, path: P, cfs: I, error_if_log_file_exist: bool, ) -> Result<Self, Error>
Opens a database for read only with the given database options and column family names.
NOTE: default column family is opened with Options::default().
If you want to open default cf with different options, set them explicitly in cfs.
Sourcepub fn open_cf_with_opts_for_read_only<P, I, N>(
db_opts: &Options,
path: P,
cfs: I,
error_if_log_file_exist: bool,
) -> Result<Self, Error>
pub fn open_cf_with_opts_for_read_only<P, I, N>( db_opts: &Options, path: P, cfs: I, error_if_log_file_exist: bool, ) -> Result<Self, Error>
Opens a database for read only with the given database options and column family names.
NOTE: default column family is opened with Options::default().
If you want to open default cf with different options, set them explicitly in cfs.
Sourcepub fn open_cf_descriptors_read_only<P, I>(
opts: &Options,
path: P,
cfs: I,
error_if_log_file_exist: bool,
) -> Result<Self, Error>
pub fn open_cf_descriptors_read_only<P, I>( opts: &Options, path: P, cfs: I, error_if_log_file_exist: bool, ) -> Result<Self, Error>
Opens a database for ready only with the given database options and
column family descriptors.
NOTE: default column family is opened with Options::default().
If you want to open default cf with different options, set them explicitly in cfs.
Sourcepub fn open_cf_as_secondary<P, I, N>(
opts: &Options,
primary_path: P,
secondary_path: P,
cfs: I,
) -> Result<Self, Error>
pub fn open_cf_as_secondary<P, I, N>( opts: &Options, primary_path: P, secondary_path: P, cfs: I, ) -> Result<Self, Error>
Opens the database as a secondary with the given database options and column family names.
NOTE: default column family is opened with Options::default().
If you want to open default cf with different options, set them explicitly in cfs.
Sourcepub fn open_cf_descriptors_as_secondary<P, I>(
opts: &Options,
path: P,
secondary_path: P,
cfs: I,
) -> Result<Self, Error>
pub fn open_cf_descriptors_as_secondary<P, I>( opts: &Options, path: P, secondary_path: P, cfs: I, ) -> Result<Self, Error>
Opens the database as a secondary with the given database options and
column family descriptors.
NOTE: default column family is opened with Options::default().
If you want to open default cf with different options, set them explicitly in cfs.
Sourcepub fn open_cf_descriptors<P, I>(
opts: &Options,
path: P,
cfs: I,
) -> Result<Self, Error>
pub fn open_cf_descriptors<P, I>( opts: &Options, path: P, cfs: I, ) -> Result<Self, Error>
Opens a database with the given database options and column family descriptors.
NOTE: default column family is opened with Options::default().
If you want to open default cf with different options, set them explicitly in cfs.
Sourcepub fn delete_range_cf_opt<K: AsRef<[u8]>>(
&self,
cf: &impl AsColumnFamilyRef,
from: K,
to: K,
writeopts: &WriteOptions,
) -> Result<(), Error>
pub fn delete_range_cf_opt<K: AsRef<[u8]>>( &self, cf: &impl AsColumnFamilyRef, from: K, to: K, writeopts: &WriteOptions, ) -> Result<(), Error>
Removes the database entries in the range ["from", "to") using given write options.
Sourcepub fn delete_range_cf<K: AsRef<[u8]>>(
&self,
cf: &impl AsColumnFamilyRef,
from: K,
to: K,
) -> Result<(), Error>
pub fn delete_range_cf<K: AsRef<[u8]>>( &self, cf: &impl AsColumnFamilyRef, from: K, to: K, ) -> Result<(), Error>
Removes the database entries in the range ["from", "to") using default write options.