diff --git a/Cargo.lock b/Cargo.lock index dccda78d5bb4e..3f126379009b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3013,7 +3013,7 @@ dependencies = [ [[package]] name = "foyer" version = "0.1.0" -source = "git+https://github.com/mrcroxx/foyer?rev=438eec8#438eec87e90c7a80cb53a06b711c6ea1ad7a0f41" +source = "git+https://github.com/mrcroxx/foyer?rev=3490e3c#3490e3c1b692ac41f57365b70b06b470b2661cc9" dependencies = [ "foyer-common", "foyer-intrusive", @@ -3024,7 +3024,7 @@ dependencies = [ [[package]] name = "foyer-common" version = "0.1.0" -source = "git+https://github.com/mrcroxx/foyer?rev=438eec8#438eec87e90c7a80cb53a06b711c6ea1ad7a0f41" +source = "git+https://github.com/mrcroxx/foyer?rev=3490e3c#3490e3c1b692ac41f57365b70b06b470b2661cc9" dependencies = [ "bytes", "foyer-workspace-hack", @@ -3038,13 +3038,13 @@ dependencies = [ [[package]] name = "foyer-intrusive" version = "0.1.0" -source = "git+https://github.com/mrcroxx/foyer?rev=438eec8#438eec87e90c7a80cb53a06b711c6ea1ad7a0f41" +source = "git+https://github.com/mrcroxx/foyer?rev=3490e3c#3490e3c1b692ac41f57365b70b06b470b2661cc9" dependencies = [ "bytes", "cmsketch", "foyer-common", "foyer-workspace-hack", - "itertools 0.10.5", + "itertools 0.11.0", "memoffset", "parking_lot 0.12.1", "paste", @@ -3055,7 +3055,7 @@ dependencies = [ [[package]] name = "foyer-storage" version = "0.1.0" -source = "git+https://github.com/mrcroxx/foyer?rev=438eec8#438eec87e90c7a80cb53a06b711c6ea1ad7a0f41" +source = "git+https://github.com/mrcroxx/foyer?rev=3490e3c#3490e3c1b692ac41f57365b70b06b470b2661cc9" dependencies = [ "anyhow", "async-channel", @@ -3084,7 +3084,7 @@ dependencies = [ [[package]] name = "foyer-workspace-hack" version = "0.1.0" -source = "git+https://github.com/mrcroxx/foyer?rev=438eec8#438eec87e90c7a80cb53a06b711c6ea1ad7a0f41" +source = "git+https://github.com/mrcroxx/foyer?rev=3490e3c#3490e3c1b692ac41f57365b70b06b470b2661cc9" dependencies = [ "crossbeam-utils", "either", @@ -3093,7 +3093,7 @@ dependencies = [ "futures-sink", "futures-util", "hyper", - "itertools 0.10.5", + "itertools 0.11.0", "libc", "memchr", "parking_lot 0.12.1", diff --git a/src/storage/Cargo.toml b/src/storage/Cargo.toml index 9e0fac5826d6a..8f0569fdc6a7d 100644 --- a/src/storage/Cargo.toml +++ b/src/storage/Cargo.toml @@ -26,7 +26,7 @@ dyn-clone = "1.0.14" either = "1" enum-as-inner = "0.6" fail = "0.5" -foyer = { git = "https://github.com/mrcroxx/foyer", rev = "438eec8" } +foyer = { git = "https://github.com/mrcroxx/foyer", rev = "3490e3c" } futures = { version = "0.3", default-features = false, features = ["alloc"] } futures-async-stream = { workspace = true } hex = "0.4" diff --git a/src/storage/src/hummock/file_cache/store.rs b/src/storage/src/hummock/file_cache/store.rs index 9de54552ae077..2bdfbbeb42fb1 100644 --- a/src/storage/src/hummock/file_cache/store.rs +++ b/src/storage/src/hummock/file_cache/store.rs @@ -18,7 +18,7 @@ use std::path::PathBuf; use std::sync::Arc; use std::time::Duration; -use bytes::{Buf, BufMut, Bytes}; +use bytes::{Buf, BufMut}; use foyer::common::code::{Key, Value}; use foyer::intrusive::eviction::lfu::LfuConfig; use foyer::storage::admission::rated_ticket::RatedTicketAdmissionPolicy; @@ -338,12 +338,12 @@ impl Key for SstableBlockIndex { 8 + 8 // sst_id (8B) + block_idx (8B) } - fn write(&self, mut buf: &mut [u8]) { + fn write(&self, mut buf: impl BufMut) { buf.put_u64(self.sst_id); buf.put_u64(self.block_idx); } - fn read(mut buf: &[u8]) -> Self { + fn read(mut buf: impl Buf) -> Self { let sst_id = buf.get_u64(); let block_idx = buf.get_u64(); Self { sst_id, block_idx } @@ -355,12 +355,12 @@ impl Value for Box { self.raw_data().len() } - fn write(&self, mut buf: &mut [u8]) { + fn write(&self, mut buf: impl BufMut) { buf.put_slice(self.raw_data()) } - fn read(buf: &[u8]) -> Self { - let data = Bytes::copy_from_slice(buf); + fn read(mut buf: impl Buf) -> Self { + let data = buf.copy_to_bytes(buf.remaining()); let block = Block::decode_from_raw(data); Box::new(block) } @@ -371,17 +371,19 @@ impl Value for Box { 8 + self.meta.encoded_size() // id (8B) + meta size } - fn write(&self, mut buf: &mut [u8]) { - buf.put_u64(self.id); + fn write(&self, mut buf: impl BufMut) { // TODO(MrCroxx): avoid buffer copy + buf.put_u64(self.id); let mut buffer = vec![]; self.meta.encode_to(&mut buffer); buf.put_slice(&buffer[..]) } - fn read(mut buf: &[u8]) -> Self { + fn read(mut buf: impl Buf) -> Self { + // TODO(MrCroxx): avoid buffer copy let id = buf.get_u64(); - let meta = SstableMeta::decode(buf).unwrap(); + let buf = buf.copy_to_bytes(buf.remaining()); + let meta = SstableMeta::decode(&buf).unwrap(); Box::new(Sstable::new(id, meta)) } }