Fork me on GitHub
#datomic
<
2016-01-12
>
domkm00:01:30

Do Floats and Doubles not compare as equal in Datomic?

bhagany00:01:44

I've been using the repl that comes with datomic (bin/repl) for all of my datomic repl needs, but I'm finally feeling the need to use a repl from emacs. However, I'm using the rest api, and I don't have a lein or boot project that cider can hook into. Should I make a dummy project just to start it with cider, or is there some way to accomplish this that I'm missing?

domkm00:01:18

To answer my own previous question, Datomic does not do float/double coercion. 😞

meow03:01:19

fyi, we're working on a slack replacement and might use datomic https://hackpad.com/collection/wnikaeBENEE

isaac05:01:28

How choose storage for datomic? Is there any Guiding principles? I read the documentation about how set up for various storage db, but not about choice.

bhagany13:01:01

@alwaysbcoding: this probably isn't terribly helpful, but your example looks a lot like what I do from python. I don't do anything special with the ?vars

bhagany13:01:25

the error suggests to me that your query datastructure isn't being coerced to a string before being sent?

bhagany13:01:18

@isaac: the canonical advice is to use whatever is operationally easiest for you. for example, if you already have postgres in production, use that. I have also seen people say that if you're on AWS, consider using dynamo.

tcrayford13:01:00

@isaac: @bhagany the last thing is that cassandra's probably the easiest/best if you don't have any other particular choice any particular way and want distributed/perf etc and cannot use dynamo

isaac13:01:42

datomic just support version of cassandra at 2.x?

Lambda/Sierra13:01:18

yes, only cassandra 2.0 and 2.1

isaac13:01:58

Is it will support cassandra higher version?

Lambda/Sierra13:01:04

Probably, at some point.

donaldball15:01:49

Hey, I’m new to datomic and could use some guidance solving a problem. Let’s say I have some book entities that have a :book/color attribute which could be :red, :green, or :blue. Let’s say also that I have a map of colors to ordinal values {:red 1 :green 2 :blue 3} which I don’t have stored in datomic. I’d like to have a query that, given an eid and such a map, returns the ordinal value of the book’s color. (I realize this is trivially done after the fact; I’m actually working on a transaction fn for which I think a solution to this simple problem will help.)

donaldball15:01:18

My naive attempt fails:

(defn get-book-color-ordinality
  [db eid color-ordinals]
  (d/q '[:find ?ord
         :in $ ?eid ?ords
         :where
         [?eid :book/color ?color]
         [(get ?ords ?color) ?ord]]
       db eid color-ordinals))

donaldball16:01:30

Nevermind, this does seem to work, I had just mixed up the type of my color attrs

donaldball18:01:34

But it doesn’t work as a txn fn; datomic complains with:

java.lang.RuntimeException: Unable to resolve symbol: ?ords in this context

donaldball18:01:09

Any clue why this might be true? I even get this when I inline the color-ordinals map.

domkm19:01:29

Does anyone know why I would be able to successfully use d/with but transacting the same tx-data to an unchanged connection would fail with a java.lang.ExceptionInInitializerError?

domkm20:01:21

Even weirder, transacting this particular data does work against an in memory connection but it does not work against a free dev connection. I'm stumped (and blocked). Any ideas? CC @bkamphaus @stuartsierra

Lambda/Sierra21:01:01

Sorry, I got nothing @domkm

domkm21:01:40

@stuartsierra: Thanks for responding. simple_smile Would you pass this on to your colleagues?

marshall21:01:21

@domkm: can you share your tx-data ?

donaldball21:01:14

I’ve written up a simple gist illustrating the txn-fn problem I’m having: https://gist.github.com/dball/f4cd5a52dddc7b812b86

donaldball21:01:41

The former form is a macro which generates a txn fn suitable for installation in a schema; the macro is well tested and I have no reason not to trust it. It fails when used in a txn. The latter form works exactly as intended locally. I’m not sure why; are clojure map literals not allowed within clojure txn fns?

domkm21:01:49

@marshall: I pasted a snippet above.

domkm21:01:07

@marshall: It's sort of a contrived example because I don't intend to use that exact code in production (which essentially prevents any concurrent modification), but I intended to do something related and, now that I know the above works in a mem transactor but not in a dev transactor, I am concerned about the approach.

marshall21:01:46

@domkm is it the invocation of the txn function that fails or the installation of it?

domkm21:01:58

@marshall: Installation works fine in both mem and dev. Let me get back to you on dev invocation...

domkm21:01:20

@marshall: Dev invocation works as well. I used this tx-data: '[[:fn/query {:query [:find ?e :where [?e :person/email "foo"]]}]]

Ben Kamphaus21:01:38

@domkm: The snippet is invoking one query to make an exception, and a second query using that exception as an arg, to throw an exception if the db has been changed and no longer has the basis-t 1031?

domkm21:01:14

@bkamphaus: Almost exactly. It doesn't invoke the query which makes and throws an exception. It simple returns that query in a list and the transactor invokes it after splicing it in.

Ben Kamphaus21:01:38

@domkm: I guess I’m not clear whether this is the intended use case of opening query in a transaction function, or a contrived example meant to illustrate a failure. That said, a suspect for the deserialize exception might be something that does a sequence manipulation in a transaction function that requires a clojure map or vec specifically rather than targeting a java.util.Hashmap as the precision of type preservation for collections is only guaranteed at the interface level (well, I think, either way it’s not preserved for the exact type) on the wire. That would produce something like the symptom you describe, where something would work on mem, but not dev/free. Maybe the assoc or cons in the code for :fn/query would be the points where the failure is encountered?

Ben Kamphaus21:01:44

(speculation, not tested at this point)

domkm21:01:38

@bkamphaus: Okay, thanks, I'll test that.

domkm22:01:57

@bkamphaus: Hmm, so you're correct that they are not Clojure data structures but assoc and cons are working as I expected on this: '[[:fn/query {:query [:find ?e :where [?e :person/email "foo"]]}]] I'm confused

Ben Kamphaus23:01:04

@domkm: I’ll use your transaction function code and investigate a bit more, see if I can identify what the exact issue is. Will update after digging some.