@@ -1,3 +1,5 @@
|
|||||||
|
#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality
|
||||||
|
|
||||||
mod leveled;
|
mod leveled;
|
||||||
mod simple_leveled;
|
mod simple_leveled;
|
||||||
mod tiered;
|
mod tiered;
|
||||||
@@ -13,11 +15,8 @@ pub use simple_leveled::{
|
|||||||
};
|
};
|
||||||
pub use tiered::{TieredCompactionController, TieredCompactionOptions, TieredCompactionTask};
|
pub use tiered::{TieredCompactionController, TieredCompactionOptions, TieredCompactionTask};
|
||||||
|
|
||||||
use crate::iterators::merge_iterator::MergeIterator;
|
|
||||||
use crate::iterators::StorageIterator;
|
|
||||||
use crate::lsm_storage::{LsmStorageInner, LsmStorageState};
|
use crate::lsm_storage::{LsmStorageInner, LsmStorageState};
|
||||||
use crate::manifest::ManifestRecord;
|
use crate::table::SsTable;
|
||||||
use crate::table::{SsTable, SsTableBuilder, SsTableIterator};
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub enum CompactionTask {
|
pub enum CompactionTask {
|
||||||
@@ -105,7 +104,7 @@ pub enum CompactionOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl LsmStorageInner {
|
impl LsmStorageInner {
|
||||||
fn compact(&self, task: &CompactionTask) -> Result<Vec<Arc<SsTable>>> {
|
fn compact(&self, _task: &CompactionTask) -> Result<Vec<Arc<SsTable>>> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,3 @@
|
|||||||
use std::collections::HashSet;
|
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::lsm_storage::LsmStorageState;
|
use crate::lsm_storage::LsmStorageState;
|
||||||
@@ -33,25 +31,25 @@ impl LeveledCompactionController {
|
|||||||
|
|
||||||
fn find_overlapping_ssts(
|
fn find_overlapping_ssts(
|
||||||
&self,
|
&self,
|
||||||
snapshot: &LsmStorageState,
|
_snapshot: &LsmStorageState,
|
||||||
sst_ids: &[usize],
|
_sst_ids: &[usize],
|
||||||
in_level: usize,
|
_in_level: usize,
|
||||||
) -> Vec<usize> {
|
) -> Vec<usize> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn generate_compaction_task(
|
pub fn generate_compaction_task(
|
||||||
&self,
|
&self,
|
||||||
snapshot: &LsmStorageState,
|
_snapshot: &LsmStorageState,
|
||||||
) -> Option<LeveledCompactionTask> {
|
) -> Option<LeveledCompactionTask> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_compaction_result(
|
pub fn apply_compaction_result(
|
||||||
&self,
|
&self,
|
||||||
snapshot: &LsmStorageState,
|
_snapshot: &LsmStorageState,
|
||||||
task: &LeveledCompactionTask,
|
_task: &LeveledCompactionTask,
|
||||||
output: &[usize],
|
_output: &[usize],
|
||||||
) -> (LsmStorageState, Vec<usize>) {
|
) -> (LsmStorageState, Vec<usize>) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
@@ -30,16 +30,16 @@ impl SimpleLeveledCompactionController {
|
|||||||
|
|
||||||
pub fn generate_compaction_task(
|
pub fn generate_compaction_task(
|
||||||
&self,
|
&self,
|
||||||
snapshot: &LsmStorageState,
|
_snapshot: &LsmStorageState,
|
||||||
) -> Option<SimpleLeveledCompactionTask> {
|
) -> Option<SimpleLeveledCompactionTask> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_compaction_result(
|
pub fn apply_compaction_result(
|
||||||
&self,
|
&self,
|
||||||
snapshot: &LsmStorageState,
|
_snapshot: &LsmStorageState,
|
||||||
task: &SimpleLeveledCompactionTask,
|
_task: &SimpleLeveledCompactionTask,
|
||||||
output: &[usize],
|
_output: &[usize],
|
||||||
) -> (LsmStorageState, Vec<usize>) {
|
) -> (LsmStorageState, Vec<usize>) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,3 @@
|
|||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::lsm_storage::LsmStorageState;
|
use crate::lsm_storage::LsmStorageState;
|
||||||
@@ -29,16 +27,16 @@ impl TieredCompactionController {
|
|||||||
|
|
||||||
pub fn generate_compaction_task(
|
pub fn generate_compaction_task(
|
||||||
&self,
|
&self,
|
||||||
snapshot: &LsmStorageState,
|
_snapshot: &LsmStorageState,
|
||||||
) -> Option<TieredCompactionTask> {
|
) -> Option<TieredCompactionTask> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_compaction_result(
|
pub fn apply_compaction_result(
|
||||||
&self,
|
&self,
|
||||||
snapshot: &LsmStorageState,
|
_snapshot: &LsmStorageState,
|
||||||
task: &TieredCompactionTask,
|
_task: &TieredCompactionTask,
|
||||||
output: &[usize],
|
_output: &[usize],
|
||||||
) -> (LsmStorageState, Vec<usize>) {
|
) -> (LsmStorageState, Vec<usize>) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
@@ -1,26 +1,24 @@
|
|||||||
use std::collections::{BTreeSet, HashMap};
|
#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality
|
||||||
use std::fs::File;
|
|
||||||
|
use std::collections::HashMap;
|
||||||
use std::ops::Bound;
|
use std::ops::Bound;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::atomic::AtomicUsize;
|
use std::sync::atomic::AtomicUsize;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::Result;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use parking_lot::{Mutex, RwLock};
|
use parking_lot::{Mutex, RwLock};
|
||||||
|
|
||||||
use crate::block::Block;
|
use crate::block::Block;
|
||||||
use crate::compact::{
|
use crate::compact::{
|
||||||
CompactionController, CompactionOptions, LeveledCompactionController, LeveledCompactionOptions,
|
CompactionController, CompactionOptions, LeveledCompactionOptions,
|
||||||
SimpleLeveledCompactionController, SimpleLeveledCompactionOptions, TieredCompactionController,
|
SimpleLeveledCompactionOptions,
|
||||||
};
|
};
|
||||||
use crate::iterators::merge_iterator::MergeIterator;
|
|
||||||
use crate::iterators::two_merge_iterator::TwoMergeIterator;
|
|
||||||
use crate::iterators::StorageIterator;
|
|
||||||
use crate::lsm_iterator::{FusedIterator, LsmIterator};
|
use crate::lsm_iterator::{FusedIterator, LsmIterator};
|
||||||
use crate::manifest::{Manifest, ManifestRecord};
|
use crate::manifest::Manifest;
|
||||||
use crate::mem_table::{map_bound, MemTable};
|
use crate::mem_table::MemTable;
|
||||||
use crate::table::{FileObject, SsTable, SsTableBuilder, SsTableIterator};
|
use crate::table::SsTable;
|
||||||
|
|
||||||
pub type BlockCache = moka::sync::Cache<(usize, usize), Arc<Block>>;
|
pub type BlockCache = moka::sync::Cache<(usize, usize), Arc<Block>>;
|
||||||
|
|
||||||
@@ -108,7 +106,7 @@ impl MiniLsm {
|
|||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn open(path: impl AsRef<Path>, options: LsmStorageOptions) -> Result<Arc<Self>> {
|
pub fn open(_path: impl AsRef<Path>, _options: LsmStorageOptions) -> Result<Arc<Self>> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,6 +134,10 @@ impl MiniLsm {
|
|||||||
self.inner.force_freeze_memtable()?;
|
self.inner.force_freeze_memtable()?;
|
||||||
self.inner.force_flush_next_imm_memtable()
|
self.inner.force_flush_next_imm_memtable()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn force_full_compaction(&self) -> Result<()> {
|
||||||
|
self.inner.force_full_compaction()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LsmStorageInner {
|
impl LsmStorageInner {
|
||||||
@@ -144,22 +146,22 @@ impl LsmStorageInner {
|
|||||||
.fetch_add(1, std::sync::atomic::Ordering::SeqCst)
|
.fetch_add(1, std::sync::atomic::Ordering::SeqCst)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn open(path: impl AsRef<Path>, options: LsmStorageOptions) -> Result<Self> {
|
pub(crate) fn open(_path: impl AsRef<Path>, _options: LsmStorageOptions) -> Result<Self> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a key from the storage. In day 7, this can be further optimized by using a bloom filter.
|
/// Get a key from the storage. In day 7, this can be further optimized by using a bloom filter.
|
||||||
pub fn get(&self, key: &[u8]) -> Result<Option<Bytes>> {
|
pub fn get(&self, _key: &[u8]) -> Result<Option<Bytes>> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Put a key-value pair into the storage by writing into the current memtable.
|
/// Put a key-value pair into the storage by writing into the current memtable.
|
||||||
pub fn put(&self, key: &[u8], value: &[u8]) -> Result<()> {
|
pub fn put(&self, _key: &[u8], _value: &[u8]) -> Result<()> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove a key from the storage by writing an empty value.
|
/// Remove a key from the storage by writing an empty value.
|
||||||
pub fn delete(&self, key: &[u8]) -> Result<()> {
|
pub fn delete(&self, _key: &[u8]) -> Result<()> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,8 +198,8 @@ impl LsmStorageInner {
|
|||||||
/// Create an iterator over a range of keys.
|
/// Create an iterator over a range of keys.
|
||||||
pub fn scan(
|
pub fn scan(
|
||||||
&self,
|
&self,
|
||||||
lower: Bound<&[u8]>,
|
_lower: Bound<&[u8]>,
|
||||||
upper: Bound<&[u8]>,
|
_upper: Bound<&[u8]>,
|
||||||
) -> Result<FusedIterator<LsmIterator>> {
|
) -> Result<FusedIterator<LsmIterator>> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -20,11 +22,11 @@ pub enum ManifestRecord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Manifest {
|
impl Manifest {
|
||||||
pub fn create(path: impl AsRef<Path>) -> Result<Self> {
|
pub fn create(_path: impl AsRef<Path>) -> Result<Self> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn recover(path: impl AsRef<Path>) -> Result<(Self, Vec<ManifestRecord>)> {
|
pub fn recover(_path: impl AsRef<Path>) -> Result<(Self, Vec<ManifestRecord>)> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +38,7 @@ impl Manifest {
|
|||||||
self.add_record_when_init(record)
|
self.add_record_when_init(record)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_record_when_init(&self, record: ManifestRecord) -> Result<()> {
|
pub fn add_record_when_init(&self, _record: ManifestRecord) -> Result<()> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
|
#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality
|
||||||
|
|
||||||
use std::ops::Bound;
|
use std::ops::Bound;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use crossbeam_skiplist::map::Entry;
|
|
||||||
use crossbeam_skiplist::SkipMap;
|
use crossbeam_skiplist::SkipMap;
|
||||||
use ouroboros::self_referencing;
|
use ouroboros::self_referencing;
|
||||||
|
|
||||||
@@ -29,27 +30,27 @@ pub(crate) fn map_bound(bound: Bound<&[u8]>) -> Bound<Bytes> {
|
|||||||
|
|
||||||
impl MemTable {
|
impl MemTable {
|
||||||
/// Create a new mem-table.
|
/// Create a new mem-table.
|
||||||
pub fn create(id: usize) -> Self {
|
pub fn create(_id: usize) -> Self {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new mem-table with WAL
|
/// Create a new mem-table with WAL
|
||||||
pub fn create_with_wal(id: usize, path: impl AsRef<Path>) -> Result<Self> {
|
pub fn create_with_wal(_id: usize, _path: impl AsRef<Path>) -> Result<Self> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a memtable from WAL
|
/// Create a memtable from WAL
|
||||||
pub fn recover_from_wal(id: usize, path: impl AsRef<Path>) -> Result<Self> {
|
pub fn recover_from_wal(_id: usize, _path: impl AsRef<Path>) -> Result<Self> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a value by key.
|
/// Get a value by key.
|
||||||
pub fn get(&self, key: &[u8]) -> Option<Bytes> {
|
pub fn get(&self, _key: &[u8]) -> Option<Bytes> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Put a key-value pair into the mem-table.
|
/// Put a key-value pair into the mem-table.
|
||||||
pub fn put(&self, key: &[u8], value: &[u8]) -> Result<()> {
|
pub fn put(&self, _key: &[u8], _value: &[u8]) -> Result<()> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,12 +62,12 @@ impl MemTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get an iterator over a range of keys.
|
/// Get an iterator over a range of keys.
|
||||||
pub fn scan(&self, lower: Bound<&[u8]>, upper: Bound<&[u8]>) -> MemTableIterator {
|
pub fn scan(&self, _lower: Bound<&[u8]>, _upper: Bound<&[u8]>) -> MemTableIterator {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Flush the mem-table to SSTable.
|
/// Flush the mem-table to SSTable.
|
||||||
pub fn flush(&self, builder: &mut SsTableBuilder) -> Result<()> {
|
pub fn flush(&self, _builder: &mut SsTableBuilder) -> Result<()> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -12,15 +14,15 @@ pub struct Wal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Wal {
|
impl Wal {
|
||||||
pub fn create(path: impl AsRef<Path>) -> Result<Self> {
|
pub fn create(_path: impl AsRef<Path>) -> Result<Self> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn recover(path: impl AsRef<Path>, skiplist: &SkipMap<Bytes, Bytes>) -> Result<Self> {
|
pub fn recover(_path: impl AsRef<Path>, _skiplist: &SkipMap<Bytes, Bytes>) -> Result<Self> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn put(&self, key: &[u8], value: &[u8]) -> Result<()> {
|
pub fn put(&self, _key: &[u8], _value: &[u8]) -> Result<()> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -151,6 +151,10 @@ impl MiniLsm {
|
|||||||
self.inner.force_freeze_memtable()?;
|
self.inner.force_freeze_memtable()?;
|
||||||
self.inner.force_flush_next_imm_memtable()
|
self.inner.force_flush_next_imm_memtable()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn force_full_compaction(&self) -> Result<()> {
|
||||||
|
self.inner.force_full_compaction()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LsmStorageInner {
|
impl LsmStorageInner {
|
||||||
|
Reference in New Issue
Block a user