Liking cljdoc? Tell your friends :D

agentspaces.datascript

A DataScript database on a persistent ref (PDT 2 phase 2, group D; srad/agentspaces-pdt2.md §3.1). datascript-conn returns a DataScript conn whose d/transact! goes through a db ref of the system's ref space, so the database survives a restart and every member of the group reads it:

(def conn (pdt-ds/datascript-conn system "pdt" "graph" schema {}))
(d/transact! conn [{:person/name "Ada"}])   ; writes a head
(d/q '[:find ?n :where [_ :person/name ?n]] @conn)
  • A transaction's tx-data joins the tail, a dn node that the head carries inline while it fits; past 128 tail datoms, or :fold-every (30 s) after the last fold, the conn folds instead: the adapter writes the dirty paths of the three indexes and the next head names a root with no tail (P2-D-03).
  • Every head is PRef.v 2 of kind db; the ref is linear unless the facade's :pdt {:refs {name {:mode :multi}}} says otherwise, and two heads of a multi ref meet in the datom merge of agentspaces.datascript.merge.
  • Opening reads the head's root, and its tail when it has one, and nothing else; a query reads the index nodes on its path (P2-D-04, P2-D-05).
  • A transaction first brings the conn to the newest head its ref holds; when another writer moves the ref before the write, a linear conn refuses the transaction (ex-data ::moved) and holds the new head, and a multi conn merges the transaction with it by datoms.
  • A head another member writes replaces the conn's database, and the conn's listeners hear it as a report whose :tx-data is the change and whose :tx-meta names the root under :agentspaces.datascript/remote.

Options: :fold-every (a duration, "30s"), :instant (:date, the default, or :instant: the Java type an instant reads back as), and :await-head (a duration to wait at open for a head of the ref to arrive; none by default).

A DataScript database on a persistent ref (PDT 2 phase 2, group D;
srad/agentspaces-pdt2.md §3.1). `datascript-conn` returns a DataScript conn
whose `d/transact!` goes through a `db` ref of the system's ref space, so the
database survives a restart and every member of the group reads it:

    (def conn (pdt-ds/datascript-conn system "pdt" "graph" schema {}))
    (d/transact! conn [{:person/name "Ada"}])   ; writes a head
    (d/q '[:find ?n :where [_ :person/name ?n]] @conn)

- A transaction's `tx-data` joins the tail, a `dn` node that the head carries
  inline while it fits; past 128 tail datoms, or `:fold-every` (30 s) after
  the last fold, the conn folds instead: the adapter writes the dirty paths
  of the three indexes and the next head names a root with no tail (P2-D-03).
- Every head is `PRef.v` 2 of kind `db`; the ref is linear unless the
  facade's `:pdt {:refs {name {:mode :multi}}}` says otherwise, and two heads
  of a multi ref meet in the datom merge of `agentspaces.datascript.merge`.
- Opening reads the head's root, and its tail when it has one, and nothing
  else; a query reads the index nodes on its path (P2-D-04, P2-D-05).
- A transaction first brings the conn to the newest head its ref holds; when
  another writer moves the ref before the write, a linear conn refuses the
  transaction (ex-data `::moved`) and holds the new head, and a multi conn
  merges the transaction with it by datoms.
- A head another member writes replaces the conn's database, and the conn's
  listeners hear it as a report whose `:tx-data` is the change and whose
  `:tx-meta` names the root under `:agentspaces.datascript/remote`.

Options: `:fold-every` (a duration, "30s"), `:instant` (`:date`, the
default, or `:instant`: the Java type an instant reads back as), and
`:await-head` (a duration to wait at open for a head of the ref to arrive;
none by default).
raw docstring

agentspaces.datascript.merge

The datom merge of two db heads (PDT 2 phase 2, P2-D-06; srad/agentspaces-pdt2.md §3.1.4). The engine finds their lowest common base by the version graph; this merge reads each head's changes since the base (PDb.changesSince, which prunes every subtree the trees share and reads both tails), unions the assertions and the retractions, and settles a cardinality-one attribute that the two heads asserted to two values on the later head's value, through the engine's resolver, which raises the PConflict. The merged database applies the changes to the base in EAVT order, so every reader computes the same indexes and the same root, and its max-tx is the larger head's plus one.

The datom merge of two `db` heads (PDT 2 phase 2, P2-D-06; srad/agentspaces-pdt2.md
§3.1.4). The engine finds their lowest common base by the version graph; this
merge reads each head's changes since the base (`PDb.changesSince`, which
prunes every subtree the trees share and reads both tails), unions the
assertions and the retractions, and settles a cardinality-one attribute that
the two heads asserted to two values on the later head's value, through the
engine's resolver, which raises the `PConflict`. The merged database applies
the changes to the base in EAVT order, so every reader computes the same
indexes and the same root, and its max-tx is the larger head's plus one.
raw docstring

agentspaces.datascript.storage

The storage adapter of a DataScript database on a persistent ref (PDT 2 phase 2, P2-D-01 to P2-D-04; srad/agentspaces-pdt2.md §3.1.1, §3.1.2). Each index's sorted set reads and writes its nodes through a CidAdapter, the persistent-sorted-set IStorage whose address is the node's CID: store of a dirty node writes a dn node through the PDb$Writer of the fold, so a fold writes exactly the dirty paths, and restore of a CID reads the node through the ref's loader into a soft cache per CID, since the tree keeps none.

Encoding. A datom's attribute travels as its keyword's print form (a string attribute has no form and is refused); a value as the datom grammar's int, text, boolean, bytes, float64, or tagged pair (UUID, instant, big integer). A keyword value is its print form; a string that starts with a colon or a backslash gains one backslash in front, the rule of agentspaces.pdt, so both read back as they went in. An instant reads back as a java.util.Date, or as a java.time.Instant under {:instant :instant}.

The storage adapter of a DataScript database on a persistent ref (PDT 2 phase
2, P2-D-01 to P2-D-04; srad/agentspaces-pdt2.md §3.1.1, §3.1.2). Each index's
sorted set reads and writes its nodes through a `CidAdapter`, the
`persistent-sorted-set` IStorage whose address is the node's CID: `store` of a
dirty node writes a `dn` node through the `PDb$Writer` of the fold, so a fold
writes exactly the dirty paths, and `restore` of a CID reads the node through
the ref's loader into a soft cache per CID, since the tree keeps none.

Encoding. A datom's attribute travels as its keyword's print form (a string
attribute has no form and is refused); a value as the datom grammar's int,
text, boolean, bytes, float64, or tagged pair (UUID, instant, big integer).
A keyword value is its print form; a string that starts with a colon or a
backslash gains one backslash in front, the rule of `agentspaces.pdt`, so
both read back as they went in. An instant reads back as a `java.util.Date`,
or as a `java.time.Instant` under `{:instant :instant}`.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close