One more question: Is there a more optimal data structure for a multi-level random lookup table like this, other than nesting? One way I can think of is to create a interrelated index of keys, point to index of the sequence. But how to construct the interrelated index?
FromIterator does not currently support such conversions:
the trait FromIterator<(K1, K2, K3, V)> is not implemented for BTreeMap<K1, BTreeMap<K2, BTreeMap<K3, V>>>
The meaning of a "random lookup table" is that I not only need to get Vs from (K1, K2, K3), but also (K3, V)s from (K1, K2), (K2, K3, V)s from K1, and maybe even (K2, V)s from (K1, K3), etc.
Described with the relational database model, the index I mentioned earlier is analogous to a table containing v_index as the primary key and three other fields k1, k2, k3, with indexes created for all of them. (In other words, embedding a sqlite running in memory mode in the application would solve the problem, but obviously overkilled.)
I'm not the kind of person who reach out their hands and ask for everything in the community, and I'm already continuing to think about how to implement this index. This is likely not something that can be described in a few sentences.