Morton Code & Z-Curve Plan Decomposition
BlackGrid maps multi-attribute agent queries into 1D space-filling Z-curves, translating 2D GoogleSQL range predicates into minimal, highly-localized Bigtable RowRangeList scans.
2D Morton Z-Order Curve & Subcell Space
16×16 coordinate grid (0..15 × 0..15) interleaved into 8-bit Morton keys (0x00..0xFF)
Morton Bit-Interleaving (X & Y → Z Key)
x | (y << 1)Bigtable Storage Plan Insights
bg#agt_7f#mem#z16#<HEX>-- GoogleSQL via BlackGrid Z-Planner (ZetaSQL AST -> Bigtable RowRangeList) SELECT memory_id, agent_session_id, MORTON_HEX_2D(semantic_cluster, decay_epoch) AS z_row_prefix, cosine_salience, payload_proto FROM `blackgrid.agent_episodic_memory` WHERE tenant_id = 'agt_7f' AND semantic_cluster BETWEEN 4 AND 9 AND decay_epoch BETWEEN 4 AND 9 ORDER BY z_row_prefix ASC LIMIT 128;
How BlackGrid Bridges GoogleSQL and Bigtable Z-Curves
BlackGrid parses standard GoogleSQL queries (e.g. episodic memory semantic cluster & temporal decay), identifying multi-dimensional BETWEEN, >=, and <= predicates to establish a hyper-rectangle bounding box.
Coordinates are mapped to 1D Morton space via bit-twiddling magic numbers. BlackGrid’s Golang planner calculates BIGMIN/LITMAX jumps to prune dead space without evaluating every individual point, preserving sub-millisecond planning latencies.
The coalesced Z-intervals are converted directly into Cloud Bigtable RowRange objects. SSTable block reads are localized to specific tablet servers, eliminating secondary index lookup roundtrips for agent memory recall.
