docs: update solution & starter code documentation for day 2 (#20)

* feat(docs): update day 2 starter code documentation

* feat(docs): update day 2 solution code documentation
This commit is contained in:
Xu
2023-07-11 12:05:40 +08:00
committed by GitHub
parent de7f2ec263
commit a5ac71c99f
4 changed files with 32 additions and 8 deletions

View File

@@ -26,10 +26,14 @@ impl BlockMeta {
pub fn encode_block_meta(block_meta: &[BlockMeta], buf: &mut Vec<u8>) {
let mut estimated_size = 0;
for meta in block_meta {
// The size of offset
estimated_size += std::mem::size_of::<u32>();
// The size of key length
estimated_size += std::mem::size_of::<u16>();
// The size of actual key
estimated_size += meta.first_key.len();
}
// Reserve the space to improve performance, especially when the size of incoming data is large
buf.reserve(estimated_size);
let original_len = buf.len();
for meta in block_meta {