Module xor8

Interface for the xor8 filter.

Copyright © (C) 2019, Matthew Pope

Authors: Matthew Pope.

Description

Interface for the xor8 filter.

Shorthand for the exor_filter module. For indepth documentation, see that module.

Example usage:
  Filter = xor8:new(["cat", "dog", "mouse"]),
  true   = xor8:contain(Filter, "cat"),
  false  = xor8:contain(Filter, "goose"),
  ok     = xor8:free(Filter).

Function Index

contain/2Tests to see if the passed argument is in the filter.
contain/3Tests to see if the passed argument is in the filter.
from_bin/1Deserializes a filter from a binary previously serialized with to_bin/1 that used the default hash function.
from_bin/2Deserializes a filter from a binary previously serialized with to_bin/1 that used a custom hash function.
new/1Initializes the xor filter, and runs the default hash function on each of the elements in the list.
new/2Initializes the xor filter, and runs the specified hash on each of the elements in the list.
new_buffered/1Initializes the xor filter, and runs the default hash function on each of the elements in the list.
new_buffered/2Initializes the xor filter, and runs the default hash function on each of the elements in the list.
to_bin/1Serializes the filter to a binary that can be later be deserialized with from_bin/1 or from_bin/2

Function Details

contain/2

contain(Filter::{reference(), atom() | function()}, Key::term()) -> true | false

Tests to see if the passed argument is in the filter. The first argument must be the pre-initialized filter.

contain/3

contain(Filter::{reference(), atom() | function()}, Key::term(), ReturnValue::any()) -> true | any()

Tests to see if the passed argument is in the filter. The first argument must be the pre-initialized filter.

Will return the third argument if the element doesn't exist in the filter.

from_bin/1

from_bin(Filter::binary()) -> {reference(), atom()}

Deserializes a filter from a binary previously serialized with to_bin/1 that used the default hash function.

from_bin/2

from_bin(Filter::binary(), Hash::atom() | function()) -> {reference(), atom() | function()}

Deserializes a filter from a binary previously serialized with to_bin/1 that used a custom hash function.

new/1

new(List::list()) -> {reference(), atom()} | {error, atom()}

Initializes the xor filter, and runs the default hash function on each of the elements in the list. This should be fine for the general case.

new/2

new(List::list(), HashFunction::atom() | function()) -> {reference(), atom() | function()} | {error, atom()}

Initializes the xor filter, and runs the specified hash on each of the elements in the list.

The option default_hash uses the erlang:phash2/1 function. The option none is for prehashed data. A fun can be passed that will be applied to each element.

new_buffered/1

new_buffered(List::list()) -> {reference(), atom()} | {error, atom()}

Initializes the xor filter, and runs the default hash function on each of the elements in the list. This is the buffered version, meant for large filters.

new_buffered/2

new_buffered(List::list(), HashFunction::atom() | function()) -> {reference(), atom() | function()} | {error, atom()}

Initializes the xor filter, and runs the default hash function on each of the elements in the list. This is the buffered version, meant for large filters. See the xor8:new/2 or exor_filter:xor8_new/2 funtions for more indepth documentaiton.

to_bin/1

to_bin(Filter::reference()) -> binary()

Serializes the filter to a binary that can be later be deserialized with from_bin/1 or from_bin/2

Returns binary().


Generated by EDoc