BlackGrid Logo
BLACKGRIDGoogleSQL → Morton Engine

Multi-dimensional Z-Order Storage Layer for Bigtable • Database & Memory for Agents

QUERY INSIGHTS & EXECUTION PLANNER

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.

Bigtable RowRanges
5(raw: 5)
Contiguous gRPC SSTable scans
Scan Reduction
86%skipped
36 / 256 morton cells read
Target Query Latency
1.79ms8.57ms
4.8x faster than full scan
Locality / Precision
100%(36 true hits)
Zero false-positives at gap=0

2D Morton Z-Order Curve & Subcell Space

16×16 coordinate grid (0..15 × 0..15) interleaved into 8-bit Morton keys (0x00..0xFF)

▲ Temporal Epoch (Y) (Y: 0..15)
Semantic Cluster (X) (X: 0..15) ▶
AA
AB
AE
AF
BA
BB
BE
BF
EA
EB
EE
EF
FA
FB
FE
FF
A8
A9
AC
AD
B8
B9
BC
BD
E8
E9
EC
ED
F8
F9
FC
FD
A2
A3
A6
A7
B2
B3
B6
B7
E2
E3
E6
E7
F2
F3
F6
F7
A0
A1
A4
A5
B0
B1
B4
B5
E0
E1
E4
E5
F0
F1
F4
F5
8A
8B
8E
8F
9A
9B
9E
9F
CA
CB
CE
CF
DA
DB
DE
DF
88
89
8C
8D
98
99
9C
9D
C8
C9
CC
CD
D8
D9
DC
DD
82
83
86
87
92
93
96
97
C2
C3
C6
C7
D2
D3
D6
D7
80
81
84
85
90
91
94
95
C0
C1
C4
C5
D0
D1
D4
D5
2A
2B
2E
2F
3A
3B
3E
3F
6A
6B
6E
6F
7A
7B
7E
7F
28
29
2C
2D
38
39
3C
3D
68
69
6C
6D
78
79
7C
7D
22
23
26
27
32
33
36
37
62
63
66
67
72
73
76
77
20
21
24
25
30
31
34
35
60
61
64
65
70
71
74
75
0A
0B
0E
0F
1A
1B
1E
1F
4A
4B
4E
4F
5A
5B
5E
5F
08
09
0C
0D
18
19
1C
1D
48
49
4C
4D
58
59
5C
5D
02
03
06
07
12
13
16
17
42
43
46
47
52
53
56
57
00
01
04
05
10
11
14
15
40
41
44
45
50
51
54
55
SQL Predicate Hit
Coalesced Gap (False Positive)
Z-Order Curve
Dynamic SQL Query Bounds (`BETWEEN` ranges)
X Min4
X Max9
Y Min4
Y Max9
Golang Coalesce Gap Optimizer:maxGap = 2 cells
Merges contiguous intervals with gap ≤ 2 to avoid gRPC seek overhead

Morton Bit-Interleaving (X & Y → Z Key)

Spread Bits: x | (y << 1)
Hover over any cell in the 16×16 grid above to inspect its binary bit-interleaving and Bigtable rowkey prefix.

Bigtable Storage Plan Insights

Optimized
Target Tableblackgrid.agent_episodic_memory
RowKey Formatbg#agt_7f#mem#z16#<HEX>
Estimated QPS Capability~4,820 qps/node
Avg Tablet CPU Impact14% per 10k ops
Z-Curve Spatial Locality: Cross-quadrant query spanning multiple Z-seams. Gap coalescing reduced 5 raw ranges down to 5 Bigtable RPC ranges.
AST Engine
-- 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

1. ZetaSQL AST Extraction

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.

2. Morton Interleaving & BIGMIN

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.

3. Bigtable RowRangeList RPC

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.