asami

Asami, the graph database https://github.com/threatgrid/asami
quoll 2020-08-05T03:19:48.022600Z

Asami 1.1.0 is now out. This has minor updates: • Entity arrays are now returned as vectors and not lists. • Entities now represent multi-arity attributes as a set of values. If more than one of an attribute is found, then a set of those values is returned in the entity. Similarly, providing a set will result in using the attribute multiple times in the graph. • Arrays in entities can be appended to by using the + annotation on attributes (see https://github.com/threatgrid/asami/wiki/Transactions#append-annotation for details) • Queries now accept _ symbols as wildcards, and accept shortened constraints (not just triples)

👍 2
2020-08-05T17:33:37.023500Z

It's mentioned in the docs that :db/ident can be any data type, but I'm not having luck getting it to work with vectors as idents. Is it actually any scalar data type?

quoll 2020-08-05T17:34:20.024100Z

Yes. Though for the in-memory indices I’m surprised that it’s not working

2020-08-05T17:37:22.024600Z

(def tx (d/transact conn {:tx-data [{:db/ident ["liz" 5] :name "Elizabeth"}]}))

(d/q '[:find [?n ...]
       :where [?p :name ?n] [?p :db/ident ["liz" 5]]] (d/db conn))

(d/entity (d/db conn) ["liz" 5])

(d/q '[:find ?p
       :where [?p :name ?n] [?p :db/ident ["liz" 5]]] (d/db conn))
yeah the 3 queries here and entity call return nil

quoll 2020-08-05T17:38:53.025Z

Oh, of course! It deconstructed it into a list!

quoll 2020-08-05T17:39:07.025300Z

I could make it ignore that on ident

quoll 2020-08-05T17:40:04.025700Z

cljs.user=> (def tx (d/transact conn {:tx-data [{:db/ident ["liz" 5] :name "Elizabeth"}]}))
#'cljs.user/tx
cljs.user=> (pprint (:tx-data @tx))
([:tg/node-5 :tg/entity true 3 true]
 [:tg/node-5 :db/ident :tg/node-6 3 true]
 [:tg/node-6 :tg/first "liz" 3 true]
 [:tg/node-6 :tg/rest :tg/node-7 3 true]
 [:tg/node-7 :tg/first 5 3 true]
 [:tg/node-6 :tg/contains "liz" 3 true]
 [:tg/node-6 :tg/contains 5 3 true]
 [:tg/node-5 :name "Elizabeth" 3 true])

quoll 2020-08-05T17:40:31.026Z

so the ident became :tg/node-6

2020-08-05T17:41:36.026800Z

aha!

quoll 2020-08-05T17:41:56.027200Z

That won’t work on buffer-backed indexes, but I think I can do it as a new datatype with edn

2020-08-05T17:42:31.027700Z

(I have no opinion on if it's a good idea or not, just starting to play with asami a little bit 🙂 )

quoll 2020-08-05T18:21:16.029Z

It’s an edge case that ought to be handled. Either accept it, or throw an exception. Either way, it shouldn’t get serialized into a linked list like that, since it isn’t useful (and led to confusion with at least one person)

quoll 2020-08-05T18:21:38.029200Z

I made a Zuko ticket for it

👍 1