2024-01-20 11:14:19 +08:00
|
|
|
#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality
|
|
|
|
|
|
2024-01-20 11:11:09 +08:00
|
|
|
use std::fs::File;
|
|
|
|
|
use std::path::Path;
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
|
|
use anyhow::Result;
|
|
|
|
|
use parking_lot::{Mutex, MutexGuard};
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
|
|
use crate::compact::CompactionTask;
|
|
|
|
|
|
|
|
|
|
pub struct Manifest {
|
|
|
|
|
file: Arc<Mutex<File>>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
|
pub enum ManifestRecord {
|
|
|
|
|
Flush(usize),
|
|
|
|
|
NewMemtable(usize),
|
|
|
|
|
Compaction(CompactionTask, Vec<usize>),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Manifest {
|
2024-01-20 11:14:19 +08:00
|
|
|
pub fn create(_path: impl AsRef<Path>) -> Result<Self> {
|
2024-01-20 11:11:09 +08:00
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-20 11:14:19 +08:00
|
|
|
pub fn recover(_path: impl AsRef<Path>) -> Result<(Self, Vec<ManifestRecord>)> {
|
2024-01-20 11:11:09 +08:00
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn add_record(
|
|
|
|
|
&self,
|
|
|
|
|
_state_lock_observer: &MutexGuard<()>,
|
|
|
|
|
record: ManifestRecord,
|
|
|
|
|
) -> Result<()> {
|
|
|
|
|
self.add_record_when_init(record)
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-20 11:14:19 +08:00
|
|
|
pub fn add_record_when_init(&self, _record: ManifestRecord) -> Result<()> {
|
2024-01-20 11:11:09 +08:00
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
}
|