docs: add comments & hints for day one starter and reference code (#18)

* feat(docs): Improve/Add comments & some hints for day one starter code

* feat(docs): Add comments for day one solution code

* feat(docs): Add figure for block storage format in starter code (block.rs)
This commit is contained in:
Xu
2023-07-11 12:05:34 +08:00
committed by GitHub
parent e13ce4f5ff
commit de7f2ec263
5 changed files with 27 additions and 3 deletions

View File

@@ -5,21 +5,32 @@ 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.
/// 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 |
/// ----------------------------------------------------------------------------------------------------
pub struct Block {
data: Vec<u8>,
offsets: Vec<u16>,
}
impl Block {
/// Encode the internal data to the data layout illustrated in the tutorial
/// Note: You may want to recheck if any of the expected field is missing from your output
pub fn encode(&self) -> Bytes {
unimplemented!()
}
/// Decode from the data layout, transform the input `data` to a single `Block`
pub fn decode(data: &[u8]) -> Self {
unimplemented!()
}