Struct xorfilter::Xor8[][src]

pub struct Xor8<H = BuildHasherDefault> where
    H: BuildHasher
{ pub hash_builder: H, pub seed: u64, pub block_length: u32, pub finger_prints: Vec<u8>, // some fields omitted }

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: Hseed: u64block_length: u32finger_prints: Vec<u8>

Implementations

impl<H> Xor8<H> where
    H: Default + BuildHasher
[src]

pub fn new() -> Self[src]

New Xor8 instance initialized with DefaultHasher.

impl<H> Xor8<H> where
    H: BuildHasher
[src]

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]

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]

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]

Trait Implementations

impl<H> Default for Xor8<H> where
    H: BuildHasher + Default
[src]

impl<H> PartialEq<Xor8<H>> for Xor8<H> where
    H: BuildHasher
[src]

Auto Trait Implementations

impl<H> RefUnwindSafe for Xor8<H> where
    H: RefUnwindSafe

impl<H> Send for Xor8<H> where
    H: Send

impl<H> Sync for Xor8<H> where
    H: Sync

impl<H> Unpin for Xor8<H> where
    H: Unpin

impl<H> UnwindSafe for Xor8<H> where
    H: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.