cuckoo_filter() = #cuckoo_filter{}
option() = {fingerprint_size, 4 | 8 | 16 | 32 | 64} | {bucket_size, pos_integer()} | {max_evictions, non_neg_integer()} | {hash_function, fun((binary()) -> non_neg_integer())}
options() = [option()]
add/2 | Equivalent to add(Filter, Data, infinity). |
add/3 | Adds data to the filter. |
capacity/1 | Returns the maximum capacity of the filter. |
contains/2 | Checks if data is in the filter. |
delete/2 | Equivalent to delete(Filter, Data, infinity). |
delete/3 | Deletes data from the filter. |
export/1 | Returns all buckets in the filter as a binary. |
import/2 | Imports filter data from a binary created using export/1 . |
new/1 | Equivalent to new(Capacity, []). |
new/2 | Creates a new cuckoo filter with the given capacity and options. |
size/1 | Returns number of items in the filter. |
add(Filter::cuckoo_filter(), Data::term()) -> ok | {error, not_enough_space}
Equivalent to add(Filter, Data, infinity).
add(Filter::cuckoo_filter(), Data::term(), LockTimeout::timeout()) -> ok | {error, not_enough_space | timeout}
Adds data to the filter.
Returns ok
if the insertion was successful, but could return
{error, not_enough_space}
, when the filter is nearing its capacity.
LockTimeout
is given, it could return {error, timeout}
, if it
can not acquire the lock within LockTimeout
milliseconds.
capacity(Cuckoo_filter::cuckoo_filter()) -> pos_integer()
Returns the maximum capacity of the filter.
contains(Filter::cuckoo_filter(), Data::term()) -> boolean()
Checks if data is in the filter.
delete(Filter::cuckoo_filter(), Data::term()) -> ok | {error, not_found}
Equivalent to delete(Filter, Data, infinity).
delete(Filter::cuckoo_filter(), Data::term(), LockTimeout::timeout()) -> ok | {error, not_found | timeout}
Deletes data from the filter.
Returns ok
if the deletion was successful, and returns {error, not_found}
if the element could not be found in the filter.
When LockTimeout
is given, it could return {error, timeout}
, if it
can not acquire the lock within LockTimeout
milliseconds.
export(Filter::cuckoo_filter()) -> binary()
Returns all buckets in the filter as a binary.
Returned binary can be used to reconstruct the filter again, usingimport/2
function.
import(Filter::cuckoo_filter(), Data::binary()) -> ok | {error, invalid_data_size}
Imports filter data from a binary created using export/1
.
new(Capacity::pos_integer()) -> cuckoo_filter()
Equivalent to new(Capacity, []).
new(Capacity::pos_integer(), Opts::options()) -> cuckoo_filter()
Creates a new cuckoo filter with the given capacity and options
Note that the actual capacity might be higher than the given capacity, because internally number of buckets in a cuckoo filter must be a power of 2.
Possible options are:{fingerprint_size, FingerprintSize}
FingerprintSize can be one of 4, 8, 16, 32, and 64 bits. Default fingerprint size is 16 bits.
{bucket_size, BucketSize}
BucketSize must be a non negative integer, and the default value is 4. Higher bucket sizes can reduce insert time considerably since it reduces the number of relocations of existing fingerprints in occupied buckets, but it increases the lookup time, and false positive rate.
{max_evictions, MaxEvictions}
MaxEvictions indicates the maximum number of relocation attemps before giving up when inserting a new element.
{hash_function, HashFunction}
You can specify a custom hash function that accepts a binary as argument and returns hash value as an integer.
size(Cuckoo_filter::cuckoo_filter()) -> non_neg_integer()
Returns number of items in the filter.
Generated by EDoc