View Source ExPoppyServer (ex_poppy v0.1.4)
Documentation for ExPoppyServer
.
ExPoppyServer is a genserver holding the reference to a ExPoppy
bloom filter in memory.
The main purpose of this construct is to avoid reloading a filter when not necessary.
Here is how one would add ExPoppyServer to an application's Supervisor to give access to a filter called host.bloom
:
{ExPoppy.ExPoppyServer, name: :poppyserver, path: Path.join([:code.priv_dir(:myapp), "host.bloom"])}
Summary
Functions
Returns the filter's capacity
Returns a specification to start this module under a supervisor.
Checks whether a string
may be preesnt in the bloom filter.
Returns true
or false
Returns the estimate count of elements in the bloom filter
Returns the filter's false positive rate
Inserts a string
into the bloomfilter.
Returns :ok
or {:error, "a message describing the error}
Loads the bloom filter located at path
.
Returns :ok
or {:error, "a message describing the error"}
Saves the bloom filter to a file located at path
Returns :ok
or {:error, "a message describing the error"}
Starts genserver. Process name can be set in the options.
Returns the filter's version
Functions
Returns the filter's capacity
Examples
iex(8)> ExPoppyServer.capacity(pid)
10000
Returns a specification to start this module under a supervisor.
See Supervisor
.
Checks whether a string
may be preesnt in the bloom filter.
Returns true
or false
Examples
iex(5)> ExPoppyServer.contains(pid, "toto")
true
iex(6)> ExPoppyServer.contains(pid, "tata")
false
Returns the estimate count of elements in the bloom filter
Examples
iex(2)> ExPoppyServer.insert(pid, "toto")
:ok
iex(3)> ExPoppyServer.insert(pid, "tata")
:ok
iex(4)> ExPoppyServer.count_estimate(pid)
2
Returns the filter's false positive rate
Examples
iex(8)> ExPoppyServer.fpp(pid)
0.001
Inserts a string
into the bloomfilter.
Returns :ok
or {:error, "a message describing the error}
Examples
iex(4)> ExPoppyServer.insert(pid, "toto")
:ok
Loads the bloom filter located at path
.
Returns :ok
or {:error, "a message describing the error"}
Examples
iex(5)> ExPoppyServer.load(pid, "toto")
:ok
iex(6)> ExPoppyServer.load(pid, "/root/toto")
{:error, "IO error: Permission denied (os error 13)"}
iex(8)> ExPoppyServer.load(pid, "/home/jlouis/tata")
{:error, "IO error: No such file or directory (os error 2)"}
Saves the bloom filter to a file located at path
Returns :ok
or {:error, "a message describing the error"}
Examples
iex(4)> ExPoppyServer.save(pid, "toto")
:ok
iex(6)> ExPoppyServer.save(pid, "/root/toto")
{:error, "IO error: Permission denied (os error 13)"}
Starts genserver. Process name can be set in the options.
Examples
iex(1)> {:ok, pid} = ExPoppyServer.start_link([])
{:ok, #PID<0.188.0>}
iex(4)> {:ok, pid2} = ExPoppyServer.start_link([])
** (MatchError) no match of right hand side value: {:error, {:already_started, #PID<0.188.0>}}
Returns the filter's version
Examples
iex(7)> ExPoppyServer.version(pid)
2