Files
mini_lsm/mini-lsm-starter/src/wal.rs
ECROF88 8fb4176e71
Some checks failed
CI (main) / build (push) Has been cancelled
CI (main) / deploy (push) Has been cancelled
First Commit
2025-10-20 20:12:40 +08:00

57 lines
1.8 KiB
Rust

// REMOVE THIS LINE after fully implementing this functionality
// Copyright (c) 2022-2025 Alex Chi Z
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#![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 anyhow::Result;
use bytes::Bytes;
use crossbeam_skiplist::SkipMap;
use parking_lot::Mutex;
use std::fs::File;
use std::io::BufWriter;
use std::path::Path;
use std::sync::Arc;
use crate::key::KeySlice;
pub struct Wal {
file: Arc<Mutex<BufWriter<File>>>,
}
impl Wal {
pub fn create(_path: impl AsRef<Path>) -> Result<Self> {
Ok(Self {
file: Arc::new(Mutex::new(BufWriter::new(File::create(_path)?))),
})
}
pub fn recover(_path: impl AsRef<Path>, _skiplist: &SkipMap<Bytes, Bytes>) -> Result<Self> {
unimplemented!()
}
pub fn put(&self, _key: &[u8], _value: &[u8]) -> Result<()> {
unimplemented!()
}
/// Implement this in week 3, day 5; if you want to implement this earlier, use `&[u8]` as the key type.
pub fn put_batch(&self, _data: &[(KeySlice, &[u8])]) -> Result<()> {
unimplemented!()
}
pub fn sync(&self) -> Result<()> {
unimplemented!()
}
}