Fork me on GitHub
#datomic
<
2021-10-22
>
Tobias Sjögren04:10:03

“In order for a keyword to appear in the A position in a datom, it must have previously appeared in the V position.” Correct? (trying to understand what a keyword really is…)

Jakub Holý (HolyJak)08:10:06

Keyword is just a data type intended to be used as an identifier, typically for properties inside maps. Attributes - your A - in datomic are identified by keywords and before you can use an attribute, you must define in, so yes, the keyword will first appear in the V position of [<attribute entity id> :db/ident <the keyword>] .

👍 1
Tobias Sjögren08:10:53

OK. Although you probably don’t want to do it - it would be possible to use the <attribute entity id> instead of the keyword in the A position, right?

Jakub Holý (HolyJak)08:10:16

I think so. If you look at the raw datoms, the E and A positions are just numbers.

Tobias Sjögren08:10:59

Do you happen to know the entity ids for the built-in attributes?

Jakub Holý (HolyJak)08:10:02

They are not fixed between DB instances. Look at their corresponding datoms (I do not remember the correct function for that)

Tobias Sjögren08:10:00

From what I’ve heard it is this:

(d/create-database "datomic:")
 (-> (d/connect "datomic:")
     (d/db)
     (d/seek-datoms :eavt 0)
     (->> (group-by :tx)
          (sort)
          vals))

Fredrik12:10:03

On my current version of Datomic Free it is the below list. But it's an implementation detail, at least it is not documented anywhere, and you shouldn't rely on it.

{:db.type/instant 25,
    :db/excise 15,
    :db.type/boolean 24,
    :db.unique/identity 38,
    :db/fn 52,
    :db.type/bytes 27,
    :db/index 44,
    :db/unique 42,
    :db.part/user 4,
    :db.lang/clojure 48,
    :db.excise/beforeT 17,
    :db.part/db 0,
    :db.bootstrap/part 53,
    :db.sys/reId 9,
    :db/valueType 40,
    :db.type/string 23,
    :db.type/keyword 21,
    :db/txInstant 50,
    :db.type/ref 20,
    :db/noHistory 45,
    :db/isComponent 43,
    :db/lang 46,
    :db/fulltext 51,
    :db.unique/value 37,
    :db/retract 2,
    :db.lang/java 49,
    :db.part/tx 3,
    :db/cardinality 41,
    :db.excise/before 18,
    :db/ident 10,
    :db/code 47,
    :db/add 1,
    :db.type/long 22,
    :db.cardinality/many 36,
    :db.install/valueType 12,
    :db.alter/attribute 19,
    :db.install/function 14,
    :db.install/partition 11,
    :db.install/attribute 13,
    :db.type/fn 26,
    :db.cardinality/one 35,
    :db.excise/attrs 16,
    :fressian/tag 39,
    :db.sys/partiallyIndexed 8}

👍 1
Tobias Sjögren12:10:40

@U024X3V2YN4 Would you happen to have the raw datoms where these built-in attributes are defined, as plain text?

Fredrik12:10:02

The datoms are not stored individually, but in segments consisting of thousands of datoms. You can get a high-level picture of the internals here: https://tonsky.me/blog/unofficial-guide-to-datomic-internals/

Fredrik13:10:38

Maybe worth pointing out that a single datom can be stored multiple times, once for each index containing it. Every datom is stored separately in the EAVT index and the AEVT index, for instance.

Fredrik13:10:05

To answer your original question, when a keyword K appears in the A position, Datomic will try to resolve that to an entity E with an attribute :db/ident whose value is K. If it cannot do that, for instance if you never installed such an entity, you'll get an error like "Unable to resolve entity: K".

Fredrik13:10:10

Such keywords K are called idents, and you can read about it here https://docs.datomic.com/on-prem/schema/identity.html#idents. Probably that whole page is worth a look.

Fredrik13:10:15

At least I found that page very helpful myself when trying to understand how Datomic named entities and how it looked things up, precisely a point I was quite confused about myself

Tobias Sjögren15:10:20

Concerning keywords: That’s how I understood it - I was a bit unsure after reading that “Keywords resolve to themselves” in the “Programming Clojure” book…

Tobias Sjögren15:10:21

I read a lot from the documentation but still have questions..

Fredrik15:10:53

Keywords do evaluate to themselves.

Fredrik15:10:58

If you give Clojure a keyword in, say, the REPL, it will return to you that same keyword

Tobias Sjögren15:10:41

You said a keyword used as an attribute will resolve to an entity id..

Fredrik15:10:39

I was talking specifically in the context of Datomic transactions. Datomic will take that keyword and try to find a matching entity

👍 1
Fredrik15:10:00

But that has all to do with how Datomic works, not how keywords are evaluated

Fredrik15:10:29

It might help to break it down into two steps. First you write some transaction data. And this really is simply data:

[{:db/id "sensor 1" :sensor/humidity 124.0}
 {:db/id "sensor 1" :sensor/humidity 125.0}
 {:db/id "sensor 2" :sensor/humidity 124.0}
 {:db/id "sensor 2" :sensor/humidity 100.0}
 {:db/id "sensor 3" :sensor/humidity 125.0}] 
Then you transact this to Datomic using d/transact. Second, when Datomic receives this, it will notice there are attributes referrred to by keywords, and then try to find matching entities.

popeye07:10:44

I was going through https://docs.datomic.com/cloud/dev-local.html and

(require '[datomic.client.api :as d])
(def client (d/client {:server-type :dev-local
                       :system "datomic-samples"}))
(d/list-databases client {})
=> ["mbrainz-subset" "solar-system" "social-news" "movies" ...]

popeye07:10:21

i thnk we need to add statement , before we printing list of databases

(d/create-database client {:db-name "friends"})

popeye07:10:55

because without that it gave me empty vector

Tobias Sjögren08:10:14

Does anyone know if there are examples of raw datoms data somewhere online?

Tobias Sjögren09:10:09

Do you know what format “db.log” files are in? I can’t read them..

Linus Ericsson07:10:35

The data is stored in either fressian https://github.com/clojure/data.fressian or transit https://github.com/cognitect/transit-clj The explicit storage of the various nodes is an implementation detail. the best way to get som example data is to follow the instructions and restore for instance the mbrainz-sampledata.

Tobias Sjögren15:10:37

another area I’d like to know about…

Tobias Sjögren15:10:08

Is someone here using Datomic without using Clojure (if it is even possible) ?

Tobias Sjögren15:10:13

Either Clojure or Java and nothing else?

Fredrik15:10:30

There are third-party libraries for some other languages

Ben Sless08:10:59

Only JVM langs from what I've seen

Linus Ericsson07:10:53

You can use any JVM-language with the Java wrapper. The datomic implementation in the peer is dependent on clojure since it is implemented in (JVM-)clojure.

jaret18:10:22

Ivar, are you accessing this site from a mobile device?

jaret18:10:01

Trying to determine what the outage is.

jaret18:10:03

@UGJE0MM0W I am seeing everything working from my end can you share specifically what you are seeing?

Robert A. Randolph18:10:41

It appears that there is or was an issue on Zendesk's end with authentication. We were able to log in after clearing all zendesk cookies.

👍 1
Ivar Refsdal07:10:59

Here is what I'm seeing

jaret13:10:52

Hi @UGJE0MM0W I believe we have resolved that just now. I would appreciate independent confirmation so if you have a moment, please let me know.

Ivar Refsdal13:10:24

Yes, I'm logged in now when I refreshed :thumbsup:

jaret13:10:42

Oh great! Thanks Ivar!

Ivar Refsdal13:10:29

No problem 🙂