{:crux.db/id :dbpedia.resource/Pablo-Picasso
:name "Pablo"
:last-name "Picasso"}
There are four transaction (write) operations:
Operation | Purpose |
---|---|
| Write a version of a document |
| Compare and swap the version of a document, if that version is as expected |
| Deletes the specific document at a given |
| Evicts a document entirely, including all historical versions |
A document looks like this:
{:crux.db/id :dbpedia.resource/Pablo-Picasso
:name "Pablo"
:last-name "Picasso"}
In practice when using Crux, one calls crux.db/submit-tx
with a
sequence of transaction operations:
[[:crux.tx/put :dbpedia.resource/Pablo-Picasso
{:crux.db/id :dbpedia.resource/Pablo-Picasso
:name "Pablo"
:last-name "Picasso"}
#inst "2018-05-18T09:20:27.966-00:00"]]
If the transaction contains CAS operations, all CAS operations must pass their pre-condition check or the entire transaction is aborted. This happens at the query node during indexing, and not when submitting the transaction.
For operations containing documents, the id and the document are
hashed, and the operation and hash is submitted to the tx-topic
in
the event log. The document itself is submitted to the doc-topic
,
using its content hash as key. In Kafka, the doc-topic
is compacted,
which enables later deletion of documents.
Put’s a document into Crux. If a document already exists with the
given :crub.db/id
, a new version of this document will be created at
the supplied valid time
.
[:crux.tx/put
:dbpedia.resource/Pablo-Picasso (1)
{:crub.db/id :dbpedia.resource/Pablo-Picasso :first-name :Pablo} (2)
#inst "2018-05-18T09:20:27.966-00:00"] (3)
1 | The ID of the document being written |
2 | The document itself |
3 | valid time |
Note that valid time
is optional and defaults to transaction time,
which is taken from the Kafka log.
Crux currently writes into the past at a single point, so to overwrite several versions or a range in time, one is required to submit a transaction containing several operations.
The CAS operation (compare and swap) swaps an existing document version with a newer one, if the existing document is as expected.
[:crux.tx/cas
:dbpedia.resource/Pablo-Picasso (1)
{..} (2)
{..} (3)
#inst "2018-05-18T09:21:31.846-00:00"] (4)
1 | The ID of the document being written |
2 | Expected Document |
3 | New document |
4 | valid time |
Deletes a document at a given valid time
. Historical version of the
document will still be available.
[:crux.tx/delete :dbpedia.resource/Pablo-Picasso
#inst "2018-05-18T09:21:52.151-00:00"]
Evicts a document from Crux. The transaction history will be
available, but all versions at or before the provided valid time
are
evicted.
[:crux.tx/evict :dbpedia.resource/Pablo-Picasso
#inst "2018-05-18T09:21:52.151-00:00"]
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close