Skip to content

Commit

Permalink
Updates to dub.json for windows build support, README tweaks for newbs (
Browse files Browse the repository at this point in the history
#4)

* refs #2 dub should handle windows and posix library linking, update docs

Docs need to include a few details about building and testing.

* refs #2 Improve rocksdb dependency documentation

* refs #3 Add mods to make example work
  • Loading branch information
truedat101 authored and b1naryth1ef committed Jun 10, 2018
1 parent bad9a55 commit f006b9c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
26 changes: 17 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,48 @@ A straightforward binding to RocksDB v5.0.1 in D-lang.

## Building

You need a valid rocksdb library somewhere your linker can find it.
You need a valid rocksdb library in the root of this project so your linker can find it. It is recommended to use a recent version of rocksdb, tested with

- facebook-rocksdb-v5.12.4 (https://github.com/facebook/rocksdb/archive/v5.12.4.tar.gz)

Note: Windows rocksdb will work and recommendation is to use vcpkg to build rocks first, and copy your rocksdb-shared.dll into the root of the parent project.

## Testing

> dub test
will launch a benchmark, and should be enough to convine one of the functionality and performance.

## Example

```D
import rocksdb;
import std.conv : to;
auto opts = new DBOptions;
opts.createIfMissing = true;
opts.errorIfExists = false;
auto db = new Database(opts, "testdb");
// Put a value into the database
db.put("key", "value");
db.putString("key", "value");
// Get a value out
assert(db.get("key") == "value");
assert(db.getString("key") == "value");
ubyte[] key = ['\x00', '\x00'];
// Delete a value
db.remove("key");
db.remove(key);
// Add values in bulk
auto batch = new WriteBatch;
for (int i = 0; i < 1000; i++) {
batch.put(i.to!string, i.to!string);
batch.putString(i.to!string, i.to!string);
}
db.write(batch);
// Iterate over the DB
auto iter = db.iter();
foreach (key, value; iter) {
db.remove(key);
db.remove(key);
}
destroy(iter);
Expand Down
22 changes: 19 additions & 3 deletions dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@
"Andrei Zbikowski <[email protected]>"
],
"targetType": "library",
"libraries": ["rocksdb"],
"lflags": ["-lrocksdb"]
}
"libs-windows-x86_64": [
"rocksdb-shared"
],
"libs-windows-x86_mscoff": [
"rocksdb-shared"
],
"libs-posix": [
"rocksdb"
],
"lflags-windows-x86_64": [
"-lrocksdb-shared"
],
"lflags-windows-x86_mscoff": [
"-lrocksdb-shared"
],
"lflags-posix": [
"-lrocksdb"
]
}

0 comments on commit f006b9c

Please sign in to comment.