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: Vec<ColumnFamilyName>,
db_opts: Options
) -> Result<Self>
pub fn open( path: impl AsRef<Path>, name: &'static str, column_families: Vec<ColumnFamilyName>, db_opts: Options ) -> Result<Self>
Create db with all the column families provided if it doesn’t exist at
path
; Otherwise, try to open it with all the column families.
sourcepub fn open_readonly(
path: impl AsRef<Path>,
name: &'static str,
column_families: Vec<ColumnFamilyName>,
db_opts: Options
) -> Result<Self>
pub fn open_readonly( path: impl AsRef<Path>, name: &'static str, column_families: Vec<ColumnFamilyName>, db_opts: Options ) -> Result<Self>
Open db in readonly mode
Note that this still assumes there’s only one process that opens the
same DB. See open_as_secondary
sourcepub fn get<S: Schema>(&self, schema_key: &S::Key) -> Result<Option<S::Value>>
pub fn get<S: Schema>(&self, schema_key: &S::Key) -> Result<Option<S::Value>>
Reads single record by key.
sourcepub fn put<S: Schema>(&self, key: &S::Key, value: &S::Value) -> Result<()>
pub fn put<S: Schema>(&self, key: &S::Key, value: &S::Value) -> Result<()>
Writes single record.
sourcepub fn range_delete<S, SK>(&self, begin: &SK, end: &SK) -> Result<()>where
S: Schema,
SK: SeekKeyCodec<S>,
pub fn range_delete<S, SK>(&self, begin: &SK, end: &SK) -> Result<()>where
S: Schema,
SK: SeekKeyCodec<S>,
Delete all keys in range [begin, end).
SK
has to be an explicit type parameter since
https://github.com/rust-lang/rust/issues/44721
sourcepub fn iter<S: Schema>(
&self,
opts: ReadOptions
) -> Result<SchemaIterator<'_, S>>
pub fn iter<S: Schema>( &self, opts: ReadOptions ) -> Result<SchemaIterator<'_, S>>
Returns a forward SchemaIterator
on a certain schema.
sourcepub fn rev_iter<S: Schema>(
&self,
opts: ReadOptions
) -> Result<SchemaIterator<'_, S>>
pub fn rev_iter<S: Schema>( &self, opts: ReadOptions ) -> Result<SchemaIterator<'_, S>>
Returns a backward SchemaIterator
on a certain schema.
sourcepub fn write_schemas(&self, batch: SchemaBatch, fast_write: bool) -> Result<()>
pub fn write_schemas(&self, batch: SchemaBatch, fast_write: bool) -> Result<()>
Writes a group of records wrapped in a SchemaBatch
.
sourcepub fn flush_all(&self, sync: bool) -> Result<()>
pub fn flush_all(&self, sync: bool) -> Result<()>
Flushes all memtable data. This is only used for testing
get_approximate_sizes_cf
in unit tests.