Expand description
Rust wrapper for RocksDB.
§Examples
use rocksdb::{DB, Options};
// NB: db is automatically closed at end of lifetime
let path = "_path_for_rocksdb_storage";
{
let db = DB::open_default(path).unwrap();
db.put(b"my key", b"my value").unwrap();
match db.get(b"my key") {
Ok(Some(value)) => println!("retrieved value {}", String::from_utf8(value).unwrap()),
Ok(None) => println!("value not found"),
Err(e) => println!("operational problem encountered: {}", e),
}
db.delete(b"my key").unwrap();
}
let _ = DB::destroy(&Options::default(), path);
Opening a database and a single column family with custom options:
use rocksdb::{DB, ColumnFamilyDescriptor, Options};
let path = "_path_for_rocksdb_storage_with_cfs";
let mut cf_opts = Options::default();
cf_opts.set_max_write_buffer_number(16);
let cf = ColumnFamilyDescriptor::new("cf1", cf_opts);
let mut db_opts = Options::default();
db_opts.create_missing_column_families(true);
db_opts.create_if_missing(true);
{
let db = DB::open_cf_descriptors(&db_opts, path, vec![cf]).unwrap();
}
let _ = DB::destroy(&db_opts, path);
Re-exports§
pub use crate::compaction_filter::Decision as CompactionDecision;
pub use crate::merge_operator::MergeOperands;
Modules§
- backup
- checkpoint
- Implementation of bindings to RocksDB Checkpoint1 API
- compaction_
filter - merge_
operator - rustic merge operator
Structs§
- Block
Based Options - For configuring block-based file storage.
- Column
Family - An opaque type used to represent a column family. Returned from some functions, and used in others
- Column
Family Descriptor - A descriptor for a RocksDB column family.
- DB
- A RocksDB database.
- DBIterator
- An iterator over a database or column family, with specifiable ranges and direction.
- DBPinnable
Slice - Wrapper around RocksDB PinnableSlice struct.
- DBRaw
Iterator - An iterator over a database or column family, with specifiable ranges and direction.
- DBWAL
Iterator - Iterates the batches of writes since a given sequence number.
- Error
- A simple wrapper round a string, used for errors reported from ffi calls.
- Flush
Options - Optionally wait for the memtable flush to be performed.
- Options
- Database-wide options around performance and behavior.
- Plain
Table Factory Options - Used with DBOptions::set_plain_table_factory. See https://github.com/facebook/rocksdb/wiki/PlainTable-Format.
- Read
Options - Slice
Transform - A SliceTranform is a generic pluggable way of transforming one string to another. Its primary use-case is in configuring rocksdb to store prefix blooms by setting prefix_extractor in ColumnFamilyOptions.
- Snapshot
- A consistent view of the database at the point of creation.
- Write
Batch - An atomic batch of write operations.
- Write
Options - Optionally disable WAL or sync for this write.
Enums§
- Block
Based Index Type - Used by BlockBasedOptions::set_index_type.
- DBCompaction
Style - DBCompression
Type - DBRecovery
Mode - Direction
- Iterator
Mode - Memtable
Factory - Defines the underlying memtable implementation. See https://github.com/facebook/rocksdb/wiki/MemTable for more information.
Traits§
- Write
Batch Iterator - Receives the puts and deletes of a write batch.