Module riak_core_metadata

Data Types

delete_opts()

delete_opts() = []

fold_opts()

fold_opts() = it_opts()

get_opt()

get_opt() = get_opt_default_val() | get_opt_resolver() | get_opt_allow_put()

get_opt_allow_put()

get_opt_allow_put() = {allow_put, boolean()}

get_opt_default_val()

get_opt_default_val() = {default, metadata_value()}

get_opt_resolver()

get_opt_resolver() = {resolver, metadata_resolver()}

get_opts()

get_opts() = [get_opt()]

it_opt()

it_opt() = it_opt_resolver() | it_opt_default() | it_opt_keymatch()

it_opt_default()

it_opt_default() = {default, metadata_value() | it_opt_default_fun()}

it_opt_default_fun()

it_opt_default_fun() = fun((metadata_key()) -> metadata_value())

it_opt_keymatch()

it_opt_keymatch() = {match, term()}

it_opt_resolver()

it_opt_resolver() = {resolver, metadata_resolver() | lww}

it_opts()

it_opts() = [it_opt()]

iterator()

iterator() = {riak_core_metadata_manager:metadata_iterator(), it_opts()}

metadata_key()

metadata_key() = any()

metadata_modifier()

metadata_modifier() = fun(([metadata_value() | metadata_tombstone()] | undefined) -> metadata_value())

metadata_prefix()

metadata_prefix() = {binary() | atom(), binary() | atom()}

metadata_resolver()

metadata_resolver() = fun((metadata_value() | metadata_tombstone(), metadata_value() | metadata_tombstone()) -> metadata_value())

metadata_tombstone()

metadata_tombstone() = '$deleted'

metadata_value()

metadata_value() = any()

put_opts()

put_opts() = []

Function Index

delete/2same as delete(FullPrefix, Key, []).
delete/3Removes the value associated with the given prefix and key locally and then triggers a broradcast to notify other nodes in the cluster.
fold/3same as fold(Fun, Acc0, FullPrefix, []).
fold/4Fold over all keys and values stored under a given prefix/subprefix.
get/2same as get(FullPrefix, Key, []).
get/3Retrieves the local value stored at the given prefix and key.
iterator/1same as iterator(FullPrefix, []).
iterator/2Return an iterator pointing to the first key stored under a prefix.
itr_close/1Closes the iterator.
itr_default/1Returns the value returned when an iterator points to a tombstone.
itr_done/1Returns true if there is nothing more to iterate over.
itr_key/1Return the key pointed at by the iterator.
itr_key_values/1Return the key and value(s) pointed at by the iterator.
itr_next/1Advances the iterator.
itr_value/1Return a single value pointed at by the iterator.
itr_values/1Return all sibling values pointed at by the iterator.
prefix_hash/1Return the local hash associated with a full-prefix or prefix.
put/3same as put(FullPrefix, Key, Value, []).
put/4Stores or updates the value at the given prefix and key locally and then triggers a broadcast to notify other nodes in the cluster.
to_list/1same as to_list(FullPrefix, []).
to_list/2Return a list of all keys and values stored under a given prefix/subprefix.

Function Details

delete/2

delete(FullPrefix::metadata_prefix(), Key::metadata_key()) -> ok

same as delete(FullPrefix, Key, [])

delete/3

delete(FullPrefix::metadata_prefix(), Key::metadata_key(), Opts::delete_opts()) -> ok

Removes the value associated with the given prefix and key locally and then triggers a broradcast to notify other nodes in the cluster. Currently there are no delete options

NOTE: currently deletion is logical and no GC is performed.

fold/3

fold(Fun::fun(({metadata_key(), [metadata_value() | metadata_tombstone()] | metadata_value() | metadata_tombstone()}, any()) -> any()), Acc0::any(), FullPrefix::metadata_prefix()) -> any()

same as fold(Fun, Acc0, FullPrefix, []).

fold/4

fold(Fun::fun(({metadata_key(), [metadata_value() | metadata_tombstone()] | metadata_value() | metadata_tombstone()}, any()) -> any()), Acc0::any(), FullPrefix::metadata_prefix(), Opts::fold_opts()) -> any()

Fold over all keys and values stored under a given prefix/subprefix. Available options are the same as those provided to iterator/2. To return early, throw {break, Result} in your fold function.

get/2

get(FullPrefix::metadata_prefix(), Key::metadata_key()) -> metadata_value() | undefined

same as get(FullPrefix, Key, [])

get/3

get(FullPrefix::metadata_prefix(), Key::metadata_key(), Opts::get_opts()) -> metadata_value()

Retrieves the local value stored at the given prefix and key.

get/3 can take the following options: * default: value to return if no value is found, undefined if not given. * resolver: A function that resolves conflicts if they are encountered. If not given last-write-wins is used to resolve the conflicts * allow_put: whether or not to write and broadcast a resolved value. defaults to true.

NOTE: an update will be broadcast if conflicts are resolved and allow_put is true. any further conflicts generated by concurrenct writes during resolution are not resolved

iterator/1

iterator(FullPrefix::metadata_prefix()) -> iterator()

same as iterator(FullPrefix, []).

iterator/2

iterator(FullPrefix::metadata_prefix(), Opts::it_opts()) -> iterator()

Return an iterator pointing to the first key stored under a prefix

iterator/2 can take the following options: * resolver: either the atom lww or a function that resolves conflicts if they are encounted (see get/3 for more details). Conflict resolution is performed when values are retrieved (see itr_value/1 and itr_key_values/1). If no resolver is provided no resolution is performed. The default is to not provide a resolver. * allow_put: whether or not to write and broadcast a resolved value. defaults to true. * default: Used when the value an iterator points to is a tombstone. default is either an arity-1 function or a value. If a function, the key the iterator points to is passed as the argument and the result is returned in place of the tombstone. If default is a value, the value is returned in place of the tombstone. This applies when using functions such as itr_values/1 and itr_key_values/1. * match: A tuple containing erlang terms and '_'s. Match can be used to iterate over a subset of keys -- assuming the keys stored are tuples

itr_close/1

itr_close(X1::iterator()) -> ok

Closes the iterator

itr_default/1

itr_default(It::iterator()) -> metadata_tombstone() | metadata_value() | it_opt_default_fun()

Returns the value returned when an iterator points to a tombstone. If the default used when creating the given iterator is a function it will be applied to the current key the iterator points at. If no default was provided the tombstone value was returned. This function should only be called after checking itr_done/1.

itr_done/1

itr_done(X1::iterator()) -> boolean()

Returns true if there is nothing more to iterate over

itr_key/1

itr_key(X1::iterator()) -> metadata_key()

Return the key pointed at by the iterator. Before calling this function, check the iterator is not complete w/ itr_done/1. No conflict resolution will be performed as a result of calling this function.

itr_key_values/1

itr_key_values(X1::iterator()) -> {metadata_key(), [metadata_value() | metadata_tombstone()] | metadata_value() | metadata_tombstone()}

Return the key and value(s) pointed at by the iterator. Before calling this function, check the iterator is not complete w/ itr_done/1. If a resolver was passed to iterator/0 when creating the given iterator, siblings will be resolved using the given function or last-write-wins (if lww is passed as the resolver). If no resolver was used then no conflict resolution will take place. If conflicts are resolved, the resolved value is written to local metadata and a broadcast is submitted to update other nodes in the cluster if allow_put is true. If allow_put is false the values are resolved but are not written or broadcast. A single value is returned as the second element of the tuple in the case values are resolved. If no resolution takes place then a list of values will be returned as the second element (even if there is only a single sibling).

NOTE: if resolution may be performed this function must be called at most once before calling itr_next/1 on the iterator (at which point the function can be called once more).

itr_next/1

itr_next(X1::iterator()) -> iterator()

Advances the iterator

itr_value/1

itr_value(X1::iterator()) -> metadata_value() | metadata_tombstone() | {error, conflict}

Return a single value pointed at by the iterator. If there are conflicts and a resolver was specified in the options when creating this iterator, they will be resolved. Otherwise, and error is returned. If conflicts are resolved, the resolved value is written locally and a broadcast is performed to update other nodes in the cluster if allow_put is true (the default value). If allow_put is false, values are resolved but not written or broadcast.

NOTE: if resolution may be performed this function must be called at most once before calling itr_next/1 on the iterator (at which point the function can be called once more).

itr_values/1

itr_values(X1::iterator()) -> [metadata_value() | metadata_tombstone()]

Return all sibling values pointed at by the iterator. Before calling this function, check the iterator is not complete w/ itr_done/1. No conflict resolution will be performed as a result of calling this function.

prefix_hash/1

prefix_hash(Prefix::metadata_prefix() | binary() | atom()) -> binary() | undefined

Return the local hash associated with a full-prefix or prefix. The hash value is updated periodically and does not always reflect the most recent value. This function can be used to determine when keys stored under a full-prefix or prefix have changed. If the tree has not yet been updated or there are no keys stored the given (full-)prefix. undefined is returned.

put/3

put(FullPrefix::metadata_prefix(), Key::metadata_key(), ValueOrFun::metadata_value() | metadata_modifier()) -> ok

same as put(FullPrefix, Key, Value, [])

put/4

put(FullPrefix::metadata_prefix(), Key::metadata_key(), ValueOrFun::metadata_value() | metadata_modifier(), Opts::put_opts()) -> ok

Stores or updates the value at the given prefix and key locally and then triggers a broadcast to notify other nodes in the cluster. Currently, there are no put options

NOTE: because the third argument to this function can be a metadata_modifier(), used to resolve conflicts on write, metadata values cannot be functions. To store functions in metadata wrap them in another type like a tuple.

to_list/1

to_list(FullPrefix::metadata_prefix()) -> [{metadata_key(), [metadata_value() | metadata_tombstone()] | metadata_value() | metadata_tombstone()}]

same as to_list(FullPrefix, [])

to_list/2

to_list(FullPrefix::metadata_prefix(), Opts::fold_opts()) -> [{metadata_key(), [metadata_value() | metadata_tombstone()] | metadata_value() | metadata_tombstone()}]

Return a list of all keys and values stored under a given prefix/subprefix. Available options are the same as those provided to iterator/2.


Generated by EDoc