Skip to content

Commit

Permalink
Kvstore: use bincode serialization (anza-xyz#3385)
Browse files Browse the repository at this point in the history
* use bincode for SSTable serialization; add tests

* Fix bug uncovered in merge algorithm by unit tests

* use bincode in write-ahead-log serialization

* Add helper `Fill` trait for zeroing buffers
  • Loading branch information
mark-solana authored Mar 20, 2019
1 parent 0dc364c commit 13c9d3d
Show file tree
Hide file tree
Showing 3 changed files with 301 additions and 245 deletions.
16 changes: 16 additions & 0 deletions kvstore/src/io_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ pub struct CRCReader<R: Read> {
chunk_size: usize,
}

/// Helper trait to make zeroing buffers easier
pub trait Fill<T> {
fn fill(&mut self, v: T);
}

impl SharedWriter {
pub fn new(buf: Arc<RwLock<Vec<u8>>>) -> SharedWriter {
SharedWriter { buf, pos: 0 }
Expand Down Expand Up @@ -146,6 +151,17 @@ impl<R: Read> CRCReader<R> {
}
}

impl<T> Fill<T> for [T]
where
T: Clone,
{
fn fill(&mut self, v: T) {
for i in self {
*i = v.clone()
}
}
}

impl Deref for MemMap {
type Target = [u8];

Expand Down
Loading

0 comments on commit 13c9d3d

Please sign in to comment.