#embedded #lsm-tree #persistence

rust-speedb

Rust wrapper for speedb embeddable datsabase

4 releases

0.0.6 Jul 13, 2023
0.0.5 Jul 13, 2023
0.0.4 Jul 13, 2023
0.0.3 Jul 13, 2023

#1377 in Database interfaces

Apache-2.0

440KB
8K SLoC

rust-speedb


lib.rs:

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);

Dependencies

~1–5.5MB
~103K SLoC