HexxlaDB uses Morton (Z-order) encoding to pack hexagonal coordinates into compact keys that preserve spatial locality in the B+ tree. This makes ring walks and neighborhood scans efficient prefix operations.Documentation Index
Fetch the complete documentation index at: https://hexxladb.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Coordinate packing scheme
To support efficient ring scans and spatial locality:- Convert axial
(q, r)to cube coordinates(q, r, s)wheres = -q - r - Zigzag-encode each signed coordinate to unsigned values
- Compute a Morton (Z-order) code by interleaving the bits of the encoded values
PackedCoord (typically 128-bit or wider) is used as the primary key.
PackedCoord
- Spatially close coordinates have nearby keys
- Ring walks become efficient prefix scans
- Scales with ring area, not database size
- High-order bits support future super-hex region identifiers for sharding
Packing and unpacking
Morton ordering
Morton ordering maps spatially close points to nearby keys with high probability. This is expected to benefit neighborhood operations like ring walks and context assembly. Why Morton encoding?- Preserves spatial locality in the B+ tree
- Enables efficient prefix scans for ring enumeration
- Natural support for hierarchical clustering (super-hex regions)
- Deterministic and reversible
Key family encoding
Cell keys
cell/0x1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p
Facet keys
facet/0x1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p/1
Edge keys
edge/0x1a2b.../0x2c3d.../see-also
Seam keys
Primary:seam/01H5X9Y8Z7W6V5U4T3S2R1Q0P9O8N7M
Secondary (by cells):
PackedCoord first) so each pair appears once.
Embedding keys
HNSW keys
Secondary index keys
Tag index:MVCC version suffixes
When MVCC is enabled (format v2), version suffixes are appended:commit_seq.
Timeline keys
Map wall-clockas_of to snapshots:
ViewAtTime on format v2.
Key ordering
Keys are ordered lexicographically within each family. This enables:- Efficient range scans for ring walks
- Prefix scans for neighborhood queries
- Ordered iteration for secondary indexes
Zigzag encoding
Signed coordinates are zigzag-encoded before Morton interleaving:- Maps signed integers to unsigned integers
- Preserves ordering: smaller signed values map to smaller unsigned values
- Enables bit interleaving without sign bit complications
See also
- Storage layout — Key families and on-disk format
- Coordinates — Hexagonal addressing system
- MVCC — Multi-version concurrency control