Crate rocksdb

source ·
Expand description

Rust wrapper for RocksDB.

Examples

 use rocksdb::DB;
 // NB: db is automatically closed at end of lifetime
 let db = DB::open_default("path/for/rocksdb/storage").unwrap();
 db.put(b"my key", b"my value");
 match db.get(b"my key") {
    Ok(Some(value)) => println!("retrieved value {}", value.to_utf8().unwrap()),
    Ok(None) => println!("value not found"),
    Err(e) => println!("operational problem encountered: {}", e),
 }
 db.delete(b"my key").unwrap();

Opening a database and a single column family with custom options:

use rocksdb::{DB, ColumnFamilyDescriptor, Options};
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/for/rocksdb/storage_with_cfs", vec![cf]).unwrap();

Re-exports

pub use compaction_filter::Decision as CompactionDecision;
pub use merge_operator::MergeOperands;

Modules

Structs

For configuring block-based file storage.
An opaque type used to represent a column family. Returned from some functions, and used in others
A descriptor for a RocksDB column family.
A RocksDB database.
An iterator over a database or column family, with specifiable ranges and direction.
An iterator over a database or column family, with specifiable ranges and direction.
Vector of bytes stored in the database.
A simple wrapper round a string, used for errors reported from ffi calls.
Database-wide options around performance and behavior.
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.
A consistent view of the database at the point of creation.
An atomic batch of write operations.
Optionally disable WAL or sync for this write.

Enums

Used by BlockBasedOptions::set_index_type.
Defines the underlying memtable implementation. See https://github.com/facebook/rocksdb/wiki/MemTable for more information.

Functions