Skip to content

Commit

Permalink
fix: dont build bloom filter if bits = -1
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-j97 committed Nov 3, 2024
1 parent b3b0d3b commit b98cff1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "lsm-tree"
description = "A K.I.S.S. implementation of log-structured merge trees (LSM-trees/LSMTs)"
license = "MIT OR Apache-2.0"
version = "2.3.0"
version = "2.3.2"
edition = "2021"
rust-version = "1.74.0"
readme = "README.md"
Expand Down
9 changes: 4 additions & 5 deletions src/compaction/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ use std::{
time::Instant,
};

#[cfg(feature = "bloom")]
use crate::segment::writer::BloomConstructionPolicy;

/// Compaction options
pub struct Options {
pub tree_id: TreeId,
Expand Down Expand Up @@ -181,8 +178,7 @@ fn merge_segments(

#[cfg(feature = "bloom")]
{
// TODO: BUG: BloomConstructionPolicy::default is 10 BPK, so setting to 0 or -1
// will still write bloom filters
use crate::segment::writer::BloomConstructionPolicy;

if opts.config.bloom_bits_per_key >= 0 {
// NOTE: Apply some MONKEY to have very high FPR on small levels
Expand All @@ -197,6 +193,9 @@ fn merge_segments(
};

segment_writer = segment_writer.use_bloom_policy(bloom_policy);
} else {
segment_writer =
segment_writer.use_bloom_policy(BloomConstructionPolicy::BitsPerKey(0));
}
}

Expand Down
5 changes: 1 addition & 4 deletions src/segment/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ use super::{
use crate::{block_cache::BlockCache, descriptor_table::FileDescriptorTable, tree::inner::TreeId};
use std::sync::Arc;

#[cfg(feature = "bloom")]
use crate::bloom::{BloomFilter, CompositeHash};

pub struct Inner {
pub(crate) tree_id: TreeId,

Expand All @@ -36,5 +33,5 @@ pub struct Inner {
/// Bloom filter
#[cfg(feature = "bloom")]
#[doc(hidden)]
pub bloom_filter: Option<BloomFilter>,
pub bloom_filter: Option<crate::bloom::BloomFilter>,
}
7 changes: 6 additions & 1 deletion src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,17 @@ impl AbstractTree for Tree {

#[cfg(feature = "bloom")]
{
use crate::segment::writer::BloomConstructionPolicy;

if self.config.bloom_bits_per_key >= 0 {
segment_writer = segment_writer.use_bloom_policy(
// TODO: increase to 0.00001 when https://github.com/fjall-rs/lsm-tree/issues/63
// is fixed
crate::segment::writer::BloomConstructionPolicy::FpRate(0.0001),
BloomConstructionPolicy::FpRate(0.0001),
);
} else {
segment_writer =
segment_writer.use_bloom_policy(BloomConstructionPolicy::BitsPerKey(0));
}
}

Expand Down

0 comments on commit b98cff1

Please sign in to comment.