Big_map
A lazily deserialized map that's intended to store large amounts of data.
"Lazily" means that storage is read or written per key on demand. Therefore
there are no map
, fold
, and iter
operations as there are in
Map.
Compared to non-lazy maps, which have a high upfront gas cost to deserialize all the data and then have cheaper access costs thereafter, lazily-deserialized maps spread this cost out across each access, increasing the per-access gas costs, but providing a cheaper overall cost when only a small portion of a large dataset is needed.
function empty : big_map ('key, 'value)
Create an empty big_map.
Alternatively, you can also create an empty big_map using:
function literal : list ('key * 'value) -> big_map ('key, 'value)
Create a non-empty big_map.
Alternative way of creating an empty big_map:
function find_opt : 'key -> big_map ('key, 'value) -> option 'value
Retrieve a value from a big map with the given key.
Because the key may be missing in the big map, the result is an optional value.
Alternatively:
function mem : 'key -> big_map ('key, 'value) -> bool
Test whether a given key exists within a big map.
function update : 'key -> option 'value -> big_map ('key, 'value) -> big_map ('key, 'value)
Note: when None
is used as a value, the value is removed from the big_map.
Alternatively:
If multiple bindings need to be updated, PascaLIGO offers a patch instruction for maps, similar to that for records.
Note the use of the keyword
map
instead ofbig_map
(which is not a keyword).
function get_and_update : key -> option(value) -> big_map (key, value) -> option(value) * big_map (key, value)
Similar to update
but it also returns the value that was previously stored in the big_map
function add : 'key -> 'value -> big_map ('key, 'value) -> big_map ('key, 'value)
function remove: 'key -> big_map ('key, 'value) -> big_map ('key, 'value)
Alternatively, the instruction remove key from map m
removes the key
key
from the big map m
(note that the keyword is map
, not
big_map
).