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
The key observation here is leaf nodes contains all the key/value pairs, if we store the leaf nodes separately in the same way as versiondb, we can query or iterate the key/value pairs directly without traversing the branch nodes.
Put it another way, it avoids the duplications between iavl and versiondb, or has fully integrated versiondb inside the iavl, and we won't need the fast node index anymore.
We assumeI the db has fully migrated to new node key format here, so we can get the version from the node key. It probably don't work with the lazy migration, aka. the mixed mode.
funcgetLeaf(key []byte, versionint64) Node {
// leaf nodes are stored in similar way as versiondbvalue:=versiondb.Get(key, version)
// compute the node hash on the flyreturnMakeLeafNode(version, key, value)
}
funcgetNode(nodeKeyNodeKey) Node {
// load the branch node with the new node key format
}
funcgetRightChild(n*Node) Node {
ifn.flag&RightLeaf>0 {
returngetLeaf(n.key, n.rightChildKey.version)
} else {
returngetNode(n.rightChildKey)
}
}
funcgetLeftChild(n*Node) Node {
ifn.flag&LeftLeaf>0 {
// `leftKey` is a new field which stores the key of it's left child, only need for the `height==1` nodes.returngetLeaf(n.leftKey, n.leftChildKey.version)
} else {
returngetNode(n.leftChildKey)
}
}
Highlights
Nodes whose height==1 need to add a new field leftKey to store the key of it's left child (the original key field is the key of right child).
Need to do an explicit deletion operation when deleting a key/value pair, previously just implicitly orphan the old leaf.
Don't store the leaf node hash on disk at all, since it's trivial to recompute on the fly, we can cache the hash in the cached node though.
Support a new pruning mode that only prune the branch nodes, but leave the archived leaf nodes, which can still supports archived historical state queries.
Don't need the fast node index anymore, it'll be as fast as that for queries at all versions.
VersionDB only supports rocksdb and pebbledb as backends.
The text was updated successfully, but these errors were encountered:
yihuang
changed the title
leaf separation
leaf separation or versiondb integration
May 4, 2023
When optimizing for reads and space on disk it definitely makes sense to consider a SS backend without inner nodes, with the (big) caveat that we'll need to support historical proofs in some other way.
The key observation here is leaf nodes contains all the key/value pairs, if we store the leaf nodes separately in the same way as versiondb, we can query or iterate the key/value pairs directly without traversing the branch nodes.
Put it another way, it avoids the duplications between iavl and versiondb, or has fully integrated versiondb inside the iavl, and we won't need the fast node index anymore.
We assumeI the db has fully migrated to new node key format here, so we can get the version from the node key. It probably don't work with the lazy migration, aka. the mixed mode.
Highlights
Node
s whoseheight==1
need to add a new fieldleftKey
to store the key of it's left child (the original key field is the key of right child).The text was updated successfully, but these errors were encountered: