I played with something like that in Python a couple of years ago, but never made it production-ready. I think in many simple cases it could replace a dedicated (SQL) database.
I played with something like that in Python a couple of years ago, but never made it production-ready. I think in many simple cases it could replace a dedicated (SQL) database.
The other reason is that most often you only need an index on one field, and don’t need the elements to be in a particular order, so you just use a map/dict with the value of that field, instead of a list.
The index is already a "simple in-memory list", sorted. That's why it is expensive to mantain.
> It would be great if you could have a std::vector or Python list of plain old objects
Sort said Python list by the columns in your index.
> and then tell it to add an index (using a hashtable for example) on one or two of the fields.
Hashtable is another thing entirely, and designed for fast key retrieval at very high memory and CPU cost. If you can't afford a index you can't afford a Hashtable/dict either.
The added benefit is that you can also dump it to the drive if you have to prematurely end your task and resume it from the same place later. And it also supports indexes, both traditional and full-text searching.
It's a lot easier to use a tool designed for the task instead of building one from scratch.
This is what a LinkedHashMap (1 index) and HashBasedTable (2 indices) do in the jvm-land. Admittedly, there isn't a convenience api to convert a given collection/vector to a map/table (but hey, if you're like me and write a lot of golang, then the current jvm-land status quo is already heaven!).
https://guava.dev/releases/snapshot-jre/api/docs/com/google/...
That's probably why such a library doesn't exist. Sorting & search is good enough for one field. Full scans aren't that bad for small/medium datasets. And databases aren't that difficult to integrate into an application.
Also, pandas exists in the Python world.
Pandas is also very powerful, but everytime I go to use it I feel I have to learn the API all over again.
I think Prolog (another commenter pointed it out) and datalog do this to some extend.