From fc4765b925fbb3c3aeec98d92f47530596efcc5c Mon Sep 17 00:00:00 2001 From: lxc Date: Sat, 31 May 2025 14:08:31 +0800 Subject: [PATCH] Fix wrong input type of put_batch (#146) * Fix wrong input type of put_batch Update wal.rs * fix Signed-off-by: Alex Chi --------- Signed-off-by: Alex Chi Co-authored-by: Alex Chi --- mini-lsm-starter/src/mem_table.rs | 2 +- mini-lsm-starter/src/wal.rs | 13 +++++++------ mini-lsm/src/mem_table.rs | 2 +- mini-lsm/src/wal.rs | 6 ++++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/mini-lsm-starter/src/mem_table.rs b/mini-lsm-starter/src/mem_table.rs index c854ad7..15e05d8 100644 --- a/mini-lsm-starter/src/mem_table.rs +++ b/mini-lsm-starter/src/mem_table.rs @@ -99,7 +99,7 @@ impl MemTable { 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<()> { unimplemented!() } diff --git a/mini-lsm-starter/src/wal.rs b/mini-lsm-starter/src/wal.rs index 25329ae..c9172a9 100644 --- a/mini-lsm-starter/src/wal.rs +++ b/mini-lsm-starter/src/wal.rs @@ -15,15 +15,16 @@ #![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 anyhow::Result; -use bytes::Bytes; -use crossbeam_skiplist::SkipMap; -use parking_lot::Mutex; +use crate::key::KeySlice; pub struct Wal { file: Arc>>, @@ -42,8 +43,8 @@ impl Wal { unimplemented!() } - /// Implement this in week 3, day 5. - pub fn put_batch(&self, _data: &[(&[u8], &[u8])]) -> Result<()> { + /// 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!() } diff --git a/mini-lsm/src/mem_table.rs b/mini-lsm/src/mem_table.rs index 74b72a7..6460be9 100644 --- a/mini-lsm/src/mem_table.rs +++ b/mini-lsm/src/mem_table.rs @@ -121,7 +121,7 @@ impl MemTable { 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<()> { unimplemented!() } diff --git a/mini-lsm/src/wal.rs b/mini-lsm/src/wal.rs index 2bd5812..739478e 100644 --- a/mini-lsm/src/wal.rs +++ b/mini-lsm/src/wal.rs @@ -23,6 +23,8 @@ use bytes::{Buf, BufMut, Bytes}; use crossbeam_skiplist::SkipMap; use parking_lot::Mutex; +use crate::key::KeySlice; + pub struct Wal { file: Arc>>, } @@ -93,8 +95,8 @@ impl Wal { Ok(()) } - /// Implement this in week 3, day 5. - pub fn put_batch(&self, _data: &[(&[u8], &[u8])]) -> Result<()> { + /// 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!() }