asami

respatialized 2021-12-10T15:24:12.232700Z

I'm trying to understand Asami's data model a bit better while also thinking about how to model metadata about assertions in Asami (things like the source of a fact). Given that every triple needs to have a specific node identifier, is it possible to make datoms/triples the subjects/entities of other facts (as https://blog.liu.se/olafhartig/2019/01/10/position-statement-rdf-star-and-sparql-star/)?

quoll 2021-12-10T16:12:29.236900Z

When you say “data model”, what are you referring to? How Asami stores data, or how it models edges in a graph? The latter is really what the API tells you, though I hope to expand that soon. The former is fixed, and I explain it in a couple of talks

respatialized 2021-12-10T17:21:31.237100Z

The latter. The concrete implementation isn't as important to me as what types of relations between facts I can model using it. I'm also wondering if, even though Asami is a schemaless DB, attributes can have attributes https://docs.datomic.com/on-prem/schema/schema.html#attributes.

quoll 2021-12-10T18:55:52.238600Z

Datomic schemas are more about data types on attributes. This is really only relevant to Asami when executing transactions, since single/multi-cardinality attributes change what adding a value means, and ownership indicates which other things get deleted when an entity it taken away. Sure, I can store this in a graph, read it, and use this to moderate how transactions are executed. I’m thinking about that. Meanwhile, I’m looking at allowing transactions to take a :schema parameter when loading data, and this schema will be used during that transaction.

quoll 2021-12-10T18:56:11.238800Z

That’s happening much sooner

quoll 2021-12-10T18:58:01.239Z

Things are a bit slow right now. This is entirely on my own time now. I’ve had a couple of big talks to complete, I just wrapped up on a side project, I’m dealing with a health issue this week (nearly resolved), and am about to travel for Christmas. I’m hoping to pick up my pace in the new year.

quoll 2021-12-10T16:07:14.233700Z

The storage supports this, though I haven't yet exposed it (sorry!)

☑️ 1
respatialized 2021-12-10T17:33:14.237400Z

If I were interested in the details of how this might be possible, which namespace should I read through?

quoll 2021-12-10T18:47:51.237600Z

Well, it happens in 2 places. The first is in asami.index. Functions like index-add accept 3 elements labeled “a”, “b”, and “c” (Depending on the index, this will be some combination of “entity”, “attribute” and “value”), an id, and a value called t. This stores a statement in an index as {:a {:b {:c {:t t, :id id}}}}. It’s yet to be committed, but there will also be a vector added to the graph that has the statement conj’ed on. The other place is asami.durable.graph. The BlockGraph implementation has 5 indexes: 4 of them (`spot`, post, ospt, tspo) hold statements, and the 5th (`pool`) maps internal ids to data. You’re looking for the tspo index. This is a flat file that holds data of [transaction, subject, predicate, object] (where subject=entity, predicate=attribute, object=value). The statement ID is the offset into this file. The other 3 indexes (whose names end with t) hold the statement ID in the 4th position. (it’s t instead of i, because it was originally going to be a transaction ID, but then I pivoted to giving every statement its own ID instead).

quoll 2021-12-10T18:49:40.237800Z

Exposing this isn’t too hard, but there are lots of bits. I need to extend the API so that resolve-triple can also take statement IDs. More importantly, I need to extend the query language to access them.

quoll 2021-12-10T18:50:49.238Z

I plan on doing this via patterns that look like this: [e a v t :as ?id]

quoll 2021-12-10T18:51:43.238200Z

where the pattern can be truncated, so that the t can be skipped, or the v t, or the a v t.

quoll 2021-12-10T18:52:09.238400Z

It’s just a little messy to get it all out and dispatch it appropriately 🙂