diff --git a/crates/brk_indexer/src/stores.rs b/crates/brk_indexer/src/stores.rs index 8c30699ac..864f0d2bd 100644 --- a/crates/brk_indexer/src/stores.rs +++ b/crates/brk_indexer/src/stores.rs @@ -72,7 +72,7 @@ impl Stores { path, "p2aaddressindex_with_outputindex", version + VERSION + Version::ZERO, - Some(None), + Some(false), ) }); let p2pk33addressindex_with_outputindex = scope.spawn(|| { @@ -81,7 +81,7 @@ impl Stores { path, "p2pk33addressindex_with_outputindex", version + VERSION + Version::ZERO, - Some(None), + Some(false), ) }); let p2pk65addressindex_with_outputindex = scope.spawn(|| { @@ -90,7 +90,7 @@ impl Stores { path, "p2pk65addressindex_with_outputindex", version + VERSION + Version::ZERO, - Some(None), + Some(false), ) }); let p2pkhaddressindex_with_outputindex = scope.spawn(|| { @@ -99,7 +99,7 @@ impl Stores { path, "p2pkhaddressindex_with_outputindex", version + VERSION + Version::ZERO, - Some(None), + Some(false), ) }); let p2shaddressindex_with_outputindex = scope.spawn(|| { @@ -108,7 +108,7 @@ impl Stores { path, "p2shaddressindex_with_outputindex", version + VERSION + Version::ZERO, - Some(None), + Some(false), ) }); let p2traddressindex_with_outputindex = scope.spawn(|| { @@ -117,7 +117,7 @@ impl Stores { path, "p2traddressindex_with_outputindex", version + VERSION + Version::ZERO, - Some(None), + Some(false), ) }); let p2wpkhaddressindex_with_outputindex = scope.spawn(|| { @@ -126,7 +126,7 @@ impl Stores { path, "p2wpkhaddressindex_with_outputindex", version + VERSION + Version::ZERO, - Some(None), + Some(false), ) }); let p2wshaddressindex_with_outputindex = scope.spawn(|| { @@ -135,7 +135,7 @@ impl Stores { path, "p2wshaddressindex_with_outputindex", version + VERSION + Version::ZERO, - Some(None), + Some(false), ) }); diff --git a/crates/brk_store/src/lib.rs b/crates/brk_store/src/lib.rs index fde1fd458..4bd522634 100644 --- a/crates/brk_store/src/lib.rs +++ b/crates/brk_store/src/lib.rs @@ -34,11 +34,9 @@ pub struct Store { rtx: ReadTransaction, puts: BTreeMap, dels: BTreeSet, - bloom_filter_bits: Option>, + bloom_filters: Option, } -/// Use default if will read -const DEFAULT_BLOOM_FILTER_BITS: Option = Some(5); // const CHECK_COLLISIONS: bool = true; const MAJOR_FJALL_VERSION: Version = Version::TWO; @@ -59,7 +57,7 @@ where path: &Path, name: &str, version: Version, - bloom_filter_bits: Option>, + bloom_filters: Option, ) -> Result { fs::create_dir_all(path)?; @@ -68,7 +66,7 @@ where &path.join(format!("meta/{name}")), MAJOR_FJALL_VERSION + version, || { - Self::open_partition_handle(keyspace, name, bloom_filter_bits).inspect_err(|e| { + Self::open_partition_handle(keyspace, name, bloom_filters).inspect_err(|e| { eprintln!("{e}"); eprintln!("Delete {path:?} and try again"); }) @@ -85,7 +83,7 @@ where rtx, puts: BTreeMap::new(), dels: BTreeSet::new(), - bloom_filter_bits, + bloom_filters, }) } @@ -180,17 +178,17 @@ where fn open_partition_handle( keyspace: &TransactionalKeyspace, name: &str, - bloom_filter_bits: Option>, + bloom_filters: Option, ) -> Result { - keyspace - .open_partition( - name, - PartitionCreateOptions::default() - .bloom_filter_bits(bloom_filter_bits.unwrap_or(DEFAULT_BLOOM_FILTER_BITS)) - .max_memtable_size(8 * 1024 * 1024) - .manual_journal_persist(true), - ) - .map_err(|e| e.into()) + let mut options = PartitionCreateOptions::default() + .max_memtable_size(8 * 1024 * 1024) + .manual_journal_persist(true); + + if bloom_filters.is_some_and(|b| !b) { + options = options.bloom_filter_bits(None); + } + + keyspace.open_partition(name, options).map_err(|e| e.into()) } pub fn commit_( @@ -272,8 +270,7 @@ where self.meta.reset(); - let partition = - Self::open_partition_handle(&self.keyspace, self.name, self.bloom_filter_bits)?; + let partition = Self::open_partition_handle(&self.keyspace, self.name, self.bloom_filters)?; self.partition.replace(partition); @@ -314,7 +311,7 @@ where rtx: self.keyspace.read_tx(), puts: self.puts.clone(), dels: self.dels.clone(), - bloom_filter_bits: self.bloom_filter_bits, + bloom_filters: self.bloom_filters, } } }