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
{{ message }}
This repository was archived by the owner on Jan 8, 2026. It is now read-only.
The bitwidth wasn't fixed for all levels. E.g., start with a bitwidth of 3 and then increase by 1 bit (double the elements) per level. I'm not sure how to do this and avoid re-writing all nodes on resize.
The number of elements in the leaves was proportional to the size of the leaf, not the actual number of elements. This is far from easy, but it would be so nice.
The depth wasn't related to the maximum element. We'd need to include offsets to make this work, but that shouldn't be difficult.
Better support for sparse AMTs. HAMTs don't have this issue because they store KV pairs. AMTs can more efficiently pack values by not storing the keys. A solution here would be to map offsets to sequential ranges (also fixes the depth issue).
At the end of the day, I'm thinking something like (rough idea):
type AMT struct {
...
node AMTNode
}
// This expands into an array indexed by "bitwidth" bits of the index.
type AMTNode struct {
prefix Int // I need _some_ way to say "this is a common prefix all elements share.
bitmap Bytes
children [AMTElement]
}
// If an element is a shard, we lookup the key within that shard. Otherwise, we load the child node.
type AMTElement union {
| &AMTNode link
| AMTShard map
} representation kinded
// A shard is a sequence of values at some offset.
type AMTShard struct {
offset Int
values [Any]
}
The tricky part here is deciding how big these shards should be and deciding when they need to be popped out into their own nodes.
Edit: I think we're going to need an additional offset
I'd really love an AMT where:
At the end of the day, I'm thinking something like (rough idea):
The tricky part here is deciding how big these shards should be and deciding when they need to be popped out into their own nodes.
Edit: I think we're going to need an additional offset