asami

wikipunk 2023-08-30T13:26:25.985799Z

Today I embark upon a quest to attempt to replace XTDB in my RDF project with Asami. I am excited and a bit intimidated. Once I learned that I have to use sets for multi-cardinality attributes it clicked. 😅

Dave Mays 2024-01-23T15:27:20.950369Z

What made you switch?

wikipunk 2024-01-23T15:29:47.636539Z

I use it to search RDF vocabulary which is schemaless, but not document oriented like XTDB, asami is triple oriented so it works a lot more seamlessly with RDF.

wikipunk 2023-09-07T22:59:03.965029Z

Quest completed! Thanks @quoll for your help!

👍 1
quoll 2023-08-30T14:10:19.232059Z

I don’t know if it was just introduced later, or what, I have a feeling that early Datomic didn’t use vectors for entities with multicardinality properties. But maybe I’m wrong and it was always like that. I forget. It turns out that I didn’t have a lot of use for multicardinality properties in Datomic. Most of the time when I needed multiple values, the order mattered.

quoll 2023-08-30T14:10:29.822149Z

So maybe I just didn’t remember properly 🙂

wikipunk 2023-08-30T14:18:00.494029Z

Sets make sense for idiomatic “RDF/EDN” serialization and will be accepted by Datomic in tx-data too. There are always going to be some trade offs in how to represent the RDF with Clojure data and I am already using EDN tagged literals which require binding the appropriate data readers for things like language tagged strings, so I think you made the right design choice thinking about RDF

quoll 2023-08-30T14:18:59.015099Z

I basically rewrote Mulgara for Clojure, with various design updates.

quoll 2023-08-30T14:19:28.832249Z

i.e. the underlying architecture was based on presumptions of RDF

🔥 1
tmprd 2023-08-30T17:18:48.750859Z

Hello! Related to RDF lists... I'm loading triples directly into Asami using https://github.com/quoll/asami/wiki/3.-Loading-Data#triples, but I noticed if you add entities with arrays, convenient https://github.com/quoll/asami/wiki/5.-Entity-Structure#containership triples are added to make querying easier. Has anyone been able to get those :a/contains predicates added when loading triples directly from RDF? I'm parsing the RDF with https://github.com/quoll/raphael (which I wouldn't expect to add them) 🙂

tmprd 2023-08-30T17:48:57.350649Z

Oh I got this property path querying working too, might be all I need

(a/q '[:find [?s ...]
       :where
       [:n0 :fhir/name ?name]
       [?name :rdf/rest* ?list]
       [?list :rdf/first ?s]]
     (a/db asami-conn))

quoll 2023-08-30T19:25:50.988319Z

Hopefully that IS all you need!!!

quoll 2023-08-30T19:26:08.491219Z

The :a/contains link is specifically an entity convenience

quoll 2023-08-30T19:26:19.283529Z

it doesn’t happen when triples come in otherwise

quoll 2023-08-30T19:26:42.035349Z

(Also, I’m very sorry that you’re running Raphael separately. I’m working on it, I promise!)

1
tmprd 2023-08-30T20:55:05.547739Z

Yes I think this is the way to go, except now I have to go deeper into nested lists ... In FHIR, someone can have multiple full names, and a full name can have multiple given names, etc. Here's the example I'm querying into https://hl7.org/fhir/R5/patient-example.ttl.html

tmprd 2023-08-30T20:57:05.658759Z

I think I almost have it for two layers using optional but it seems like I should try to go arbitrarily deep... This kind of thing is tricky for me to grasp in SPARQL

tmprd 2023-08-30T23:34:57.543309Z

Oh I didn't search well enough! https://clojurians.slack.com/archives/C018H97E02D/p1675503703424879 I'll try using CURIEs that look like :rdf:rest

quoll 2023-08-30T23:37:03.309319Z

Maybe, :rdf/rest?

tmprd 2023-08-31T19:53:04.470339Z

Oh I thought I could do a recursive property path query if I changed

:rdf/rest*/:rdf/first
to
:rdf:rest*/:rdf:first
But I see that you suggested another way to achieve this for arbitrary depth... I have something working now but it's not a very general or pretty solution, because I'm collecting values that are either RDF lists or not... but it works well enough for what I need