Fix wrong input type of put_batch (#146)

* Fix wrong input type of put_batch

Update wal.rs

* fix

Signed-off-by: Alex Chi <iskyzh@gmail.com>

---------

Signed-off-by: Alex Chi <iskyzh@gmail.com>
Co-authored-by: Alex Chi <iskyzh@gmail.com>
This commit is contained in:
lxc
2025-05-31 14:08:31 +08:00
committed by GitHub
parent 4c8d4ebf23
commit fc4765b925
4 changed files with 13 additions and 10 deletions

View File

@@ -99,7 +99,7 @@ impl MemTable {
unimplemented!() unimplemented!()
} }
/// Implement this in week 3, day 5. /// 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<()> { pub fn put_batch(&self, _data: &[(KeySlice, &[u8])]) -> Result<()> {
unimplemented!() unimplemented!()
} }

View File

@@ -15,15 +15,16 @@
#![allow(unused_variables)] // TODO(you): remove this lint after implementing this mod #![allow(unused_variables)] // TODO(you): remove this lint after implementing this mod
#![allow(dead_code)] // 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::fs::File;
use std::io::BufWriter; use std::io::BufWriter;
use std::path::Path; use std::path::Path;
use std::sync::Arc; use std::sync::Arc;
use anyhow::Result; use crate::key::KeySlice;
use bytes::Bytes;
use crossbeam_skiplist::SkipMap;
use parking_lot::Mutex;
pub struct Wal { pub struct Wal {
file: Arc<Mutex<BufWriter<File>>>, file: Arc<Mutex<BufWriter<File>>>,
@@ -42,8 +43,8 @@ impl Wal {
unimplemented!() unimplemented!()
} }
/// Implement this in week 3, day 5. /// 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: &[(&[u8], &[u8])]) -> Result<()> { pub fn put_batch(&self, _data: &[(KeySlice, &[u8])]) -> Result<()> {
unimplemented!() unimplemented!()
} }

View File

@@ -121,7 +121,7 @@ impl MemTable {
Ok(()) Ok(())
} }
/// Implement this in week 3, day 5. /// 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<()> { pub fn put_batch(&self, _data: &[(KeySlice, &[u8])]) -> Result<()> {
unimplemented!() unimplemented!()
} }

View File

@@ -23,6 +23,8 @@ use bytes::{Buf, BufMut, Bytes};
use crossbeam_skiplist::SkipMap; use crossbeam_skiplist::SkipMap;
use parking_lot::Mutex; use parking_lot::Mutex;
use crate::key::KeySlice;
pub struct Wal { pub struct Wal {
file: Arc<Mutex<BufWriter<File>>>, file: Arc<Mutex<BufWriter<File>>>,
} }
@@ -93,8 +95,8 @@ impl Wal {
Ok(()) Ok(())
} }
/// Implement this in week 3, day 5. /// 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: &[(&[u8], &[u8])]) -> Result<()> { pub fn put_batch(&self, _data: &[(KeySlice, &[u8])]) -> Result<()> {
unimplemented!() unimplemented!()
} }