Expose an order for folding over the context
This MR exposes an additional parameter to the functions folding over the context.
On flattened stores, some directories contain a large number of entries. Folding over such nodes - while ensuring that objects are visited in a sorted order - will require loading the entire node in memory, which is not memory efficient.
The fold
functions now expose a parameter order: [Sorted | Undefined]
, where the Undefined
option is memory efficient even when folding over large directories.
For simplicity, I have set the order to Sorted
everywhere for now.
Irmin exposes a third option Random of Random.State.t
but because Random
is not defined in lib_protocol, I did not exposed it in lib_context
. But it would be useful to do that for testing purposes: to ensure that, whenever the order
is not set to Sorted
then indeed the folding order is not relied on.