pub struct SeriesBloomFilter { /* private fields */ }Expand description
Per-segment bloom filter for series key pruning.
A space-efficient probabilistic data structure that answers set membership queries with possible false positives but no false negatives.
§False Positive Rate
The default target FP rate is 1%. At this rate, the filter uses approximately 10 bits per inserted key, with 7 hash functions.
Implementations§
Source§impl SeriesBloomFilter
impl SeriesBloomFilter
Sourcepub fn insert(&mut self, key: &SeriesKey) -> bool
pub fn insert(&mut self, key: &SeriesKey) -> bool
Insert a series key into the filter.
Returns true if the key was probably new (not previously present),
false if it was definitely already present. The count is only
incremented for new insertions, giving a more accurate FP-rate estimate.
Sourcepub fn may_contain(&self, key: &SeriesKey) -> bool
pub fn may_contain(&self, key: &SeriesKey) -> bool
Test whether the filter may contain the given series key.
Returns false: the key is definitely not in the set.
Returns true: the key is probably in the set (with FP rate p).
Sourcepub fn num_hashes(&self) -> u32
pub fn num_hashes(&self) -> u32
Returns the number of hash functions.
Sourcepub fn to_bytes(&self) -> Result<Vec<u8>, IndexError>
pub fn to_bytes(&self) -> Result<Vec<u8>, IndexError>
Serialize the bloom filter to bytes.
Format: [num_bits: u32][num_hashes: u8][count: u32][bits...]
§Errors
Returns IndexError::Corrupt if num_bits or count exceeds
u32::MAX (bloom filter too large for the v1 wire format).
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self, IndexError>
pub fn from_bytes(data: &[u8]) -> Result<Self, IndexError>
Deserialize a bloom filter from bytes.
§Errors
Returns an error if the data is too short or corrupt.
Trait Implementations§
Source§impl Clone for SeriesBloomFilter
impl Clone for SeriesBloomFilter
Source§fn clone(&self) -> SeriesBloomFilter
fn clone(&self) -> SeriesBloomFilter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SeriesBloomFilter
impl RefUnwindSafe for SeriesBloomFilter
impl Send for SeriesBloomFilter
impl Sync for SeriesBloomFilter
impl Unpin for SeriesBloomFilter
impl UnsafeUnpin for SeriesBloomFilter
impl UnwindSafe for SeriesBloomFilter
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more