Skip to content

Instantly share code, notes, and snippets.

@wspeirs wspeirs/lib.rs
Created Sep 11, 2016

Embed
What would you like to do?
let mut wal_file = try!(OpenOptions::new().read(true).write(true).create(true).open(tree_file_path.to_owned() + ".wal"));
// if we have a WAL file, just replay it into the mem_tree
if try!(wal_file.metadata()).len() != 0 {
let mut buff = vec![0; node_size];
while true {
match wal_file.read_exact(&mut buff) {
Ok(_) => {
let k = try!(decode(&buff[0..max_key_size]));
let v = try!(decode(&buff[max_key_size..max_value_size]));
mem_tree.insert(k,v);
},
Err(e) => if e.kind() == ErrorKind::UnexpectedEof {
break
} else {
return Err(From::from(e));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.