Skip to content

Commit 16961e1

Browse files
committed
fix(bloom): align MAX_NUM_BITS with java implementation
1 parent 9a83070 commit 16961e1

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

datasketches/src/bloom/builder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
// under the License.
1717

1818
use super::BloomFilter;
19+
use crate::bloom::sketch::PREAMBLE_LONGS_STANDARD;
1920
use crate::hash::DEFAULT_UPDATE_SEED;
2021

2122
const MIN_NUM_BITS: u64 = 64;
22-
const MAX_NUM_BITS: u64 = (1u64 << 35) - 64; // ~32 GB - reasonable limit
23+
const MAX_NUM_BITS: u64 = (i32::MAX as u64 - PREAMBLE_LONGS_STANDARD as u64) * 64;
2324

2425
/// Builder for creating [`BloomFilter`] instances.
2526
///

datasketches/src/bloom/sketch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use crate::error::Error;
2424
use crate::hash::XxHash64;
2525

2626
// Serialization constants
27+
pub const PREAMBLE_LONGS_STANDARD: u8 = 4;
2728
const PREAMBLE_LONGS_EMPTY: u8 = 3;
28-
const PREAMBLE_LONGS_STANDARD: u8 = 4;
2929
const BLOOM_FAMILY_ID: u8 = 21; // Bloom filter family ID
3030
const SERIAL_VERSION: u8 = 1;
3131
const EMPTY_FLAG_MASK: u8 = 1 << 2;

0 commit comments

Comments
 (0)