finish 2.7

Signed-off-by: Alex Chi <iskyzh@gmail.com>
This commit is contained in:
Alex Chi
2024-01-28 14:08:08 +08:00
parent b96479384c
commit b4485f49c3
15 changed files with 165 additions and 36 deletions

View File

@@ -1,5 +1,6 @@
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
use anyhow::Result;
use bytes::{BufMut, Bytes, BytesMut};
/// Implements a bloom filter
@@ -45,13 +46,13 @@ impl<T: AsMut<[u8]>> BitSliceMut for T {
impl Bloom {
/// Decode a bloom filter
pub fn decode(buf: &[u8]) -> Self {
pub fn decode(buf: &[u8]) -> Result<Self> {
let filter = &buf[..buf.len() - 1];
let k = buf[buf.len() - 1];
Self {
Ok(Self {
filter: filter.to_vec().into(),
k,
}
})
}
/// Encode a bloom filter

View File

@@ -1,6 +1,7 @@
#![allow(dead_code)] // REMOVE THIS LINE after fully implementing this functionality
use std::fs::File;
use std::io::BufWriter;
use std::path::Path;
use std::sync::Arc;
@@ -10,7 +11,7 @@ use crossbeam_skiplist::SkipMap;
use parking_lot::Mutex;
pub struct Wal {
file: Arc<Mutex<File>>,
file: Arc<Mutex<BufWriter<File>>>,
}
impl Wal {