oak icon indicating copy to clipboard operation
oak copied to clipboard

ABI function for iterating over all the keys in the lookup data

Open tiziano88 opened this issue 4 years ago • 6 comments

This may be useful for use cases in which the code is trying to find the best (e.g. closest) item in the list of items.

tiziano88 avatar Jun 16 '21 10:06 tiziano88

@conradgrobler you had some ideas related to the leveldb, perhaps we could "emulate" (a subset of) its API, do you have any pointers to that? I think @mariaschett could help with this once we get more details.

tiziano88 avatar Oct 04 '21 16:10 tiziano88

A general overview of leveldb is at https://github.com/google/leveldb/blob/master/doc/index.md

The idea is to extened the lookup data feature to support a read-only version of the leveldb features. We already have a key-based lookup of data, so the main missing part is support for iterators (https://github.com/google/leveldb/blob/master/include/leveldb/iterator.h).

To implement this iteratively, I think the following steps could be a good approach:

  • Make the lookup data feature optional/pluggable similar to the ML and metrics features
  • Add a new lookup data feature that internally uses a tree map to support sorted data
  • Add iterator support to the ABI (e.g. create, seek, seek_to_first, seek_to_last, next, previous)
  • Add iterator support to the SDK

conradgrobler avatar Oct 04 '21 16:10 conradgrobler

Possibly relevant: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#

tiziano88 avatar Oct 04 '21 16:10 tiziano88

As first step, I wonder whether just switching from a hash map to a b-tree map may be a good stand-alone PR, so that we can check there are no regressions. Once that is submitted, then we can think about the additional API changes to expose to Wasm modules.

tiziano88 avatar Oct 06 '21 15:10 tiziano88

Also https://github.com/project-oak/oak/issues/2050 may be a prerequisite for this change.

tiziano88 avatar Oct 06 '21 16:10 tiziano88

As first step, I wonder whether just switching from a hash map to a b-tree map may be a good stand-alone PR, so that we can check there are no regressions. Once that is submitted, then we can think about the additional API changes to expose to Wasm modules.

Agreed: #2317

mariaschett avatar Oct 11 '21 10:10 mariaschett