Files
mini_lsm/mini-lsm-starter/src/table/builder.rs

50 lines
1.3 KiB
Rust
Raw Normal View History

#![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
pub fn add(&mut self, key: &[u8], value: &[u8]) {
unimplemented!()
}
/// Get the estimated size of the SSTable.
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)
}
}