Well, yeah, I understand that, but you use dets as a storage which is unordered. And dets can store data as erlang terms. But you still encode keys into binary. You could use ets with tab2file, for example, and it would have the ordering and you wouldn’t even have to encode keys in the first place.
I understand that dets is a temporary solution, but even if you choose any other storage, ordering of terms is a problem on the storage level. And when you allow only some keys to be encoded, it means that your abstraction is leaking and the limitation of storage level is getting exposed to the end user.
The better approach would be to
- Don’t encode keys and values during the whole pipeline
- Introduce ordering with comparators instead of binary comparison.
- Encode keys only when you have indexed them and you want to write them to the persistent storage
One possible algorithm I can think of is using B+ tree index with append-only file structure similar to what CubDB does. It’s not the best possible algorithm, but it just shows that sortability of keys-as-binaries is not a hard requirement and is rather a limitation of the approach you are planning to take in the future
I don’t quite get what you’re saying here. My best guess is that you’re talking about some algorithm which is not yet implemented and it allows to query data in the DB like by matching on the left part of tuple (and this tuple pattern has no size like {^first, ^second | _}). Well yeah, if someone wanted to do this, they would better have used the list as a key. Because this problem is not new, and ets has the same problem and the solution is also to just use lists






















