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
feat: make typed random-access structures configurable (config + @table directive)
main already gates struct-mode writes to primary DBIs (a2d0faf, for v4-downgrade
compat). This makes the primary-DBI default itself controllable:
- storage.randomAccessFields config (default off) — global default for primary stores
- @table(randomAccessFields: true) directive — per-table override, persisted at creation
(like sealed/compression)
- OpenDBIObject: primary randomAccessStructure now follows the config
(isPrimary && RANDOM_ACCESS_FIELDS); non-primary stays off (v4-downgrade compat unchanged)
Typed structures key on per-field value WIDTH, so wide/variably-typed schemas mint an
unbounded per-encoder dictionary (OOM) and diverge across replicas (decode failures);
defaulting them off for primary stores is the conservative choice, with opt-in where safe.
Also keep custom-index object stores (e.g. HNSW vector graphs) in struct mode regardless
of the config — their internal node shapes (numeric-keyed per-level connection arrays and
quantized bins) are fixed and rely on struct encoding, so the table-level default-off would
corrupt the graph.
Adds unit coverage for the config + directive wiring (databases.test.js,
randomAccessFieldsDirective.test.js).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: config-root.schema.json
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -460,6 +460,10 @@
460
460
"description": "Max write queue time before rejecting (e.g. '45s')."
461
461
},
462
462
"noReadAhead": { "type": "boolean", "description": "Advise OS to not read ahead. Default: false" },
463
+
"randomAccessFields": {
464
+
"type": "boolean",
465
+
"description": "Encode records as typed random-access structures, optimizing for fast field access and smaller records. Best for tables with stable, homogeneous field types; wide or variably-typed schemas should leave this off. Can be overridden per-table with the @table(randomAccessFields:) schema directive. Default: false"
466
+
},
463
467
"prefetchWrites": { "type": "boolean", "description": "Load data prior to write transactions. Default: true" },
464
468
"path": { "type": "string", "description": "Directory for all database files. Default: <rootPath>/database" },
0 commit comments