@@ -5,22 +5,13 @@ mod builder;
|
||||
mod iterator;
|
||||
|
||||
pub use builder::BlockBuilder;
|
||||
/// You may want to check `bytes::BufMut` out when manipulating continuous chunks of memory
|
||||
use bytes::Bytes;
|
||||
pub use iterator::BlockIterator;
|
||||
|
||||
/// A block is the smallest unit of read and caching in LSM tree.
|
||||
/// It is a collection of sorted key-value pairs.
|
||||
/// The `actual` storage format is as below (After `Block::encode`):
|
||||
///
|
||||
/// ----------------------------------------------------------------------------------------------------
|
||||
/// | Data Section | Offset Section | Extra |
|
||||
/// ----------------------------------------------------------------------------------------------------
|
||||
/// | Entry #1 | Entry #2 | ... | Entry #N | Offset #1 | Offset #2 | ... | Offset #N | num_of_elements |
|
||||
/// ----------------------------------------------------------------------------------------------------
|
||||
/// A block is the smallest unit of read and caching in LSM tree. It is a collection of sorted key-value pairs.
|
||||
pub struct Block {
|
||||
data: Vec<u8>,
|
||||
offsets: Vec<u16>,
|
||||
pub(crate) data: Vec<u8>,
|
||||
pub(crate) offsets: Vec<u16>,
|
||||
}
|
||||
|
||||
impl Block {
|
||||
@@ -35,6 +26,3 @@ impl Block {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
@@ -11,8 +11,8 @@ pub struct BlockIterator {
|
||||
block: Arc<Block>,
|
||||
/// The current key, empty represents the iterator is invalid
|
||||
key: Vec<u8>,
|
||||
/// The corresponding value, can be empty
|
||||
value: Vec<u8>,
|
||||
/// the value range from the block
|
||||
value_range: (usize, usize),
|
||||
/// Current index of the key-value pair, should be in range of [0, num_of_elements)
|
||||
idx: usize,
|
||||
}
|
||||
@@ -22,7 +22,7 @@ impl BlockIterator {
|
||||
Self {
|
||||
block,
|
||||
key: Vec::new(),
|
||||
value: Vec::new(),
|
||||
value_range: (0, 0),
|
||||
idx: 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
//! Please copy `mini-lsm/src/block/tests.rs` here so that you can run tests.
|
||||
@@ -159,6 +159,3 @@ impl SsTable {
|
||||
self.id
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
//! Please copy `mini-lsm/src/table/tests.rs` here so that you can run tests.
|
||||
Reference in New Issue
Block a user