API Reference
Version scope: Python 0.0.17 / JavaScript 0.5.10. Read-only SQL is included from Python 0.0.14 / npm 0.5.6; entity keys, progressive geometry and structured ragged/CSR from 0.0.11 / 0.5.3. See feature examples and limits for the supported boundaries; older packages may not expose these methods.
Selected public signatures are matched to the 0.0.17 release source (tag python-v0.0.17). This page covers common pipeline operations; the feature guide adds query controls, entity-key, geometry and structured-array examples rather than claiming an exhaustive API inventory.
Looking for SQL? from dreamdb import SqlSession is available from 0.0.14; see
SqlSession in the SQL guide.
Besides the module functions, dreamdb.__all__ lists
Schema, Dataset, SqlSession and, from 0.0.16, the result types EmbeddingAppendReport, SpatialCompactPass, SpatialEntry,
SpatialCellEntries and SpatialEntryMerge, and from 0.0.17 VideoUploader,
EmbeddingUploader and ScalarUploader.
Schema
Chainable field declarations. Every method returns the schema.
algorithm defaults to dreamdb.lsh-cosine, which requires a published spatial_index hash like every other partitioning algorithm — see Indexes. compressor takes a hash from publish_rabitq_compressor or train_and_publish_pq_compressor; rerank=True keeps full-precision vectors alongside compressed codes for a second scoring pass.
add_array declares a fixed-shape numeric value. Python accepts and returns NumPy arrays, validating the persisted dtype, shape, byte order, layout, codec, units, semantic type, frame, and axis order. The supported v1 dtypes are f32, f64, i8/i16/i32/i64, and u8/u16/u32/u64.
Dataset
Lifecycle
open recovers the schema from the manifest; pass one only if you want it checked field-for-field. open_at takes the dict snapshot() returned.
Writing
samples is a list of dicts keyed by field name. hot=True routes writes through a hot shard; threshold/age checks run during ingest, not in an independent background timer. Use flush_hot() when an explicit flush is needed. embedding_specs supplies per-field embedding identities, while vector queries use spec_id. ingest_video fragments a file with ffmpeg, so ffmpeg has to be on PATH.
Dataset.add_array adds an optional typed-array field to an existing dataset. add_constant supports the SDK's defined text, URI, SPDX, and JSON constant modalities; add_array_constant stores one typed NumPy array for the complete timeline.
From 0.0.16, appending an anchor that a typed-array field already holds is refused, and an array index that grows past 1 MiB is written in the paged form. Readers older than 0.0.16 / npm 0.5.8 refuse paged array Tracks, so upgrade readers first.
publish_prepared_video_item inserts or replaces one already-segmented video by opaque key and commits once. fragments are (bytes, relative_start_ns, relative_end_ns) tuples; there is no transcoding. With the default fragment_pack_bytes=0, every Fragment is its own Object. A positive value packs consecutive Fragments of that item into FragmentPacks of at most that many bytes. The target bounds each pack, not process memory; an empty Fragment or one larger than the target stays standalone, and no Fragment is split or transcoded. This changes the item's Object and Track hashes, and a narrow range read may become slower. set_application records an application name and revision on subsequent Manifest publications. It is self-reported metadata, so never pass credentials.
Split upload and commit (0.0.17+)
Each uploader writes objects without reading or moving the ref, so it can run on another thread while the same Dataset keeps committing. The matching commit call publishes through the ordinary conditional ref move and is bound to the Dataset's current Manifest: a ref moved by anyone else raises a conflict rather than being rebased.
upload_video_itemtakes the same arguments and validation aspublish_prepared_video_item. The receipt cannot be pickled or carried to another process.commit_video_itemscommits at most 64 receipts of one field, insert-only, in one ref move: every item or none.prepare_video_itemsreturns the exact candidate Manifest andreplaybytes; storereplaydurably beforepublish_prepared_video_items, and finish an unknown outcome withrepublish_video_items, which publishes only that exact candidate.append_embedding_layer_preparedis refused before any storage call if the field is no longer bound as the batch was encoded. The prepared batch is consumed whatever the outcome.scalar_uploaderstages on a snapshot and is refused while the Dataset holds staged work.commit_prepared_scalarrefuses a field whose bound version is no longer the one the stage grew; prepare again. The prepared append is consumed whatever the outcome.field_track_hashis local and read-only: the content address of the field's currently bound Track on this handle, orNone. It does not re-read the ref.
Reading and querying
The iter_* methods yield dicts of columns plus _time_anchors. query_* methods return anchors, or (anchor, score) tuples for the scored ones. nprobe widens a vector search across neighbouring cells.
rerank_pool_size is a positive integer at least top_k; omitted, it preserves
the five-times-top-k partition pool. rerank_mode is inherit, approximate
or exact. Explicit modes override the Schema for this query only; exact mode
refuses missing exact capability rather than falling back. These controls do
not widen probes or guarantee global recall. Graph queries reject explicit pool
size or non-inherit mode. See query examples and limits.
Behavior in 0.0.16. On a multi-table vector field, iter_vector returns each Item once and refuses replicas whose vectors differ. For compressed fields that comparison is over codes. A time-range read now raises when required metadata cannot be read, instead of returning None for that field. query_text, query_hybrid and query_phrase check the TextIndex/SPLADE binding at the first text query, so a mismatched binding fails there rather than at open.
http_stats() returns None on file:// and memory://. Otherwise it returns a dict of cumulative integer counters for the HTTP connector this Dataset uses: attempts_started, attempts_completed, retries_internal, put_redirect_hops, status_2xx…status_5xx, status_412, transport_errors, body_errors, cancelled, request_body_bytes, response_body_bytes, attempt_nanos_total, requests_get/head/put/post/delete/other and ranged_gets. Measure a phase by subtracting two snapshots taken at quiescence. Counters are per connector, so a branch() shares them, and they are never reset. Module-level helpers (train_and_publish_*, gc) and MCAP conversion use their own connectors and are not counted. Body byte counts exclude headers, TLS and compression, and attempt_nanos_total overlaps across concurrent attempts, so neither is a bandwidth or wall-clock figure.
The VideoItem metadata methods do not download media. item_key is opaque bytes and anchors remain exact Python integers. read_video_item_range returns initialization bytes and complete fragments overlapping an item-relative half-open range; it materializes the result in memory and never crosses into the next item.
The raw iter_stream fast path still requires an embedding field. A projection without one raises streaming iter with no embedding fields — use iter() for scalar-only:
Scalar-only datasets are otherwise usable: query_scalar, iter_scalar, distinct_values, list_anchors, count, and history all work without an embedding.
count() now works with every schema and excludes tombstoned anchors. It counts the union of distinct visible anchors across Tracks, so it is O(U_total) and materializes that anchor set rather than reading a stored counter.
iter_arrow_batches uses the embedding-only stream when exactly one embedding field is requested, and a windowed eager join for general projections. window_batches=None restores the fully eager behavior. Typed-array columns use Arrow FixedShapeTensor. The method needs pyarrow and NumPy, and says so when either is missing:
Versioning
Ingest checkpoints are explicit, operator-driven provenance resets. plan_* writes nothing, so persist the returned bytes before calling apply_ingest_checkpoint. storage_scope is the non-secret endpoint/bucket identity. The plain plan supports only standalone scalar and VideoItem data. The indexed plan covers cold IVF layers over VideoItem and emits lineage-v5, which older readers reject. Apply requires exclusive maintenance against GC. It keeps the old history under the plan's immutable archive tag and moves the Ref by CAS. After an uncertain result, reopen the Ref and apply the same plan. No data is merged or deleted. ingest_lineage_usage returns the canonical lineage bytes and their limit, not the headroom for the next write.
snapshot returns {"label": "<ref>@<label>", "manifest": "<hash>", "timeline": "<hash>"} — keep it to reopen that exact state. Details in Versioning.
Indexes and layers
A layer attaches a derived field to an existing one — a second embedding of the same images, a thumbnail, a text index. compact returns counters:
The 0.0.16 cell-maintenance methods are caller-driven and bounded. append_embedding_layer_with_report behaves like append_embedding_layer, and its EmbeddingAppendReport(modality, manifest, cells) names the (spatial_key, table_id) cells the append wrote Buckets to. spatial_key is a base-2 string and table_id is None for a single-table field.
compact_spatial_cells compacts only those named cells of an inline or paged SpatialBucket index. Every limit keyword is required, including the index-page limits on an inline index, and max_index_page_bytes must be at least 1 MiB. The pass stops at the first limit it cannot admit. SpatialCompactPass reports each cell as compacted, complete, absent or deferred, names the limit in stopped, and returns the counters it used. A stop still publishes the cells accepted before it.
spatial_cell_entries returns SpatialCellEntries(spatial_key, table_id, entries) of SpatialEntry values. merge_spatial_entries merges caller-chosen subsets of one cell's entries and publishes them by one Ref CAS against the tip it read. It raises without publishing if a named entry is missing from the tip or the merge would drop a record, and a concurrent writer also makes it raise.
There is no automatic maintenance policy. Recompacting growing cells repeatedly can cost rewrite work quadratic in cell size.
Metadata
Module functions
Jobs that happen outside a dataset's lifetime.
Each train_and_publish_* returns a 33-byte content multihash to pass as spatial_index= or compressor=. They are deterministic: the same sample, parameters, and seed produce the same hash, so two workers publishing independently is a content-addressed no-op rather than a conflict.
gc defaults to dry_run=True. Destructive GC additionally requires
writers_paused=True after externally stopping and draining writers, uploads,
staged transactions and root changes, with a settled Ref listing. Keep that
fence for the whole run; the flag acquires no lock. Use roots (base32 Manifest
hashes) to retain otherwise unrooted reader snapshots. An empty root set refuses.
A concurrent dry-run is advisory, not a reusable deletion plan; age retention
cannot protect a concurrent writer reusing old Objects. Version 0.0.12 fixes
reference-mode vector-pool retention, but does not recover already-deleted data.
PyTorch
See Training pipelines.