Module shards_lib

Common Shards Utilities.

Description

Common Shards Utilities.

Data Types

kv_list()

kv_list() = [{any(), any()}]

Function Index

get_pid/1 Returns the PID associated to the Name.
iterator/1 Returns a sequence of integers that starts with 0 and contains the successive results of adding +1 to the previous element, until NumShards is reached or passed (in the latter case, NumShards is not an element of the sequence).
key_from_object/1 Returns the key for the given object or list of objects.
keyfind/2Equivalent to keyfind(Key, KVList, undefined).
keyfind/3 Returns the value to the given Key or Default if it doesn't exist.
keyupdate/3Equivalent to keyupdate(Fun, Keys, undefined, TupleList).
keyupdate/4 Updates the given Keys by the result of calling Fun(OldValue).
list_shards/2 Returns the list of shard names associated to the given TabName.
pick/3 Pick/computes the shard where the Key will be handled.
read_tabfile/1 Reads the file info related to a tabfile saved previously.
reduce_while/3 Reduces the List until fun returns {halt, any()}'.
shard_name/2 Builds a shard name ShardName.
to_string/1 Converts the input data to a string.
write_tabfile/2 Writes to a file a content related to a table.

Function Details

get_pid/1

get_pid(Name::atom()) -> pid() | no_return()

Returns the PID associated to the Name.

iterator/1

iterator(StateOrNumShards::shards_state:state() | pos_integer()) -> Iterator::[integer()]

Returns a sequence of integers that starts with 0 and contains the successive results of adding +1 to the previous element, until NumShards is reached or passed (in the latter case, NumShards is not an element of the sequence).

key_from_object/1

key_from_object(ObjOrObjs::tuple() | [tuple()]) -> Key::any()

Returns the key for the given object or list of objects.

keyfind/2

keyfind(Key, KVList) -> any()

Equivalent to keyfind(Key, KVList, undefined).

keyfind/3

keyfind(Key::term(), KVList::kv_list(), Default::term()) -> term()

Returns the value to the given Key or Default if it doesn't exist.

keyupdate/3

keyupdate(Fun, Keys, TupleList) -> any()

Equivalent to keyupdate(Fun, Keys, undefined, TupleList).

keyupdate/4

keyupdate(Fun::fun((Key::any(), Value::any()) -> any()), Keys::[any()], Init::any(), KVList1::kv_list()) -> KVList2::kv_list()

Updates the given Keys by the result of calling Fun(OldValue). If Key doesn't exist, then Init is set.

list_shards/2

list_shards(Tab::atom(), NumShards::pos_integer()) -> ShardNames::[atom()]

Returns the list of shard names associated to the given TabName. The shard names that were created in the shards:new/2,3 fun.

pick/3

pick(Key::shards_state:key(), Range::shards_state:range(), Op::atom()) -> Result::non_neg_integer()

Pick/computes the shard where the Key will be handled.

read_tabfile/1

read_tabfile(Filename::shards_local:filename()) -> term() | no_return()

Reads the file info related to a tabfile saved previously.

reduce_while/3

reduce_while(Fun::fun((Elem::any(), Acc::any()) -> FunRes), AccIn::any(), ListOrMap::[any()] | map()) -> Result::any()

Reduces the List until fun returns {halt, any()}'.

shard_name/2

shard_name(Tab::atom(), Shard::non_neg_integer()) -> ShardName::atom()

Builds a shard name ShardName.

to_string/1

to_string(Data::any()) -> string() | no_return()

Converts the input data to a string.

write_tabfile/2

write_tabfile(Filename::shards_local:filename(), Content::term()) -> ok | {error, term()}

Writes to a file a content related to a table.


Generated by EDoc