Struct xorfilter::Xor8 [−][src]
Type Xor8 is probabilistic data-structure to test membership of an element in a set.
This implementation has a false positive rate of about 0.3%
and a memory usage of less than 9 bits per entry for sizeable sets.
Xor8 is parametrized over type H
which is expected to implement
BuildHasher trait, like RandomState and BuildHasherDefault.
When not supplied, BuildHasherDefault
is used as the default
hash-builder. When applications want to serialize and de-serialize
Xor8, avoid using RandomState
.
Fields
hash_builder: H
seed: u64
block_length: u32
finger_prints: Vec<u8>
Implementations
impl<H> Xor8<H> where
H: Default + BuildHasher,
[src]
H: Default + BuildHasher,
impl<H> Xor8<H> where
H: BuildHasher,
[src]
H: BuildHasher,
pub fn with_hasher(hash_builder: H) -> Self
[src]
New Xor8 instance initialized with supplied hasher
.
pub fn insert<T: ?Sized + Hash>(&mut self, key: &T)
[src]
Insert 64-bit digest of a single key. Digest for the key shall be generated using the default-hasher or via hasher supplied via Xor8::with_hasher method.
pub fn populate<T: Hash>(&mut self, keys: &[T])
[src]
Populate 64-bit digests for collection of keys. Digest for the key shall be generated using the default-hasher or via hasher supplied via Xor8::with_hasher method.
pub fn populate_keys(&mut self, keys: &[u64])
[src]
Populate pre-compute 64-bit digests for keys.
pub fn build(&mut self)
[src]
Build bitmap for keys that are insert using Xor8::insert or Xor8::populate method.
pub fn build_keys(&mut self, keys: &[u64])
[src]
Build a bitmap for pre-computed 64-bit digests for keys. If any keys where inserted using Xor8::insert, Xor8::populate, Xor8::populate_keys method shall be ignored.
pub fn contains<T: ?Sized + Hash>(&self, key: &T) -> bool
[src]
Contains tell you whether the key is likely part of the set.
pub fn contains_key(&self, key: u64) -> bool
[src]
impl<H> Xor8<H> where
H: BuildHasher,
[src]
H: BuildHasher,
pub fn write_file(&self, path: &OsStr) -> Result<usize>
[src]
Write to file in binary format TODO Add chechsum of finger_prints into file headers
pub fn read_file(path: &OsStr) -> Result<Self> where
H: Default,
[src]
H: Default,
Read from file in binary format
pub fn to_bytes(&self) -> Vec<u8>
[src]
pub fn from_bytes(buf: Vec<u8>) -> Result<Self> where
H: Default,
[src]
H: Default,
Trait Implementations
impl<H> Default for Xor8<H> where
H: BuildHasher + Default,
[src]
H: BuildHasher + Default,
impl<H> PartialEq<Xor8<H>> for Xor8<H> where
H: BuildHasher,
[src]
H: BuildHasher,
Auto Trait Implementations
impl<H> RefUnwindSafe for Xor8<H> where
H: RefUnwindSafe,
H: RefUnwindSafe,
impl<H> Send for Xor8<H> where
H: Send,
H: Send,
impl<H> Sync for Xor8<H> where
H: Sync,
H: Sync,
impl<H> Unpin for Xor8<H> where
H: Unpin,
H: Unpin,
impl<H> UnwindSafe for Xor8<H> where
H: UnwindSafe,
H: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,