Exleveldb v0.11.0 Exleveldb
Exleveldb is a thin wrapper around Basho’s eleveldb. At the moment, Exleveldb exposes the functions defined in this module.
Summary
Functions
Takes a reference as returned by open/2
and closes the specified datastore if open
Takes a reference as returned by open/2
, a key and an options list and
deletes the value associated with key
in the datastore, db_ref
Destroy a database, which implies the deletion of the database folder. Takes a string with the path to the database and a list of options.
Returns :ok
on success and {:error, reason}
on error
Takes a reference as returned by open/2
, an anonymous function,
an accumulator, and an options list and folds over the key-value pairs
in the datastore specified in db_ref
Takes a reference as returned by open/2
, an anonymous function,
an accumulator, and an options list and folds over the keys
of the open datastore specified by db_ref
Takes a reference as returned by open/2
, a key, and an options list and
retrieves a value in LevelDB by key
Takes a reference as returned by open/2
and checks whether the datastore
specified by db_ref
is empty
Takes a reference to a data store, then creates and returns {:ok, ""}
where the
seemingly empty binary is a reference to the iterator. As with db_ref
, the iterator
reference is an opaque type and as such appears to be an empty binary because it’s
internal to the eleveldb module
Takes an iterator reference, closes the iterator, and returns :ok
Takes an iterator reference and an action and returns the corresponding key-value pair
Takes a reference as returned by open/2
and an anonymous function,
and maps over the key-value pairs in the datastore
Takes a reference as returned by open/2
and an anonymous function,
and maps over the keys in the datastore
Takes a name
string and an opts
list and opens a new datastore in the
directory called name
. If name
does not exist already and no opts
list
was provided, opts
will default to [{:create_if_missing, :true}]
Takes a reference as returned by open/2
, a key and an options list and
puts a single key-value pair into the datastore specified by the reference, db_ref
Takes a reference as returned by open/2
,
and constructs a stream of all key-value pairs in the referenced datastore.
When called with :keys_only
as its second argument, only keys,
not values will be emitted by the stream
Performs a batch write to the datastore, either deleting or putting key-value pairs
Types
open_options() :: [create_if_missing: boolean, error_if_exists: boolean, write_buffer_size: pos_integer, block_size: pos_integer, sst_block_size: pos_integer, block_restart_interval: pos_integer, block_size_steps: pos_integer, paranoid_checks: boolean, verify_compactions: boolean, compression: boolean, use_bloomfilter: boolean | pos_integer, total_memory: pos_integer, total_leveldb_mem: pos_integer, total_leveldb_mem_percent: pos_integer, is_internal_db: boolean, limited_developer_mem: boolean, eleveldb_threads: pos_integer, fadvise_willneed: boolean, block_cache_threshold: pos_integer, delete_threshold: pos_integer, tiered_slow_level: pos_integer, tiered_fast_prefix: charlist, tiered_slow_prefix: charlist]
Functions
Takes a reference as returned by open/2
and closes the specified datastore if open.
Returns :ok
or {:error, {:type, 'reason for error'}}
on error.
Takes a reference as returned by open/2
, a key and an options list and
deletes the value associated with key
in the datastore, db_ref
.
Returns :ok
when successful or {:error, reference, {:type, action}}
on error.
Destroy a database, which implies the deletion of the database folder. Takes a string with the path to the database and a list of options.
Returns :ok
on success and {:error, reason}
on error.
Takes a reference as returned by open/2
, an anonymous function,
an accumulator, and an options list and folds over the key-value pairs
in the datastore specified in db_ref
.
Returns the result of the last call to the anonymous function used in the fold.
The two arguments passed to the anonymous function, fun
are a tuple of the
key value pair and acc
.
Takes a reference as returned by open/2
, an anonymous function,
an accumulator, and an options list and folds over the keys
of the open datastore specified by db_ref
.
Returns the result of the last call to the anonymous function used in the fold.
The two arguments passed to the anonymous function, fun
are a key and acc
.
get(db_reference, db_key, read_options) :: {:ok, Bitstring} | :not_found
Takes a reference as returned by open/2
, a key, and an options list and
retrieves a value in LevelDB by key.
Returns {:ok, value}
when successful or :not_found
on failed lookup.
Takes a reference as returned by open/2
and checks whether the datastore
specified by db_ref
is empty.
Returns true
if empty and false
if not.
iterator(db_reference, read_options) :: {:ok, itr_reference} | {:error, any}
Takes a reference to a data store, then creates and returns {:ok, ""}
where the
seemingly empty binary is a reference to the iterator. As with db_ref
, the iterator
reference is an opaque type and as such appears to be an empty binary because it’s
internal to the eleveldb module.
If the :keys_only
atom is given after opts, the iterator will only traverse keys.
iterator(db_reference, read_options, :keys_only) :: {:ok, itr_reference} | {:error, any}
Takes an iterator reference, closes the iterator, and returns :ok
.
iterator_move(itr_reference, Atom) :: {:ok, Atom, Atom} | {:error, Atom}
Takes an iterator reference and an action and returns the corresponding key-value pair.
An action can either be :first
, :last
, :next
, :prev
, :prefetch
, or a binary
representing the key of the pair you want to fetch.
Takes a reference as returned by open/2
and an anonymous function,
and maps over the key-value pairs in the datastore.
Returns the results of applying the anonymous function to every key-value pair currently in the datastore.
The argument to the anonymous function is i
for the current item,
i.e. key-value pair, in the list.
Takes a reference as returned by open/2
and an anonymous function,
and maps over the keys in the datastore.
Returns the results of applying the anonymous function to every key in currently in the datastore.
The argument to the anonymous function is i
for the current item,
i..e key, in the list.
open(db_location, open_options) :: {:ok, db_reference} | {:error, any}
Takes a name
string and an opts
list and opens a new datastore in the
directory called name
. If name
does not exist already and no opts
list
was provided, opts
will default to [{:create_if_missing, :true}]
.
Returns {:ok, ""}
where what appears to be an empty binary is a reference to the opened
datastore or, on error, {:error, {:type, 'reason for error'}}
.
Takes a reference as returned by open/2
, a key and an options list and
puts a single key-value pair into the datastore specified by the reference, db_ref
.
Returns :ok
if successful or {:error, reference, {:type, action}}
on error.
Takes the path to the leveldb database and a list of options. The standard recomended option is the empty list []
.
Before calling repair/2
, close the connection to the database with close/1
.
Returns :ok
on success and {:error, reason}
on error.
Takes a reference as returned by open/2
,
and constructs a stream of all key-value pairs in the referenced datastore.
When called with :keys_only
as its second argument, only keys,
not values will be emitted by the stream.
Returns a stream with the datastore’s key-value pairs as its enumerable.
When calling Enum.take/2
or similar on the resulting stream,
specifying more entries than are in the referenced datastore
will not yield an error but simply return a list of all pairs in the datastore.
write(db_reference, write_actions, write_options) :: :ok | {:error, any}
Performs a batch write to the datastore, either deleting or putting key-value pairs.
Takes a reference to an open datastore, a list of tuples (containing atoms for operations and strings for keys and values) designating operations (delete or put) to be done, and a list of options.
Returns :ok
on success and {:error, reference, {:type, reason}}
on error.