Object store
The objects plugin stores binary payloads in the database file and names them in a tree of files and directories.
Enable it at open with plugins {objects {}}. It has no settings.
See plugin selection for the open options.
Calls without it report the unavailable status.
The typed wrappers use plugin_call or plugin_stream with plugin objects.
Request members use lowerCamelCase, such as expectedRevision.
Payloads
A payload is an immutable byte sequence. Its digest is the SHA-256 of all its bytes.
Write a payload through an upload stream: write appends bytes in order and finish publishes the payload atomically.
Equal bytes publish one payload: a second finish of the same bytes reports deduplicated true and stores nothing new.
The database splits payloads into content-defined chunks of 256 KiB to 4 MiB, so edits to a large payload share most chunks with earlier versions.
manifest lists the chunks, and an open stream reads any byte range: seek moves its position and read copies from it.
Published payloads are never deleted. Removing a file or pointing it at another payload keeps the earlier payload, and history keeps every earlier version of the file. An upload that does not finish publishes nothing. Closing the stream abandons it, and the next open removes what an interrupted upload left behind.
Each upload holds a working buffer of up to 4 MiB from the database memory budget until it finishes or closes.
An upload that cannot fit reports out_of_memory. Calls on one stream are serialized; separate streams can run at the same time.
Digests cross the API as 64 hexadecimal digits in either case. Results show them as {#sha256 <hex>} values.
Files and directories
Every node lives under the root directory, entity 0. A directory holds named children; a file names one published payload.
Names are non-empty UTF-8 text without / or NUL, and are not . or ... Names are unique within a directory and hold at most 4096 bytes.
A record describes one node:
| Member | Value |
|---|---|
entity | The node's entity. |
parent | The parent directory's entity, 0 for the root. |
name | The node's name in its parent. |
kind | file or directory. |
revision | The transaction that last changed the node. |
size | A file's payload size in bytes. |
digest | A file's payload digest. |
create creates up to 4096 nodes in one commit.
A node names its parent by entity, or with under by the position of an earlier directory in the same request:
[
{:name "notes"}
{:name "hello.txt"
:under 1
:digest {:#sha256 "95e84da38cbefdf3f9f6ef02201074c73124f7cf2025d3e1d69e591a410856fb"}}]A file can name only a published payload.
A merge patch can also write stardust/object/digest on an entity; the commit then needs a published payload too.
Revisions
Each write commits atomically through the commit queue. A refused write changes nothing.
update, move and remove take an expected revision.
Pass the revision of a record you read to refuse the write when another writer changed the node since: the call reports conflict.
Pass 0 to skip the check.
An update to the current payload, or a move to the current name and parent, changes nothing and keeps the revision.
With replace true, a move can replace a destination node of the same kind.
A file replaces a file. A directory replaces only an empty directory.
Remove deletes a file or an empty directory.
Reads
Every tree read uses one snapshot of the database. Concurrent writes do not change a read in progress.
children lists a directory in name order.
path returns the names from the root to a node.
files finds the files that hold a payload.
A stream read verifies every chunk it reads against its digest and reports evaluation_failed when stored bytes do not match.
Without the plugin
On a database that does not enable objects, a write that sets stardust/object/digest fails with the unavailable status and the code plugin_required.
Payloads and files that the plugin stored stay in the database file and return when the plugin is enabled again.
Operations
| Operation | Returns | Summary |
|---|---|---|
| get | Unavailable | objects.get(entity) returns the owned record document of an object file or directory. |
| lookup | Unavailable | objects.lookup(parent, name) returns the owned record document of a directory's child. |
| children | Unavailable | objects.children(parent) returns an owned array document of a directory's child records in name order. |
| path | Unavailable | objects.path(entity) returns an owned array document of the names from the root to an object node. |
| files | Unavailable | objects.files(digest) returns an owned ascending array document of the file entities that hold a payload. |
| manifest | Unavailable | objects.manifest(digest) returns a published payload's owned manifest document. |
| create | Unavailable | objects.create(nodes) creates files and directories in one commit and returns an owned array document of their records. |
| update | Unavailable | objects.update(entity, digest, expected_revision) points a file at another published payload and returns its owned record document. |
| move | Unavailable | objects.move(entity, parent, name, expected_revision, replace) renames or moves a node and returns its owned record document. |
| remove | Unavailable | objects.remove(entity, expected_revision) removes a file or an empty directory. |
| upload | Unavailable | objects.upload() opens an owned plugin stream that uploads one payload. |
| open | Unavailable | objects.open(digest) opens an owned plugin stream that reads a published payload. |
get
C calls plugin operations through stardust_db_plugin_call and stardust_db_plugin_stream_open with a request document.
Also calls: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release
lookup
C calls plugin operations through stardust_db_plugin_call and stardust_db_plugin_stream_open with a request document.
Also calls: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release
children
C calls plugin operations through stardust_db_plugin_call and stardust_db_plugin_stream_open with a request document.
Also calls: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release
path
C calls plugin operations through stardust_db_plugin_call and stardust_db_plugin_stream_open with a request document.
Also calls: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release
files
C calls plugin operations through stardust_db_plugin_call and stardust_db_plugin_stream_open with a request document.
Also calls: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release
manifest
C calls plugin operations through stardust_db_plugin_call and stardust_db_plugin_stream_open with a request document.
Also calls: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release
create
C calls plugin operations through stardust_db_plugin_call and stardust_db_plugin_stream_open with a request document.
Also calls: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release
update
C calls plugin operations through stardust_db_plugin_call and stardust_db_plugin_stream_open with a request document.
Also calls: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release
move
C calls plugin operations through stardust_db_plugin_call and stardust_db_plugin_stream_open with a request document.
Also calls: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release
remove
C calls plugin operations through stardust_db_plugin_call and stardust_db_plugin_stream_open with a request document.
Also calls: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release
upload
C calls plugin operations through stardust_db_plugin_call and stardust_db_plugin_stream_open with a request document.
Also calls: stardust_db_plugin_stream_open, stardust_result_error, stardust_result_release
open
C calls plugin operations through stardust_db_plugin_call and stardust_db_plugin_stream_open with a request document.
Also calls: stardust_db_plugin_stream_open, stardust_result_error, stardust_result_release