Fork me on GitHub
#asami
<
2022-02-20
>
lilactown17:02:53

does asami support reverse lookups of attributes?

quoll19:02:07

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?

lilactown17:02:04

didn't see it in the query docs

lilactown17:02:00

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

lilactown18:02:23

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?

quoll19:02:46

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

lilactown19:02:49

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}},

lilactown19:02:22

which makes it unable to be used with entity it seems

quoll20:02:10

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.

quoll20:02:29

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

quoll20:02:19

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).

quoll20:02:01

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.

quoll20:02:47

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

quoll01:02:11

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

quoll12:02:14

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 🙂

lilactown18:02:52

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.

quoll19:02:41

I think I need to see that in context

quoll20:02:34

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

😂 1