pub struct DB { /* private fields */ }
Expand description
This DB is a schematized RocksDB wrapper where all data passed in and out are typed according to
Schema
s.
Implementations§
Source§impl DB
impl DB
Sourcepub fn open(
path: impl AsRef<Path>,
name: &'static str,
column_families: impl IntoIterator<Item = impl Into<String>>,
db_opts: &Options,
) -> Result<Self>
pub fn open( path: impl AsRef<Path>, name: &'static str, column_families: impl IntoIterator<Item = impl Into<String>>, db_opts: &Options, ) -> Result<Self>
Opens a database backed by RocksDB, using the provided column family names and default column family options.
Sourcepub fn open_with_cfds(
db_opts: &Options,
path: impl AsRef<Path>,
name: &'static str,
cfds: impl IntoIterator<Item = ColumnFamilyDescriptor>,
) -> Result<DB>
pub fn open_with_cfds( db_opts: &Options, path: impl AsRef<Path>, name: &'static str, cfds: impl IntoIterator<Item = ColumnFamilyDescriptor>, ) -> Result<DB>
Open RocksDB with the provided column family descriptors. This allows to configure options for each column family.
Sourcepub fn open_cf_readonly(
opts: &Options,
path: impl AsRef<Path>,
name: &'static str,
cfs: Vec<ColumnFamilyName>,
) -> Result<DB>
pub fn open_cf_readonly( opts: &Options, path: impl AsRef<Path>, name: &'static str, cfs: Vec<ColumnFamilyName>, ) -> Result<DB>
Open db in readonly mode. This db is completely static, so any writes that occur on the primary after it has been opened will not be visible to the readonly instance.
Sourcepub fn open_cf_as_secondary<P: AsRef<Path>>(
opts: &Options,
primary_path: P,
secondary_path: P,
name: &'static str,
cfs: Vec<ColumnFamilyName>,
) -> Result<DB>
pub fn open_cf_as_secondary<P: AsRef<Path>>( opts: &Options, primary_path: P, secondary_path: P, name: &'static str, cfs: Vec<ColumnFamilyName>, ) -> Result<DB>
Open db in secondary mode. A secondary db is does not support writes, but can be dynamically caught up to the primary instance by a manual call. See https://github.com/facebook/rocksdb/wiki/Read-only-and-Secondary-instances for more details.
Sourcepub fn get<S: Schema>(
&self,
schema_key: &impl KeyCodec<S>,
) -> Result<Option<S::Value>>
pub fn get<S: Schema>( &self, schema_key: &impl KeyCodec<S>, ) -> Result<Option<S::Value>>
Reads single record by key.
Sourcepub fn put<S: Schema>(
&self,
key: &impl KeyCodec<S>,
value: &impl ValueCodec<S>,
) -> Result<()>
pub fn put<S: Schema>( &self, key: &impl KeyCodec<S>, value: &impl ValueCodec<S>, ) -> Result<()>
Writes single record.
Sourcepub fn iter<S: Schema>(&self) -> Result<SchemaIterator<'_, S>>
pub fn iter<S: Schema>(&self) -> Result<SchemaIterator<'_, S>>
Returns a forward SchemaIterator
on a certain schema with the default read options.
Sourcepub fn iter_with_opts<S: Schema>(
&self,
opts: ReadOptions,
) -> Result<SchemaIterator<'_, S>>
pub fn iter_with_opts<S: Schema>( &self, opts: ReadOptions, ) -> Result<SchemaIterator<'_, S>>
Returns a forward SchemaIterator
on a certain schema with the provided read options.
Sourcepub fn rev_iter<S: Schema>(&self) -> Result<SchemaIterator<'_, S>>
pub fn rev_iter<S: Schema>(&self) -> Result<SchemaIterator<'_, S>>
Returns a backward SchemaIterator
on a certain schema with the default read options.
Sourcepub fn rev_iter_with_opts<S: Schema>(
&self,
opts: ReadOptions,
) -> Result<SchemaIterator<'_, S>>
pub fn rev_iter_with_opts<S: Schema>( &self, opts: ReadOptions, ) -> Result<SchemaIterator<'_, S>>
Returns a backward SchemaIterator
on a certain schema with the provided read options.
Sourcepub fn write_schemas(&self, batch: SchemaBatch) -> Result<()>
pub fn write_schemas(&self, batch: SchemaBatch) -> Result<()>
Writes a group of records wrapped in a SchemaBatch
.
Sourcepub fn flush_cf(&self, cf_name: &str) -> Result<()>
pub fn flush_cf(&self, cf_name: &str) -> Result<()>
Flushes MemTable data.
This is only used for testing get_approximate_sizes_cf
in unit tests.