-
Notifications
You must be signed in to change notification settings - Fork 11
Description
There is currently no way to get all the keys or values from a Store Map. A simple workaround is to use both a Map and a Var, to track the set of keys used in the Map. This is rather inefficient, both for the extra storage and since extracting all the values from the map requires repeated lookup operations. Plus the extra overhead/mistake potential of keeping the key Set synced with the Map.
It should be possible to directly support this. IAVL is designed specifically with this use case in mind, keys are stored sequentially and there are operations to iterate over all keys/values in a tree or within a key range. This behavior is exposed through the gRPC layer with the List procedure.
I would propose adding methods such as: keys and toMap/toList to the Map Store interface which would need to be backed by an iterate method in the RawStore/IAVLStore to get all keys/values under a particular prefix/substore.
I think this could also be used to improve the efficiency of operations like foldl in List and Array since they are currently using repeated lookups to access sequentially stored values.