Skip to content

Commit

Permalink
GH #9 - Replace MD5 checksum on blob with a safe hasher
Browse files Browse the repository at this point in the history
- Replace MD5 with Blake2b with 32 bytes (256 bits) digest output.
- To be more scalable on multi-core processor, move checksum
  calculation from the WAL thread to client threads.
- Update examples/simple to store larger values (8KB).
  • Loading branch information
tatsuya6502 committed May 24, 2017
1 parent 7094351 commit 6ab9623
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 117 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ build = "build.rs"
[build-dependencies]

[dependencies]
blake2-rfc = "0.2.17"
byteorder = "1.0.0"
data-encoding = "2.0.0-rc.1"
generic-array = "0.7.2"
lazy_static = "0.2.2"
md-5 = "0.4.3"
promising-future = "0.2.4"
rmp-serde = "0.13.1"
rocksdb = "0.6.0"
Expand Down
6 changes: 4 additions & 2 deletions examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ fn main() {
let brick_id = brick::add_brick(brick_name);

let put_op = |brick_id: brick::BrickId, key_str: &str, key: &[u8], value: &[u8]| {
brick::put(brick_id, key.to_vec(), value.to_vec())
let mut large_value = vec![0; 8 * 1024];
large_value[..value.len()].copy_from_slice(value);
brick::put(brick_id, key.to_vec(), large_value)
.expect(&format!("Failed to put a key {}", key_str));
};

let get_op = |brick_id: brick::BrickId, key_str: &str, key: &[u8], value: &[u8]| {
let val = brick::get(brick_id, key).expect(&format!("Failed to get a key {}", key_str));
assert_eq!(value.to_vec(), val.unwrap());
assert_eq!(value, &val.unwrap()[..value.len()]);
};

do_ops(brick_id, NUM_THREADS, NUM_KEYS_PER_THREAD, "put", put_op);
Expand Down
Loading

0 comments on commit 6ab9623

Please sign in to comment.