Open vitiral opened 1 year ago
The basic design is
picker.someField
returns a Query object which has picker=picker, path={'someField'}
in_
, lte
, filter
, etc. These all append to the Query.ops
list, which influence what happens when the query is executed. Note that the query is NOT executed immediately.
I'm really enjoying using Lua.
I've thought for a long time about what the "base type" of the system should be. The basic type is a List of structs, where you can run queries on the structs and there is an index on that array. The structs wouldn't even have to be stored locally -- they could be in the filesystem.
The type to interface with all this will be called a
Picker
. The default implementation will be a picker on a List of some struct. You retrieve items with Query.The basic interface looks like
The picker is not just a view onto the list though: it can contain an
lookup
of one or more struct fields, which is just a Map[value, List[index]] to say which indexes are at a specific key -- useful forisIn
comparisons. Comparable fields can also have asortedLookup
so thatlte
/ etc operators can be found using a binary search (O(logn) instead of O(n)).A Picker can be backed by either a
List
or an Iter/function (iterators are implemented as functions in lua, but I also have an Iter type). Each call to a picker method returns a PickerIter, which is an iterator that still has access to the picker data.