Start keys with NULL data start every scan at the first key in its direction, and end_keys stop it before a key, where zeroed ones bound nothing. ustore_scan_ascending_k walks the keys in [start, end) smallest first, and ustore_scan_descending_k those in (end, start] largest first.
The next ascending page starts from the key right after the last exported one, its 16 bytes incremented as one big-endian integer, a descending one from the key right before it, and a ustore_blobs_read of the found keys fetches their values. ustore_blobs_sample draws up to wanted keys uniformly at random, and ustore_blobs_measure bounds the cardinality, value bytes and disk usage of a range of keys from below and above, taking the same start, end and direction as a scan.
Every other modality samples and measures through its own _sample and _measure verbs, where the strings modality samples strings and measures ranges of them. ustore_scan_unordered_k is reserved for scans that may hand keys over out of order, and no engine acts on it yet.
A cursor walks the keys of one collection in pages, every pull resuming past the last key the pull before it handed out, and reads their values in the same call when values asks for them:
ustore_blobs_cursor_init reads nothing, and its view and start_key choose what the walk sees and where it starts, the head and the first key when zeroed, while an end_key stops it before a key and direction walks it down from its start.
A cursor keeps only the key its next pull starts at, so a key written behind it is never handed out and one written ahead of it is, while ustore_blobs_scan stays the batched listing of many ranges.
A page shorter than wanted exhausts the walk for good: every later pull writes zero keys without reading, even after writes ahead of where it stopped.
A pull that fails or is cancelled leaves the cursor where it was, and a pull at the head lists and reads at two moments, so a key removed between them reads as an empty value.
The cursor holds its database open, and the transaction or snapshot it reads through, until ustore_blobs_cursor_free, so the caller may free those handles first.
It serves one pull at a time, and a second pull naming it finishes ustore_status_contended_k. ustore_strings_cursor_init opens the same walk over the strings of one prefix from an optional start_string to an optional end_string, copying all three, and its pulls write the strings and their values as tapes.
ustore_changes_cursor_init opens a feed of the changes committed to one collection after since_stamp, oldest first, pinning that stamp as a snapshot does.
Every ustore_changes_cursor_next resumes past the last change the pull before it handed out, writing the key, the commit stamp and the ustore_change_kind_t of every change and, when asked, the bytes every change carries, where a range removal comes as the removal of every key it removed.
A key changed twice comes twice, once per commit, an empty pull reached the newest commit, and later pulls see later commits.
Versions already dropped refuse the init with ustore_status_write_conflict_k, and LevelDB, which keeps no stamps, with ustore_status_unsupported_k.
API
Types
ustore_pattern_kind_tWhat the strings of a ustore_patterns_t are matched as.
A zeroed structure matches everything. Patterns that fail to compile refuse the call with ustore_status_invalid_argument_k, carrying StringZilla's message.
ustore_predicate_callback_tAdmits or rejects count listed keys at once, never zero, writing one admission per key into admissions, a buffer the library owns for the call.
Keys come in order, each once, and only while present.
ustore_scan_unordered_k
1
Keys may come out of order, deleted or repeated, as each partition or run is walked on its own with no merge across them, so a page of fewer than all keys cannot resume where it ended.
It pins the stamp it reads from the way a snapshot does, so no compaction drops a version above it, and every pull resumes past the last change the pull before it handed out. Nothing reads ahead of the caller: a pull costs what it hands out. It serves one pull at a time and holds its database open until ustore_changes_cursor_free.
ustore_blobs_cursor_tAn opaque handle to a walk over the keys of one collection, which every pull resumes past the last key the pull before it handed out.
It keeps only the key its next pull starts at, so a key written behind the walk is never handed out and one written ahead of it is, while ustore_blobs_scan stays the batched listing of many ranges. It holds its database open, and the transaction or snapshot it reads through, until ustore_blobs_cursor_free. A cursor serves one pull at a time, so a second pull naming it finishes ustore_status_contended_k.
ustore_docs_cursor_tAn opaque handle to a walk over the document keys of one collection, which every pull resumes past the last key the pull before it handed out, as ustore_blobs_cursor_t walks.
It holds its database open, and the transaction or snapshot it reads through, until ustore_docs_cursor_free, and serves one pull at a time, so a second pull naming it finishes ustore_status_contended_k.
ustore_pages_cursor_tAn opaque handle to a walk over the page keys of one collection, which every pull resumes past the last key the pull before it handed out, as ustore_blobs_cursor_t walks.
It holds its database open, and the transaction or snapshot it reads through, until ustore_pages_cursor_free, and serves one pull at a time, so a second pull naming it finishes ustore_status_contended_k.
Functions
ustore_changes_cursor_initOpens a feed of one collection's changes committed after a stamp, reading nothing yet.
ustore_status_write_conflict_k means the versions after since_stamp are already gone, as no pin kept them, which a starved snapshot reader is refused with too. The RAM engine also refuses a stamp below the head unless an open feed already pins one at or below it, while NVMe and RocksDB serve any stamp their history still holds.
A pull yields every change committed after the last one it handed out, up to wanted; a key changed twice comes twice, once per commit, and the changes of one commit come by key. A range removal comes as the removal of every key it covered.
ustore_status_contended_k The arena or the cursor serves another call, the executor's deferred table is full, or a callback blocks on the executor running it.
ustore_changes_cursor_freeWaits until every deferred call naming the feed finishes, then frees it, releasing the stamp it pinned and the hold it kept on its database.
ustore_status_contended_k The arena or the transaction the view reads through serves another call, the executor's deferred table is full, a callback blocks on the executor running it, or an NVMe value keeps changing size across reads.
ustore_status_unsupported_k The executor computes on a device, where no engine serves the call yet, or on one matching no values, as AMD devices do, given patterns.
ustore_status_invalid_argument_k means the arena, collections or an output is missing, the mode, direction, a pattern kind, a case sensitivity or a predicate cost is unknown, the patterns do not compile, the view was made by neither view constructor or belongs to another engine, a watching scan goes through a staged transaction, or a collection holds another modality.
ustore_blobs_cursor_initOpens a walk over the keys of one collection, reading nothing until its first pull.
Executor of the kind every pull runs on, which picks the side the walk computes on, where NULL walks on host executors; a pull on another kind of executor reports ustore_status_device_k.
Optional verdict on the keys of every page, asked as its cost says; host executors only.
Statuses
ustore_status_invalid_argument_k The cursor output is NULL, the view was made by neither view constructor or reads another database, the direction, a pattern kind, a case sensitivity or a predicate cost is unknown, or the patterns do not compile.
Optional output for their values as a tape inside arena, so a walk reads without a second call, where a key removed at the head between the listing and the read of one pull reads as an empty value; NULL skips them.
Optional callback reporting the one pull, which may cancel it before the cursor advances.
progress_statevoid *
Opaque pointer passed to progress.
Statuses
ustore_status_invalid_argument_k The cursor, the arena or the written output is NULL, the cursor walks another database, a watching pull goes through a staged transaction, or the collection holds another modality.
ustore_status_device_k The arena lives where another executor computes, a cursor opened for a device is pulled on host threads, or a host cursor is pulled on a device.
ustore_status_contended_k The arena, the cursor or the transaction it reads through serves another call, the executor's deferred table is full, a callback blocks on the executor running it, or an NVMe value keeps changing size across reads.
ustore_*_cursor_free× 3Waits until every deferred call naming the cursor finishes, then frees it, giving back the holds it kept on its database and on the transaction or snapshot it reads through.
ustore_status_invalid_argument_k The arena, collections or an output is missing, the view was made by neither view constructor or belongs to another engine, a watching sample goes through a staged transaction, or a collection holds another modality.
ustore_status_contended_k The arena or the transaction the view reads through serves another call, the executor's deferred table is full, a callback blocks on the executor running it, or an NVMe value keeps changing size across reads.
ustore_status_contended_k The arena or the transaction the view reads through serves another call, the executor's deferred table is full, or a callback blocks on the executor running it.
Rewound by this call, then holding every output it writes; NULL is refused.
Statuses
ustore_status_invalid_argument_k means the arena or the collections are missing, the direction is unknown, the view was made by neither view constructor or belongs to another engine, a watching measure goes through a staged transaction, or a collection holds another modality.
ustore_docs_scanScans a batch of document key ranges.
ustore_status_contended_k The arena or the transaction the view reads through serves another call, the executor's deferred table is full, a callback blocks on the executor running it, or an NVMe value keeps changing size across reads.
ustore_status_invalid_argument_k means the arena, collections or an output is missing, the mode, direction or a predicate cost is unknown, the filter does not compile, the view was made by neither view constructor or belongs to another engine, a watching scan goes through a staged transaction, or a collection holds another modality.
ustore_docs_cursor_initOpens a walk over the document keys of one collection, compiling its filter once and reading nothing until its first pull.
Executor of the kind every pull runs on, which picks the side the walk computes on, where NULL walks on host executors; a pull on another kind of executor reports ustore_status_device_k.
Optional verdict on the keys of every page, asked as its cost says; host executors only.
Statuses
ustore_status_invalid_argument_k The cursor output is NULL, the view was made by neither view constructor or reads another database, a predicate cost is unknown, or the filter does not compile.
Optional output for the whole documents as a tape inside arena, where a key removed at the head between the listing and the read of one pull reads as an empty document; NULL skips them.
Optional callback reporting the one pull, which may cancel it before the cursor advances.
progress_statevoid *
Opaque pointer passed to progress.
Statuses
ustore_status_invalid_argument_k The cursor, the arena or the written output is NULL, the cursor walks another database, a watching pull goes through a staged transaction, or the collection holds another modality.
ustore_status_device_k The arena lives where another executor computes, a cursor opened for a device is pulled on host threads, or a host cursor is pulled on a device.
ustore_status_contended_k The arena, the cursor or the transaction it reads through serves another call, the executor's deferred table is full, a callback blocks on the executor running it, or an NVMe value keeps changing size across reads.
ustore_status_invalid_argument_k The arena, collections or an output is missing, the view was made by neither view constructor or belongs to another engine, a watching sample goes through a staged transaction, or a collection holds another modality.
ustore_status_contended_k The arena or the transaction the view reads through serves another call, the executor's deferred table is full, a callback blocks on the executor running it, or an NVMe value keeps changing size across reads.
ustore_status_invalid_argument_k means the arena or the collections are missing, the direction is unknown, the view was made by neither view constructor or belongs to another engine, a watching measure goes through a staged transaction, or a collection holds another modality.
ustore_status_contended_k The arena or the transaction the view reads through serves another call, the executor's deferred table is full, or a callback blocks on the executor running it.
Executor of the kind every pull runs on, which picks the side the walk computes on, where NULL walks on host executors; a pull on another kind of executor reports ustore_status_device_k.
Optional path in StringZilla's XPath subset every page the walk hands out holds a node of, copied and compiled here once; a zeroed view walks every page.
Optional verdict on the keys of every page, asked as its cost says; host executors only.
Statuses
ustore_status_invalid_argument_k The cursor output is NULL, the view was made by neither view constructor or reads another database, a predicate cost is unknown, or the filter does not compile.
Optional output for the whole pages rendered as a tape inside arena, where a key removed at the head between the listing and the read of one pull renders empty; NULL skips them.
Optional callback reporting the one pull, which may cancel it before the cursor advances.
progress_statevoid *
Opaque pointer passed to progress.
Statuses
ustore_status_invalid_argument_k The cursor, the arena or the written output is NULL, the outputs_encoding is unknown, the cursor walks another database, a watching pull goes through a staged transaction, or the collection holds another modality.
ustore_status_device_k The arena lives where another executor computes, a cursor opened for a device is pulled on host threads, or a host cursor is pulled on a device.
ustore_status_contended_k The arena, the cursor or the transaction it reads through serves another call, the executor's deferred table is full, a callback blocks on the executor running it, or an NVMe value keeps changing size across reads.
ustore_status_unsupported_k The outputs_encoding is HTML, Markdown or JSON, or the pulling executor's device loaded no bundle of the library's kernels and the walk has a filter.
ustore_status_invalid_argument_k The arena, collections or an output is missing, the view was made by neither view constructor or belongs to another engine, a watching sample goes through a staged transaction, or a collection holds another modality.
ustore_status_contended_k The arena or the transaction the view reads through serves another call, the executor's deferred table is full, or a callback blocks on the executor running it.
ustore_status_invalid_argument_k means the arena or the collections are missing, the direction is unknown, the view was made by neither view constructor or belongs to another engine, a watching measure goes through a staged transaction, or a collection holds another modality.
ustore_status_contended_k The arena or the transaction the view reads through serves another call, the executor's deferred table is full, or a callback blocks on the executor running it.