asami

lilactown 2022-02-20T17:55:53.436779Z

does asami support reverse lookups of attributes?

quoll 2022-02-20T19:42:07.273159Z

Entities are just built out of triples, and you can look up triples in any direction, so yes. Maybe you're looking for a different type of API though?

lilactown 2022-02-20T17:56:04.185189Z

didn't see it in the query docs

lilactown 2022-02-20T17:58:00.331859Z

trying to figure out how I ought to structure my data. I'm going to want to do a lot of back references - "this entity refers to that one, and these are all of the entities that refer it" - which in some dbs I could use reverse lookups. I could just transact those relations explicitly though I think

lilactown 2022-02-20T18:21:23.264319Z

another question: I'd like to use a tuple [:foo "bar"] as a :db/ident. this doesn't seem to work when I try to do (d/entity db [:foo "bar"]). haven't tried it any other way yet but, are complex data types like that allowed as idents?

quoll 2022-02-22T01:54:11.305699Z

I’m nearly there. I can store them and retrieve them, but searching for them isn’t working. Will try again in the morning

quoll 2022-02-23T03:56:37.711089Z

Yay! https://github.com/threatgrid/asami/tree/2.2.4!

1
🎉 1
quoll 2022-02-20T19:43:46.719179Z

Asami can store it, but I haven’t put it into the API yet because without a schema it's just looks like a nested structure that needs to be converted to triples

lilactown 2022-02-20T19:54:49.109899Z

yeah I see it ends up in the (in-memory) structure as

{:graph {:spo {:node-19455 {:db/ident #:tg{:node-19456 {:t 2, :id 16}},

lilactown 2022-02-20T19:55:22.362389Z

which makes it unable to be used with entity it seems

quoll 2022-02-20T20:11:10.869849Z

What I need is some way to get it through the asami.entities.writer/map->triples operation without descending into the ID attributes. Actually, that may not be hard at all, since they’re well known, and there is not reason to every have a triple-based structure on those attributes.

quoll 2022-02-20T20:11:29.672139Z

I’ll have to change that and see if it works.

quoll 2022-02-20T20:14:19.412089Z

If they’re not converted into triples, then then in memory, they just get stored as the data for the node, and on disk then end up going straight to the Data Pool, and represented with a number (that is a pointed into the data pool).

quoll 2022-02-20T20:17:01.938049Z

Encoding happens in asami.durable.encoder/FlatFile which is a protocol for storing things in the file that encodes the data pool. That protocol is extended onto ISeq on line 282, onto IPersistentVector on line 329, and IPersistentMap on line 333.

quoll 2022-02-20T20:17:47.987249Z

Still in the middle of writing other code, but I guess I could try making a branch that does this, so it can happen sooner

quoll 2022-02-23T12:39:14.449079Z

This is what I mean when I keep saying that I have “plans”. I have lots of nearly-done features that I need to connect up 🙂

lilactown 2022-02-20T18:24:52.730959Z

I also do not understand this line in the docs about identity > However, using these ident values in `:db/add` statements has greater potential to interfere with tuples that should not be modified, so the use is discouraged.

quoll 2022-02-20T19:44:41.218719Z

I think I need to see that in context

lilactown 2022-02-20T19:52:17.023559Z

last paragraph under this heading https://github.com/threatgrid/asami/wiki/4.-Transactions#identity-values

quoll 2022-02-20T20:07:34.389259Z

Apparently I was on a roll that day… I don’t know what I meant either!

😂 1