Erlang Native Implemented Functions around Judy arrays, written in C++.
Given enough system memory,
- Arbitary number of elements,
- Arbitary size of keys and elements.
- Nested arrays.
All NIF functions accessing the underlying array are wrapped with normal functions doing term()
to binary()
, and vice versa, translation prior storage or retrieval.
The array is modified in-place, and thus not a functional data structure.
Creates a new Judy array resource wrapped in a tuple.
1> judy:new().
{judy, <<>>}
Insert a new value into the array.
1> J = judy:new().
{judy, <<>>}
2> judy:insert(key, value, J).
{judy, <<>>}
3> judy:insert(key, value, J).
{judy, <<>>}
Remove a key/value from the array.
1> J = judy:new().
{judy, <<>>}
2> judy:insert(key, value, J).
{judy, <<>>}
3> judy:remove(key, J).
{judy, <<>>}
4> judy:remove(key, J).
{judy, <<>>}
Retrieve a value from the array.
- Returns the stored value or
{error, Key}
in case the key was not present.
1> J = judy:new().
{judy, <<>>}
2> judy:insert(key, value, J).
{judy, <<>>}
3> judy:get(key, J).
value
4> judy:get(foo, J).
{error,foo}
Retrieve multiple values from the array.
1> J = judy:new().
{judy, <<>>}
2> judy:insert(key, value, J).
{judy, <<>>}
3> judy:insert(key2, value2, J).
{judy, <<>>}
4> judy:mget([key, key2, key3], J).
[value,value2,{error,key3}]
This project, and all contributed code, are licensed under the FreeBSD License. A copy of the license can be found in the repository.