Files
mini_lsm/mini-lsm-starter/src/table/builder.rs
Xu a5ac71c99f 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
2023-07-11 00:05:40 -04:00

52 lines
1.5 KiB
Rust

#![allow(unused_variables)] // TODO(you): remove this lint after implementing this mod
#![allow(dead_code)] // TODO(you): remove this lint after implementing this mod
use std::path::Path;
use std::sync::Arc;
use anyhow::Result;
use super::{BlockMeta, SsTable};
use crate::lsm_storage::BlockCache;
/// Builds an SSTable from key-value pairs.
pub struct SsTableBuilder {
pub(super) meta: Vec<BlockMeta>,
// Add other fields you need.
}
impl SsTableBuilder {
/// Create a builder based on target block size.
pub fn new(block_size: usize) -> Self {
unimplemented!()
}
/// Adds a key-value pair to SSTable.
/// Note: You should split a new block when the current block is full.(`std::mem::replace` may be of help here)
pub fn add(&mut self, key: &[u8], value: &[u8]) {
unimplemented!()
}
/// Get the estimated size of the SSTable.
/// Since the data blocks contain much more data than meta blocks, just return the size of data blocks here.
pub fn estimated_size(&self) -> usize {
unimplemented!()
}
/// Builds the SSTable and writes it to the given path. No need to actually write to disk until
/// chapter 4 block cache.
pub fn build(
self,
id: usize,
block_cache: Option<Arc<BlockCache>>,
path: impl AsRef<Path>,
) -> Result<SsTable> {
unimplemented!()
}
#[cfg(test)]
pub(crate) fn build_for_test(self, path: impl AsRef<Path>) -> Result<SsTable> {
self.build(0, None, path)
}
}