Struct rocksdb::DBCommon

pub struct DBCommon<T, D>
where T: ThreadMode, D: DBInner,
{ /* private fields */ }
Expand description

A helper type to implement some common methods for DBWithThreadMode and OptimisticTransactionDB.

Implementations§

§

impl<T> DBCommon<T, DBWithThreadModeInner>
where T: ThreadMode,

Methods of DBWithThreadMode.

pub fn open_default<P>( path: P, ) -> Result<DBCommon<T, DBWithThreadModeInner>, Error>
where P: AsRef<Path>,

Opens a database with default options.

pub fn open<P>( opts: &Options, path: P, ) -> Result<DBCommon<T, DBWithThreadModeInner>, Error>
where P: AsRef<Path>,

Opens the database with the specified options.

pub fn open_for_read_only<P>( opts: &Options, path: P, error_if_log_file_exist: bool, ) -> Result<DBCommon<T, DBWithThreadModeInner>, Error>
where P: AsRef<Path>,

Opens the database for read only with the specified options.

pub fn open_as_secondary<P>( opts: &Options, primary_path: P, secondary_path: P, ) -> Result<DBCommon<T, DBWithThreadModeInner>, Error>
where P: AsRef<Path>,

Opens the database as a secondary.

pub fn open_with_ttl<P>( opts: &Options, path: P, ttl: Duration, ) -> Result<DBCommon<T, DBWithThreadModeInner>, Error>
where P: AsRef<Path>,

Opens the database with a Time to Live compaction filter.

pub fn open_cf_with_ttl<P, I, N>( opts: &Options, path: P, cfs: I, ttl: Duration, ) -> Result<DBCommon<T, DBWithThreadModeInner>, Error>
where P: AsRef<Path>, I: IntoIterator<Item = N>, N: AsRef<str>,

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.

pub fn open_cf_descriptors_with_ttl<P, I>( opts: &Options, path: P, cfs: I, ttl: Duration, ) -> Result<DBCommon<T, DBWithThreadModeInner>, Error>

Opens a database with the given database with a Time to Live compaction filter and column family descriptors.

pub fn open_cf<P, I, N>( opts: &Options, path: P, cfs: I, ) -> Result<DBCommon<T, DBWithThreadModeInner>, Error>
where P: AsRef<Path>, I: IntoIterator<Item = N>, N: AsRef<str>,

Opens a database with the given database options and column family names.

Column families opened using this function will be created with default Options.

pub fn open_cf_with_opts<P, I, N>( opts: &Options, path: P, cfs: I, ) -> Result<DBCommon<T, DBWithThreadModeInner>, Error>
where P: AsRef<Path>, I: IntoIterator<Item = (N, Options)>, N: AsRef<str>,

Opens a database with the given database options and column family names.

Column families opened using given Options.

pub fn open_cf_for_read_only<P, I, N>( opts: &Options, path: P, cfs: I, error_if_log_file_exist: bool, ) -> Result<DBCommon<T, DBWithThreadModeInner>, Error>
where P: AsRef<Path>, I: IntoIterator<Item = N>, N: AsRef<str>,

Opens a database for read only with the given database options and column family names.

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<DBCommon<T, DBWithThreadModeInner>, Error>
where P: AsRef<Path>, I: IntoIterator<Item = (N, Options)>, N: AsRef<str>,

Opens a database for read only with the given database options and column family names.

pub fn open_cf_descriptors_read_only<P, I>( opts: &Options, path: P, cfs: I, error_if_log_file_exist: bool, ) -> Result<DBCommon<T, DBWithThreadModeInner>, Error>

Opens a database for ready only with the given database options and column family descriptors.

pub fn open_cf_as_secondary<P, I, N>( opts: &Options, primary_path: P, secondary_path: P, cfs: I, ) -> Result<DBCommon<T, DBWithThreadModeInner>, Error>
where P: AsRef<Path>, I: IntoIterator<Item = N>, N: AsRef<str>,

Opens the database as a secondary with the given database options and column family names.

pub fn open_cf_descriptors_as_secondary<P, I>( opts: &Options, path: P, secondary_path: P, cfs: I, ) -> Result<DBCommon<T, DBWithThreadModeInner>, Error>

Opens the database as a secondary with the given database options and column family descriptors.

pub fn open_cf_descriptors<P, I>( opts: &Options, path: P, cfs: I, ) -> Result<DBCommon<T, DBWithThreadModeInner>, Error>

Opens a database with the given database options and column family descriptors.

pub fn delete_range_cf_opt<K>( &self, cf: &impl AsColumnFamilyRef, from: K, to: K, writeopts: &WriteOptions, ) -> Result<(), Error>
where K: AsRef<[u8]>,

Removes the database entries in the range ["from", "to") using given write options.

pub fn delete_range_cf<K>( &self, cf: &impl AsColumnFamilyRef, from: K, to: K, ) -> Result<(), Error>
where K: AsRef<[u8]>,

Removes the database entries in the range ["from", "to") using default write options.

pub fn write_opt( &self, batch: WriteBatchWithTransaction<false>, writeopts: &WriteOptions, ) -> Result<(), Error>

pub fn write( &self, batch: WriteBatchWithTransaction<false>, ) -> Result<(), Error>

pub fn write_without_wal( &self, batch: WriteBatchWithTransaction<false>, ) -> Result<(), Error>

§

impl<T, D> DBCommon<T, D>
where T: ThreadMode, D: DBInner,

Common methods of DBWithThreadMode and OptimisticTransactionDB.

pub fn list_cf<P>(opts: &Options, path: P) -> Result<Vec<String>, Error>
where P: AsRef<Path>,

pub fn destroy<P>(opts: &Options, path: P) -> Result<(), Error>
where P: AsRef<Path>,

pub fn repair<P>(opts: &Options, path: P) -> Result<(), Error>
where P: AsRef<Path>,

pub fn path(&self) -> &Path

pub fn flush_wal(&self, sync: bool) -> Result<(), Error>

Flushes the WAL buffer. If sync is set to true, also syncs the data to disk.

pub fn flush_opt(&self, flushopts: &FlushOptions) -> Result<(), Error>

Flushes database memtables to SST files on the disk.

pub fn flush(&self) -> Result<(), Error>

Flushes database memtables to SST files on the disk using default options.

pub fn flush_cf_opt( &self, cf: &impl AsColumnFamilyRef, flushopts: &FlushOptions, ) -> Result<(), Error>

Flushes database memtables to SST files on the disk for a given column family.

pub fn flush_cfs_opt( &self, cfs: &[&impl AsColumnFamilyRef], opts: &FlushOptions, ) -> Result<(), Error>

Flushes multiple column families.

If atomic flush is not enabled, it is equivalent to calling flush_cf multiple times. If atomic flush is enabled, it will flush all column families specified in cfs up to the latest sequence number at the time when flush is requested.

pub fn flush_cf(&self, cf: &impl AsColumnFamilyRef) -> Result<(), Error>

Flushes database memtables to SST files on the disk for a given column family using default options.

pub fn get_opt<K>( &self, key: K, readopts: &ReadOptions, ) -> Result<Option<Vec<u8>>, Error>
where K: AsRef<[u8]>,

Return the bytes associated with a key value with read options. If you only intend to use the vector returned temporarily, consider using get_pinned_opt to avoid unnecessary memory copy.

pub fn get<K>(&self, key: K) -> Result<Option<Vec<u8>>, Error>
where K: AsRef<[u8]>,

Return the bytes associated with a key value. If you only intend to use the vector returned temporarily, consider using get_pinned to avoid unnecessary memory copy.

pub fn get_cf_opt<K>( &self, cf: &impl AsColumnFamilyRef, key: K, readopts: &ReadOptions, ) -> Result<Option<Vec<u8>>, Error>
where K: AsRef<[u8]>,

Return the bytes associated with a key value and the given column family with read options. If you only intend to use the vector returned temporarily, consider using get_pinned_cf_opt to avoid unnecessary memory.

pub fn get_cf<K>( &self, cf: &impl AsColumnFamilyRef, key: K, ) -> Result<Option<Vec<u8>>, Error>
where K: AsRef<[u8]>,

Return the bytes associated with a key value and the given column family. If you only intend to use the vector returned temporarily, consider using get_pinned_cf to avoid unnecessary memory.

pub fn get_pinned_opt<K>( &self, key: K, readopts: &ReadOptions, ) -> Result<Option<DBPinnableSlice<'_>>, Error>
where K: AsRef<[u8]>,

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

pub fn get_pinned<K>( &self, key: K, ) -> Result<Option<DBPinnableSlice<'_>>, Error>
where K: AsRef<[u8]>,

Return the value associated with a key using RocksDB’s PinnableSlice so as to avoid unnecessary memory copy. Similar to get_pinned_opt but leverages default options.

pub fn get_pinned_cf_opt<K>( &self, cf: &impl AsColumnFamilyRef, key: K, readopts: &ReadOptions, ) -> Result<Option<DBPinnableSlice<'_>>, Error>
where K: AsRef<[u8]>,

Return the value associated with a key using RocksDB’s PinnableSlice so as to avoid unnecessary memory copy. Similar to get_pinned_opt but allows specifying ColumnFamily

pub fn get_pinned_cf<K>( &self, cf: &impl AsColumnFamilyRef, key: K, ) -> Result<Option<DBPinnableSlice<'_>>, Error>
where K: AsRef<[u8]>,

Return the value associated with a key using RocksDB’s PinnableSlice so as to avoid unnecessary memory copy. Similar to get_pinned_cf_opt but leverages default options.

pub fn multi_get<K, I>(&self, keys: I) -> Vec<Result<Option<Vec<u8>>, Error>>
where K: AsRef<[u8]>, I: IntoIterator<Item = K>,

Return the values associated with the given keys.

pub fn multi_get_opt<K, I>( &self, keys: I, readopts: &ReadOptions, ) -> Vec<Result<Option<Vec<u8>>, Error>>
where K: AsRef<[u8]>, I: IntoIterator<Item = K>,

Return the values associated with the given keys using read options.

pub fn multi_get_cf<'a, 'b, K, I, W>( &'a self, keys: I, ) -> Vec<Result<Option<Vec<u8>>, Error>>
where 'b: 'a, K: AsRef<[u8]>, I: IntoIterator<Item = (&'b W, K)>, W: 'b + AsColumnFamilyRef,

Return the values associated with the given keys and column families.

pub fn multi_get_cf_opt<'a, 'b, K, I, W>( &'a self, keys: I, readopts: &ReadOptions, ) -> Vec<Result<Option<Vec<u8>>, Error>>
where 'b: 'a, K: AsRef<[u8]>, I: IntoIterator<Item = (&'b W, K)>, W: 'b + AsColumnFamilyRef,

Return the values associated with the given keys and column families using read options.

pub fn batched_multi_get_cf<'a, K, I>( &self, cf: &impl AsColumnFamilyRef, keys: I, sorted_input: bool, ) -> Vec<Result<Option<DBPinnableSlice<'_>>, Error>>
where K: AsRef<[u8]> + 'a + ?Sized, I: IntoIterator<Item = &'a K>,

Return the values associated with the given keys and the specified column family where internally the read requests are processed in batch if block-based table SST format is used. It is a more optimized version of multi_get_cf.

pub fn batched_multi_get_cf_opt<'a, K, I>( &self, cf: &impl AsColumnFamilyRef, keys: I, sorted_input: bool, readopts: &ReadOptions, ) -> Vec<Result<Option<DBPinnableSlice<'_>>, Error>>
where K: AsRef<[u8]> + 'a + ?Sized, I: IntoIterator<Item = &'a K>,

Return the values associated with the given keys and the specified column family where internally the read requests are processed in batch if block-based table SST format is used. It is a more optimized version of multi_get_cf_opt.

pub fn key_may_exist<K>(&self, key: K) -> bool
where K: AsRef<[u8]>,

Returns false if the given key definitely doesn’t exist in the database, otherwise returns true. This function uses default ReadOptions.

pub fn key_may_exist_opt<K>(&self, key: K, readopts: &ReadOptions) -> bool
where K: AsRef<[u8]>,

Returns false if the given key definitely doesn’t exist in the database, otherwise returns true.

pub fn key_may_exist_cf<K>(&self, cf: &impl AsColumnFamilyRef, key: K) -> bool
where K: AsRef<[u8]>,

Returns false if the given key definitely doesn’t exist in the specified column family, otherwise returns true. This function uses default ReadOptions.

pub fn key_may_exist_cf_opt<K>( &self, cf: &impl AsColumnFamilyRef, key: K, readopts: &ReadOptions, ) -> bool
where K: AsRef<[u8]>,

Returns false if the given key definitely doesn’t exist in the specified column family, otherwise returns true.

pub fn key_may_exist_cf_opt_value<K>( &self, cf: &impl AsColumnFamilyRef, key: K, readopts: &ReadOptions, ) -> (bool, Option<CSlice>)
where K: AsRef<[u8]>,

If the key definitely does not exist in the database, then this method returns (false, None), else (true, None) if it may. If the key is found in memory, then it returns (true, Some<CSlice>).

This check is potentially lighter-weight than calling get(). One way to make this lighter weight is to avoid doing any IOs.

pub fn iterator<'a, 'b>( &'a self, mode: IteratorMode<'_>, ) -> DBIteratorWithThreadMode<'b, DBCommon<T, D>>
where 'a: 'b,

pub fn iterator_opt<'a, 'b>( &'a self, mode: IteratorMode<'_>, readopts: ReadOptions, ) -> DBIteratorWithThreadMode<'b, DBCommon<T, D>>
where 'a: 'b,

pub fn iterator_cf_opt<'a, 'b>( &'a self, cf_handle: &impl AsColumnFamilyRef, readopts: ReadOptions, mode: IteratorMode<'_>, ) -> DBIteratorWithThreadMode<'b, DBCommon<T, D>>
where 'a: 'b,

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

pub fn full_iterator<'a, 'b>( &'a self, mode: IteratorMode<'_>, ) -> DBIteratorWithThreadMode<'b, DBCommon<T, D>>
where 'a: 'b,

Opens an iterator with set_total_order_seek enabled. This must be used to iterate across prefixes when set_memtable_factory has been called with a Hash-based implementation.

pub fn prefix_iterator<'a, 'b, P>( &'a self, prefix: P, ) -> DBIteratorWithThreadMode<'b, DBCommon<T, D>>
where 'a: 'b, P: AsRef<[u8]>,

pub fn iterator_cf<'a, 'b>( &'a self, cf_handle: &impl AsColumnFamilyRef, mode: IteratorMode<'_>, ) -> DBIteratorWithThreadMode<'b, DBCommon<T, D>>
where 'a: 'b,

pub fn full_iterator_cf<'a, 'b>( &'a self, cf_handle: &impl AsColumnFamilyRef, mode: IteratorMode<'_>, ) -> DBIteratorWithThreadMode<'b, DBCommon<T, D>>
where 'a: 'b,

pub fn prefix_iterator_cf<'a, P>( &'a self, cf_handle: &impl AsColumnFamilyRef, prefix: P, ) -> DBIteratorWithThreadMode<'a, DBCommon<T, D>>
where P: AsRef<[u8]>,

pub fn raw_iterator<'a, 'b>( &'a self, ) -> DBRawIteratorWithThreadMode<'b, DBCommon<T, D>>
where 'a: 'b,

Opens a raw iterator over the database, using the default read options

pub fn raw_iterator_cf<'a, 'b>( &'a self, cf_handle: &impl AsColumnFamilyRef, ) -> DBRawIteratorWithThreadMode<'b, DBCommon<T, D>>
where 'a: 'b,

Opens a raw iterator over the given column family, using the default read options

pub fn raw_iterator_opt<'a, 'b>( &'a self, readopts: ReadOptions, ) -> DBRawIteratorWithThreadMode<'b, DBCommon<T, D>>
where 'a: 'b,

Opens a raw iterator over the database, using the given read options

pub fn raw_iterator_cf_opt<'a, 'b>( &'a self, cf_handle: &impl AsColumnFamilyRef, readopts: ReadOptions, ) -> DBRawIteratorWithThreadMode<'b, DBCommon<T, D>>
where 'a: 'b,

Opens a raw iterator over the given column family, using the given read options

pub fn snapshot(&self) -> SnapshotWithThreadMode<'_, DBCommon<T, D>>

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

pub fn put_cf_opt<K, V>( &self, cf: &impl AsColumnFamilyRef, key: K, value: V, writeopts: &WriteOptions, ) -> Result<(), Error>
where K: AsRef<[u8]>, V: AsRef<[u8]>,

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

pub fn merge_cf_opt<K, V>( &self, cf: &impl AsColumnFamilyRef, key: K, value: V, writeopts: &WriteOptions, ) -> Result<(), Error>
where K: AsRef<[u8]>, V: AsRef<[u8]>,

pub fn delete_opt<K>( &self, key: K, writeopts: &WriteOptions, ) -> Result<(), Error>
where K: AsRef<[u8]>,

pub fn delete_cf_opt<K>( &self, cf: &impl AsColumnFamilyRef, key: K, writeopts: &WriteOptions, ) -> Result<(), Error>
where K: AsRef<[u8]>,

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

pub fn put_cf<K, V>( &self, cf: &impl AsColumnFamilyRef, key: K, value: V, ) -> Result<(), Error>
where K: AsRef<[u8]>, V: AsRef<[u8]>,

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

pub fn merge_cf<K, V>( &self, cf: &impl AsColumnFamilyRef, key: K, value: V, ) -> Result<(), Error>
where K: AsRef<[u8]>, V: AsRef<[u8]>,

pub fn delete<K>(&self, key: K) -> Result<(), Error>
where K: AsRef<[u8]>,

pub fn delete_cf<K>( &self, cf: &impl AsColumnFamilyRef, key: K, ) -> Result<(), Error>
where K: AsRef<[u8]>,

pub fn compact_range<S, E>(&self, start: Option<S>, end: Option<E>)
where S: AsRef<[u8]>, E: AsRef<[u8]>,

Runs a manual compaction on the Range of keys given. This is not likely to be needed for typical usage.

pub fn compact_range_opt<S, E>( &self, start: Option<S>, end: Option<E>, opts: &CompactOptions, )
where S: AsRef<[u8]>, E: AsRef<[u8]>,

Same as compact_range but with custom options.

pub fn compact_range_cf<S, E>( &self, cf: &impl AsColumnFamilyRef, start: Option<S>, end: Option<E>, )
where S: AsRef<[u8]>, E: AsRef<[u8]>,

Runs a manual compaction on the Range of keys given on the given column family. This is not likely to be needed for typical usage.

pub fn compact_range_cf_opt<S, E>( &self, cf: &impl AsColumnFamilyRef, start: Option<S>, end: Option<E>, opts: &CompactOptions, )
where S: AsRef<[u8]>, E: AsRef<[u8]>,

Same as compact_range_cf but with custom options.

pub fn wait_for_compact( &self, opts: &WaitForCompactOptions, ) -> Result<(), Error>

Wait for all flush and compactions jobs to finish. Jobs to wait include the unscheduled (queued, but not scheduled yet).

NOTE: This may also never return if there’s sufficient ongoing writes that keeps flush and compaction going without stopping. The user would have to cease all the writes to DB to make this eventually return in a stable state. The user may also use timeout option in WaitForCompactOptions to make this stop waiting and return when timeout expires.

pub fn set_options(&self, opts: &[(&str, &str)]) -> Result<(), Error>

pub fn set_options_cf( &self, cf: &impl AsColumnFamilyRef, opts: &[(&str, &str)], ) -> Result<(), Error>

pub fn property_value( &self, name: impl CStrLike, ) -> Result<Option<String>, Error>

Retrieves a RocksDB property by name.

Full list of properties could be find here.

pub fn property_value_cf( &self, cf: &impl AsColumnFamilyRef, name: impl CStrLike, ) -> Result<Option<String>, Error>

Retrieves a RocksDB property by name, for a specific column family.

Full list of properties could be find here.

pub fn property_int_value( &self, name: impl CStrLike, ) -> Result<Option<u64>, Error>

Retrieves a RocksDB property and casts it to an integer.

Full list of properties that return int values could be find here.

pub fn property_int_value_cf( &self, cf: &impl AsColumnFamilyRef, name: impl CStrLike, ) -> Result<Option<u64>, Error>

Retrieves a RocksDB property for a specific column family and casts it to an integer.

Full list of properties that return int values could be find here.

pub fn latest_sequence_number(&self) -> u64

The sequence number of the most recent transaction.

pub fn get_updates_since(&self, seq_number: u64) -> Result<DBWALIterator, Error>

Iterate over batches of write operations since a given sequence.

Produce an iterator that will provide the batches of write operations that have occurred since the given sequence (see latest_sequence_number()). Use the provided iterator to retrieve each (u64, WriteBatch) tuple, and then gather the individual puts and deletes using the WriteBatch::iterate() function.

Calling get_updates_since() with a sequence number that is out of bounds will return an error.

pub fn try_catch_up_with_primary(&self) -> Result<(), Error>

Tries to catch up with the primary by reading as much as possible from the log files.

pub fn ingest_external_file<P>(&self, paths: Vec<P>) -> Result<(), Error>
where P: AsRef<Path>,

Loads a list of external SST files created with SstFileWriter into the DB with default opts

pub fn ingest_external_file_opts<P>( &self, opts: &IngestExternalFileOptions, paths: Vec<P>, ) -> Result<(), Error>
where P: AsRef<Path>,

Loads a list of external SST files created with SstFileWriter into the DB

pub fn ingest_external_file_cf<P>( &self, cf: &impl AsColumnFamilyRef, paths: Vec<P>, ) -> Result<(), Error>
where P: AsRef<Path>,

Loads a list of external SST files created with SstFileWriter into the DB for given Column Family with default opts

pub fn ingest_external_file_cf_opts<P>( &self, cf: &impl AsColumnFamilyRef, opts: &IngestExternalFileOptions, paths: Vec<P>, ) -> Result<(), Error>
where P: AsRef<Path>,

Loads a list of external SST files created with SstFileWriter into the DB for given Column Family

pub fn get_column_family_metadata(&self) -> ColumnFamilyMetaData

Obtains the LSM-tree meta data of the default column family of the DB

pub fn get_column_family_metadata_cf( &self, cf: &impl AsColumnFamilyRef, ) -> ColumnFamilyMetaData

Obtains the LSM-tree meta data of the specified column family of the DB

pub fn live_files(&self) -> Result<Vec<LiveFile>, Error>

Returns a list of all table files with their level, start key and end key

pub fn delete_file_in_range<K>(&self, from: K, to: K) -> Result<(), Error>
where K: AsRef<[u8]>,

Delete sst files whose keys are entirely in the given range.

Could leave some keys in the range which are in files which are not entirely in the range.

Note: L0 files are left regardless of whether they’re in the range.

SnapshotWithThreadModes before the delete might not see the data in the given range.

pub fn delete_file_in_range_cf<K>( &self, cf: &impl AsColumnFamilyRef, from: K, to: K, ) -> Result<(), Error>
where K: AsRef<[u8]>,

Same as delete_file_in_range but only for specific column family

pub fn cancel_all_background_work(&self, wait: bool)

Request stopping background work, if wait is true wait until it’s done.

§

impl<I> DBCommon<SingleThreaded, I>
where I: DBInner,

pub fn create_cf<N>(&mut self, name: N, opts: &Options) -> Result<(), Error>
where N: AsRef<str>,

Creates column family with given name and options

pub fn drop_cf(&mut self, name: &str) -> Result<(), Error>

Drops the column family with the given name

pub fn cf_handle(&self, name: &str) -> Option<&ColumnFamily>

Returns the underlying column family handle

§

impl<I> DBCommon<MultiThreaded, I>
where I: DBInner,

pub fn create_cf<N>(&self, name: N, opts: &Options) -> Result<(), Error>
where N: AsRef<str>,

Creates column family with given name and options

pub fn drop_cf(&self, name: &str) -> Result<(), Error>

Drops the column family with the given name by internally locking the inner column family map. This avoids needing &mut self reference

pub fn cf_handle(&self, name: &str) -> Option<Arc<BoundColumnFamily<'_>>>

Returns the underlying column family handle

§

impl<T> DBCommon<T, OptimisticTransactionDBInner>
where T: ThreadMode,

Methods of OptimisticTransactionDB.

pub fn open_default<P>( path: P, ) -> Result<DBCommon<T, OptimisticTransactionDBInner>, Error>
where P: AsRef<Path>,

Opens a database with default options.

pub fn open<P>( opts: &Options, path: P, ) -> Result<DBCommon<T, OptimisticTransactionDBInner>, Error>
where P: AsRef<Path>,

Opens the database with the specified options.

pub fn open_cf<P, I, N>( opts: &Options, path: P, cfs: I, ) -> Result<DBCommon<T, OptimisticTransactionDBInner>, Error>
where P: AsRef<Path>, I: IntoIterator<Item = N>, N: AsRef<str>,

Opens a database with the given database options and column family names.

Column families opened using this function will be created with default Options.

pub fn open_cf_descriptors<P, I>( opts: &Options, path: P, cfs: I, ) -> Result<DBCommon<T, OptimisticTransactionDBInner>, Error>

Opens a database with the given database options and column family descriptors.

pub fn transaction( &self, ) -> Transaction<'_, DBCommon<T, OptimisticTransactionDBInner>>

Creates a transaction with default options.

pub fn transaction_opt( &self, writeopts: &WriteOptions, otxn_opts: &OptimisticTransactionOptions, ) -> Transaction<'_, DBCommon<T, OptimisticTransactionDBInner>>

Creates a transaction with default options.

pub fn write_opt( &self, batch: WriteBatchWithTransaction<true>, writeopts: &WriteOptions, ) -> Result<(), Error>

pub fn write(&self, batch: WriteBatchWithTransaction<true>) -> Result<(), Error>

pub fn write_without_wal( &self, batch: WriteBatchWithTransaction<true>, ) -> Result<(), Error>

Trait Implementations§

§

impl<T, D> DBAccess for DBCommon<T, D>
where T: ThreadMode, D: DBInner,

§

unsafe fn create_snapshot(&self) -> *const rocksdb_snapshot_t

§

unsafe fn release_snapshot(&self, snapshot: *const rocksdb_snapshot_t)

§

unsafe fn create_iterator( &self, readopts: &ReadOptions, ) -> *mut rocksdb_iterator_t

§

unsafe fn create_iterator_cf( &self, cf_handle: *mut rocksdb_column_family_handle_t, readopts: &ReadOptions, ) -> *mut rocksdb_iterator_t

§

fn get_opt<K>( &self, key: K, readopts: &ReadOptions, ) -> Result<Option<Vec<u8>>, Error>
where K: AsRef<[u8]>,

§

fn get_cf_opt<K>( &self, cf: &impl AsColumnFamilyRef, key: K, readopts: &ReadOptions, ) -> Result<Option<Vec<u8>>, Error>
where K: AsRef<[u8]>,

§

fn get_pinned_opt<K>( &self, key: K, readopts: &ReadOptions, ) -> Result<Option<DBPinnableSlice<'_>>, Error>
where K: AsRef<[u8]>,

§

fn get_pinned_cf_opt<K>( &self, cf: &impl AsColumnFamilyRef, key: K, readopts: &ReadOptions, ) -> Result<Option<DBPinnableSlice<'_>>, Error>
where K: AsRef<[u8]>,

§

fn multi_get_opt<K, Iter>( &self, keys: Iter, readopts: &ReadOptions, ) -> Vec<Result<Option<Vec<u8>>, Error>>
where K: AsRef<[u8]>, Iter: IntoIterator<Item = K>,

§

fn multi_get_cf_opt<'b, K, Iter, W>( &self, keys_cf: Iter, readopts: &ReadOptions, ) -> Vec<Result<Option<Vec<u8>>, Error>>
where K: AsRef<[u8]>, Iter: IntoIterator<Item = (&'b W, K)>, W: AsColumnFamilyRef + 'b,

§

impl<T, I> Debug for DBCommon<T, I>
where T: ThreadMode, I: DBInner,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<T, I> Drop for DBCommon<T, I>
where T: ThreadMode, I: DBInner,

§

fn drop(&mut self)

Executes the destructor for this type. Read more
§

impl<T, I> Send for DBCommon<T, I>
where T: ThreadMode + Send, I: DBInner,

§

impl<T, I> Sync for DBCommon<T, I>
where T: ThreadMode, I: DBInner,

Auto Trait Implementations§

§

impl<T, D> Freeze for DBCommon<T, D>
where D: Freeze, T: Freeze,

§

impl<T, D> RefUnwindSafe for DBCommon<T, D>

§

impl<T, D> Unpin for DBCommon<T, D>
where D: Unpin, T: Unpin,

§

impl<T, D> UnwindSafe for DBCommon<T, D>
where D: UnwindSafe, T: UnwindSafe,

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> 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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.