Fork me on GitHub
#datomic
<
2016-01-18
>
curtosis00:01:22

@raphael: it doesn't look like you're installing the :dialog/bubbles attribute. Your tx map for the schema needs to include :db.install/_attribute :db.part/db.

yenda09:01:00

@robert-stuttaford: thanks that's a good start, it doesn't use components maybe I don't need them after all

tcrayford13:01:24

@currentoor: datomic's caching should never have any notable impact on the app, except for memory pressure. Also a reminder that "it doesn't work" isn't a great bug report. What were you trying to do? What happened? What should have happened? Tell us a bit about your environment? (OS, Datomic version, JVM version)

pesterhazy15:01:42

currentoor: there are occsaionally issues when restoring a database on top of a version of the same database. Are you using the restore functionality?

jannis15:01:10

Hi! I've dug around in the datomic query docs and various examples/tutorials but I'm unsure whether this is easily possible: Given a db and an entity, I would like to return a single boolean value if it has more than N references via a specific attribute. Example: given a user with :user/friends (a many ref attribute), return a boolean for whether the user is "popular" (i.e. has more than 2 friends. I can probably make it work using a custom aggregate function but I wonder if it's possible with built-in features?

bkamphaus15:01:15

@jannis: you can use a nested query/subquery to limit query results to a ref attribute with refs of a count greater than some number, that’s pretty much what’s going on in the second query here - https://groups.google.com/forum/#!msg/datomic/5849yVrza2M/31--4xcdxOMJ-- re: returning a single boolean, I think I’d just handle that outside query. I.e., the query returns something in the results or it does not.

bkamphaus15:01:39

(the second query from the link)

(d/q '[:find ?track ?count
       :where [(datomic.api/q '[:find ?track (count ?artist)
               :where [?track :track/artists ?artist]] $) [[?track ?count]]]
       [(> ?count 1)]]
  (d/db conn))

jannis16:01:46

I want to try doing it inside the query. (My goal is to have a declarative, query-based way of describing data derived from entities.)

jannis16:01:54

https://gist.github.com/Jannis/8fd22f556b55f02589bf - this almost works, except for when no friends are set.

bkamphaus16:01:31

@jannis: ah, aggregates in find won’t get called if there are no results, you could look at using http://docs.datomic.com/query.html#get-else maybe

bkamphaus16:01:15

oh wait card many attribute

jannis16:01:39

So if I'd simply want to query the number of friends with :find (count ?f) ., it would return nil and not 0 if there are no friends?

jannis16:01:31

Just tested it. The answer is yes.

bkamphaus16:01:33

that’s correct,

jannis16:01:50

I find that odd but ok, I'm new to Datomic.

jannis16:01:55

There must be a way to achieve this though.

bkamphaus16:01:20

@jannis here’s one, but it’s a hack (against mbrainz sample)

bkamphaus16:01:42

(defn prolific [tracks]
  (> (count (filter #(not= :nil %) tracks)) 500))

(d/q '[:find (user/prolific ?t) .
       :in $ ?a
       :where 
       (or [?t :track/artists ?a]
           (and
             [(missing? $ ?a :track/_artists)]
             [(ground :nil) ?t]))]
       (d/db conn)
       1111) ;;no tracks for non-existent artist
       ;17592186046909) ;pink floyd - works for true condition in artist

jannis16:01:07

Nice job. simple_smile Yes, it may be a hack but I played with or and ground as well and couldn't get anything to work. This is still reasonably readable.

bkamphaus17:01:17

I have to give credit to @marshall for suggesting that use of or, missing?, and ground to me.

currentoor17:01:20

@tcrayford: My apologies. I was having the same issue as @domkm, same codebase. Namely we have this rule. https://clojurians.slack.com/files/domkm/F0JJN0G9X/rules.clj And it sporadically results in this exception. https://clojurians.slack.com/files/domkm/F0JJMNC65/-.txt

raphael17:01:08

Hello, what the difference between (d/tempid :db.part/db) and #db/id[:db.part/db] ? thank a lot simple_smile

bostonaholic17:01:18

@raphael: you would use the former in code, and the latter in a data structure to be read (like an edn file)

currentoor18:01:01

I'm on the  Datomic Pro Starter license and it ways I get to have to 2 peers + 1 transactor. I was wondering if it is ok for me to have a staging environment with that the same setup and production environment as well, so 4 peers and 2 transactors total (albeit two separate apps).

currentoor18:01:15

Or does that violate the license?

marshall18:01:24

@currentoor: That is perfectly acceptable. The process limit specifically refers to production processes. You’re permitted to maintain separate unlimited development/staging instances.

jannis22:01:45

What can lead to this error? java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: :db.error/not-an-entity Unable to resolve entity: :user/email?

bhagany22:01:15

it looks like the :user/email attribute isn't installed

bhagany22:01:31

(assuming it's an attribute)

jannis22:01:21

It is, yep

jannis22:01:35

I'll check whether the schema makes it into the database

bhagany22:01:27

worth mentioning: recently there was someone who missed the :db.install/_attribute :db.part/db part of the schema installation. that's a hard one to see.

jannis22:01:47

Nope, that's there. The schema is generated by datomic-schema. But it's not current transacted into the db apparently. I'll dive deeper.

jannis22:01:56

Oh, (d/transact ...) not @(d/transact ...), so my guess is since it was never deref'd it didn't run at all?

tcrayford22:01:22

Not not run, but if transact throws an exception you have to deref to see it

jannis22:01:15

Ah! Excellent, it is working now. There was an error: :db.type/int doesn't exist, I should be using :db.type/long.

jannis22:01:48

So the schema transaction failed and the exceptions weren't visible.

bhagany22:01:32

glad you found it simple_smile

jannis22:01:56

Thanks for the help, that was quick simple_smile

jannis22:01:53

I hit another problem: Exception in thread "async-dispatch-5" java.lang.IllegalStateException: :db.error/connection-released The connection has been released. inside (d/db conn).

bhagany22:01:47

not sure about that one

jannis22:01:19

The web suggests someone might be deleting the db before the (d/db conn) call.

bkamphaus22:01:36

@jannis: that’s likely. Or a different thread releases the connection through a call to release, or memory issues/gc on peer or transactor cause excessive latency and peer loses connection, etc. (or genuine network partition), etc.

jannis22:01:59

I am using multiple connections in the same process, could that be a problem?

jannis22:01:33

Oh, I know what it is. My process terminates while a go loop is still busy and tries to access a conn/db.

bkamphaus22:01:28

yep, that would do it.

bkamphaus22:01:09

Datomic caches connections, so successive connect calls, etc. are usually not an issue.

bkamphaus22:01:10

if you’re interested in more discussion re: managing connections, I think Ryan’s blog post here is pretty good: http://www.rkn.io/2014/12/16/datomic-antipatterns-eager-conn/