Skip to content

Commit

Permalink
using rocksdb rust wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
skariyania committed Jan 26, 2024
1 parent a3ba0cc commit a8f33a6
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 0 deletions.
168 changes: 168 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ resolver = "2"
exclude = ["tutorials"]

members = [
"example/rocksdb-example",
"workspace/add_one",
"workspace/adder",
"workspace/adder_ws",
Expand Down
9 changes: 9 additions & 0 deletions example/rocksdb-example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "rocksdb-example"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rocksdb = "0.21.0"
23 changes: 23 additions & 0 deletions example/rocksdb-example/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use rocksdb::{Options, DB};

fn main() {
println!("Hello, world!");
let path = "rocksdb-example/data";
{
let db = DB::open_default(path).unwrap();
db.put(b"name", b"sahil").unwrap();
for i in 0..1000 {
db.put(String::from(i.to_string()), b"sahil").unwrap();
if i % 100 == 0 {
println!("{} records inserted ..", i);
}
}
match db.get(b"name") {
Ok(Some(value)) => println!("found value: {}", String::from_utf8(value).unwrap()),
Ok(None) => println!("value not found"),
Err(e) => println!("operational problem encountered: {}", e),
}
db.delete(b"name").unwrap();
}
let _ = DB::destroy(&Options::default(), path);
}
4 changes: 4 additions & 0 deletions rust-learnings.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@
"[toml]": {
"editor.defaultFormatter": "tamasfe.even-better-toml"
},
"cSpell.words": [
"rocksdb",
"saka"
],
}
}

0 comments on commit a8f33a6

Please sign in to comment.