Fork me on GitHub
#datomic
<
2016-01-17
>
genRaiy10:01:49

I’m fiddling around with trying to obtain transaction events using the tx-report-queue facility and seeing some odd behaviour….

genRaiy10:01:23

(save-new-cart conn {:cart/name "Cart-2"})
=> {:db/id 17592186045484, :cart/name "Cart-2"}
(def txns (d/tx-report-queue conn))
=> #'shopping-cart-demo.datomic/txns
txns
=>
#object[java.util.concurrent.LinkedBlockingQueue
        0x418201de
        "[{:db-before datomic.db.Db@1b2fa2ff, :db-after datomic.db.Db@d4d134ad, :tx-data [#datom[13194139534379 50 #inst \"2016-01-17T10:26:25.862-00:00\" 13194139534379 true] #datom[17592186045484 64 \"Cart-2\" 13194139534379 true]], :tempids {-9223350046623220289 17592186045484}}]"]
(d/pull (:db-after txns) '[*] 17592186045484)
NullPointerException   datomic.api/pull (api.clj:162)
(d/remove-tx-report-queue conn)
=> nil
(def conn (d/connect uri))
=> #'shopping-cart-demo.datomic/conn
(d/pull (d/db conn) '[*] 17592186045484)
=> {:db/id 17592186045484, :cart/name "Cart-2"}

genRaiy10:01:51

the save-new-cart resolves the tempid so I can see the entity that was created and of course that agree with the data in the txns queue

genRaiy10:01:40

but when I come to query it, I get a NPE … and I then reconnect to the DB and the data is there

genRaiy10:01:21

It seems like the :db-after is not null, the entity ID is not null so something weird is going on

genRaiy10:01:11

I am running the peer lib and transactor from datomic-pro-0.9.5327 starter edition

genRaiy10:01:24

maybe I shouldn’t use the data like this so any advice on how I can retrieve the data for the transaction from the queue would be great!

genRaiy10:01:43

[my goal, perhaps obviously, is to watch the DB and generate changed data out to other systems]

casperc10:01:14

I am wondering, is it possible to use aggregates in a where clause to answer a question like: what is the newest entity of a given type, and then use that entity to join some other stuff in the same query

casperc13:01:30

Or the entity with the biggest of some value and then use that in the query again.

yenda13:01:50

if I want to keep the position of each element in a component list do I need a position attribute or is the list of element already ordered ? I want to have an ordered list of requests for each scenario with the following schema :

robert-stuttaford14:01:01

@casperc, as aggregates are declared at the :find level, that’s not possible in a single query. however, you can nest queries! [(datomic.api/q [… query with aggregates ...] $ ?something) ?something-else]. good to do this if the subquery isn’t likely to be reused, otherwise probably better to make it a separate fn and compose

casperc14:01:28

@robert-stuttaford: Woah, I did not know you can nest queries!

casperc14:01:49

@robert-stuttaford: That could be the way to go, if aggregates can indeed answer the first part of the question, e.g. give me the entity with the biggest of some value. I’ll need to play around with it

robert-stuttaford15:01:50

let me know if it solves it for you simple_smile

casperc15:01:22

@robert-stuttaford: Will do. Still trying to sort it out, but an aggregate can definitely answer the first part of the question, so just need to grok completely how subqueries work simple_smile

isaac16:01:47

Why Datomic use memcached as cache system instead of redis?

bhagany16:01:33

@raymcdermott: I think the problem is that you're treating txns like it's a record with a :db-after key. But it's not that - it's a LinkedBlockingQueue with a record inside it.

bhagany16:01:39

@raymcdermott: you want something like (d/pull (:db-after (.take txns)) '[*] 17592186045484), if I remember that api right

genRaiy18:01:23

@bhagany: ok, thanks I didn’t find any good examples with tx-report-queue directly so I’ll check out the LBQ

genRaiy18:01:40

@bhagany: that works a treat - thanks!!

bhagany18:01:52

good to hear simple_smile

genRaiy18:01:30

I guess people use core.asynch or something similar to manage the events

genRaiy18:01:02

bit of a shame that day of datomic etc. does not have some examples of this functionality … I will play around with it and make a blog post

tcrayford20:01:12

@isaac: memcached is a much better cache for datomic's purposes. It scales multicore whereas redis is limited to one. Given that datomic only uses it's cache for k/v writes with bytes in each, it doesn't need any of the features of redis

raphael21:01:56

Hello, I am starting with datomic

raphael21:01:17

somebody see what the error in my snippet?

raphael21:01:31

Heu.. is it the right place to ask? simple_smile

raphael21:01:34

thank a lot

raphael21:01:37

Ah sorry, I received this error: IllegalArgumentExceptionInfo :db.error/not-an-entity Unable to resolve entity: :dialog/bubbles datomic.error/arg (error.clj:57)

currentoor22:01:39

Is there a way to invalidate the caching in Datomic in dev?

currentoor22:01:15

In the peer and anything potentially lingering in the transactor?

currentoor23:01:56

I’m seeing sporadic issues when trying to load seed data in dev. I’ve tried deleting the database and restarting both the transactor and the JVM but loading seed data still fails sometimes.