Expand description
Rust wrapper for RocksDB.
§Examples
use ckb_rocksdb::prelude::*;
// 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 {}", 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 ckb_rocksdb::{prelude::*, ColumnFamilyDescriptor};
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();
Re-exports§
pub extern crate librocksdb_sys as ffi;
pub use crate::column_family::ColumnFamilyDescriptor;
pub use crate::compaction_filter::Decision as CompactionDecision;
pub use crate::merge_operator::MergeOperands;
Modules§
- backup
- checkpoint
- column_
family - compaction_
filter - compaction_
filter_ factory - ffi_
util - merge_
operator - rustic merge operator
- ops
- prelude
Structs§
- Block
Based Options - For configuring block-based file storage.
- Cache
- Column
Family - An opaque type used to represent a column family. Returned from some functions, and used in others
- Compact
Options - Cuckoo
Table Options - Configuration of cuckoo-based storage.
- DB
- A RocksDB database.
- DBIterator
- An iterator over a database or column family, with specifiable ranges and direction.
- DBPath
- Represents a path where sst files can be put into
- DBPinnable
Slice - Wrapper around RocksDB PinnableSlice struct.
- DBRaw
Iterator - DBVector
- Vector of bytes stored in the database.
- DBWithTTL
- Env
- An Env is an interface used by the rocksdb implementation to access operating system functionality like the filesystem etc. Callers may wish to provide a custom Env object when opening a database to get fine gain control; e.g., to rate limit file system operations.
- Error
- A simple wrapper round a string, used for errors reported from ffi calls.
- Fifo
Compact Options - Flush
Options - Optionally wait for the memtable flush to be performed.
- Full
Options - Ingest
External File Options - For configuring external files ingestion.
- Optimistic
Transaction - Optimistic
TransactionDB - A optimistic transaction database.
- Optimistic
Transaction Options - Optimistic
Transaction Snapshot - 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
OnlyDB - Read
Options - SecondaryDB
- Secondary
Open Descriptor - 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.
- SstFile
Writer - SstFileWriter is used to create sst files that can be added to database later All keys in files generated by SstFileWriter will have sequence number = 0.
- TTLOpen
Descriptor - TemporaryDB
Path - Ensures that DB::Destroy is called and the directory is deleted for this database when TemporaryDBPath is dropped.
- Transaction
- TransactionDB
- A transaction database.
- TransactionDB
Options - Transaction
Options - Transaction
Snapshot - Universal
Compact Options - 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.
- Bottommost
Level Compaction - DBCompaction
Style - DBCompression
Type - DBRecovery
Mode - Data
Block Index Type - Used by BlockBasedOptions::set_data_block_index_type.
- Direction
- Iterator
Mode - KeyEncoding
Type - Used in
PlainTableFactoryOptions
. - LogLevel
- Memtable
Factory - Defines the underlying memtable implementation. See https://github.com/facebook/rocksdb/wiki/MemTable for more information.
- Universal
Compaction Stop Style
Traits§
- Const
Handle - Handle
- Provides access to underlying handles for database operations