You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was going over the insert method of the Trie struct and subsequently the implementation of iterative_insert. Finally I ended up on the with_key_value associated method of the TrieNode
Why does the TrieNode store the KeyValue pair and not just the value? I would imagined the key fragments in the NibbleVec represent the key. Doesn't storing the full key defeat the purpose of the trie?
I could be missing something, hence this question 🙂
The text was updated successfully, but these errors were encountered:
Hey @mattgathu, you raise a very good point, and I don't believe you're missing anything. I would be interested to try the optimisation you suggest, which would likely require adding functions to deserialise the bytes of the NibbleVec back into the key type
Similar to the encode methods, we could make one of these methods optional.
You've shown you have a pretty great understanding of the code, so if you'd like to try implementing this I'd be willing to provide tips here and there
I was going over the
insert
method of theTrie
struct and subsequently the implementation ofiterative_insert
. Finally I ended up on thewith_key_value
associated method of theTrieNode
It looks like this:
rust_radix_trie/src/trie_node.rs
Lines 52 to 63 in 0e295e8
and the
TrieNode
struct itself:rust_radix_trie/src/trie_node.rs
Lines 6 to 21 in 0e295e8
Question
Why does the TrieNode store the KeyValue pair and not just the value? I would imagined the key fragments in the
NibbleVec
represent the key. Doesn't storing the full key defeat the purpose of the trie?I could be missing something, hence this question 🙂
The text was updated successfully, but these errors were encountered: