Fork me on GitHub
#datomic
<
2018-12-21
>
igrishaev04:12:42

@dustingetz how is that’s possible in Datomic I wonder?

igrishaev04:12:12

@eraserhd that makes sense! the second time you give me a hand, thank you!

kardan06:12:38

While reading up on Web Ions I see that they are supposed to return a ring map, does this mean that anything like server side events or websockets are not supported?

rhansen07:12:24

@kardan I haven't tested it myself, but ions run behind aws gateway, which recently got support for websockets. So I think you can support websockets that way.

kardan07:12:42

I was thinking about the Ion web API (https://docs.datomic.com/cloud/ions/ions-reference.html#sec-7). But I have to say that I have not chewed on Ions enough to understand how it all hangs together. But I got the impression that the Ion itself wanted a ring request / response workflow.

kardan07:12:00

Anyway, I was only interested it’s no show stopper for me reading up more 🙂

rhansen08:12:38

So ions are simple clojure functions which are inserted into your datomic cluster. AWS Gateway can send events to your ions as a ring request. AWS Gateway now supports websockets, which means that it in theory can send a request on user connection, user message and user disconnect. It essentially converts websockets communication to a request/response thing. I would assume that you can give each user an ID and so do asynchronous message sends, but I haven't looked to closely at it yet.

kardan08:12:00

I see, thanks for explaining. I will look a bit more 🙂

rhansen08:12:05

Sure, no problem :9

claudiu09:12:49

Hi 🙂 anybody know what's the role of "preload database" and what it adds on top of the deploy life-cycle ? in the deploy reference (https://docs.datomic.com/cloud/ions/ions-reference.html#deploy-outputs) it says Ensure that active databases are present in memory before routing requests to newly updated nodes..

igrishaev11:12:17

I still cannot solve my problem. Imagine I have a model: an account with a set if interests.

{:db/ident       :account/id
  :db/valueType   :db.type/long
  :db/cardinality :db.cardinality/one
  :db/unique      :db.unique/identity}

{:db/ident       :account/interests
 :db/valueType   :db.type/string
 :db/cardinality :db.cardinality/many
 :db/index       true}
Now I need to query all the accounts that have ALL the interests I’ve got from request. What I tried (for a single account):
(d/q 

 '[:find ?id ?interest
   :in $ ?a [?interest ...]
   :where
   [?a :account/id        ?id]
   (not [?a :account/interests ?interest])]
 
 (d/db conn)
 [:account/id 1]
 ["foo" "bar" "baz"])
or
(d/q 

 '[:find ?id ?interest
   :in $ ?a [?interest ...]
   :where
   [?a :account/id        ?id]
   (not-join
    [?a ?interest]
    (not [?a :account/interests ?interest]))]
 
 (d/db conn)
 [:account/id 1]
 ["foo" "bar" "baz"])
It works partially yet I still have wrong data. How can I improve that?

octahedrion11:12:44

@igrishaev - I have a similar problem: I have a thing with a :db.cardinality/many attribute & I need to query for all having two kinds of values e.g. this thing can have multiple colours and I want all the things having red and green colours

benoit12:12:48

@igrishaev One way to do it would be to dynamically generate a and clause with all the interests you're looking for:

(and
 [?a :account/interest ?i1]
 [?a :account/interest ?i2]
 ...)

octahedrion13:12:10

what if :account/interest was another entity which you wanted to ensure there were 2 instances of which each had attributes ?i1 and ?i2

benoit13:12:53

You can add clauses with intermediate vars for those entities. If that gets too long you can abstract the set of clauses with a rule.

octahedrion14:12:23

I tried that, but it didn't work

igrishaev12:12:49

@me1740 hm, makes sense…

igrishaev12:12:24

a friend of mine suggested me to pull entity and intersect sets

igrishaev12:12:44

[(d/entity $ ?e) ?ent]
[(:interests ?ent) ?interests]
[(subset? #{"cars" "games"} ?interests)]

benoit12:12:06

You're not taking advantage of your indexes with something like that. You have to pull every single account and do the subset? operation on it.

igrishaev12:12:32

right, that would be too slow

igrishaev12:12:48

the idea of multiple conditions is much better

anders12:12:29

which aws instance types are supported by datomic on-prem? ensure-cf fails for m5.large

jaret13:12:58

@U0ESP0TS8 I believe all legal instance types are supported ( http://aws.amazon.com/ec2/instance-types/). I just tested by ensuring a my-cf.properties file with aws-instance-type=m5.large in us-east-1 and the ensure did not fail.

$ bin/datomic ensure-cf my-cf.properties my-cf.properties
{:success my-cf.properties}

jaret13:12:09

What error are you seeing?

anders13:12:08

$  bin/datomic ensure-cf cf-template.properties cf-template.properties
java.lang.Exception: Key not found: m5.large
	at datomic.common$getx.invokeStatic(common.clj:191)
	at datomic.common$getx.invoke(common.clj:184)
	at datomic.memory$aws_transactor_settings.invokeStatic(memory.clj:174)
	at datomic.memory$aws_transactor_settings.invoke(memory.clj:170)
...

anders13:12:29

eu-central-1 region, datomic-pro-0.9.5786

jaret14:12:43

hmmm I am not seeing that at all. Would you mind logging a ticket to support or sharing your properties file with me? I’d like to try with your file.

jaret14:12:01

<mailto:[email protected]|[email protected]> e-mail should generate a ticket that I can look at

anders14:12:32

jaret, have you tried against eu-central-1?

jaret14:12:50

I tried with ensure on eu-central-1.

jaret14:12:07

But just ensure. I didn’t start the process from the beginning.

jaret14:12:32

Please let me know when you send the e-mail, I want to make sure I jump on this when it comes in. 🙂

benoit13:12:52

@igrishaev In case you don't know about it. It's probably easier to dynamically generate queries using the map form. https://docs.datomic.com/on-prem/query.html#list-vs-map

Dustin Getz14:12:15

@igrishaev @me1740 Rules to test if a collection of players are a subset of the players in a roster https://gist.github.com/dustingetz/66e493e87a99b9656e2cfe96bf6a51cc cc @cjsauer

eraserhd14:12:57

@igrishaev here's what I meant (I haven't tested, but it should work): https://gist.github.com/eraserhd/c918cd1fa8cf06694b071c135e532125

benoit14:12:29

@dustingetz yes, recursive rule should work too

igrishaev14:12:40

@eraserhd thanks a lot, let me check it

benoit14:12:28

I had a bad surprise with using clojure core functions on the transactor a while back. Never got an answer as why it fails https://forum.datomic.com/t/conj-in-a-rule-fails-on-the-transactor/413

benoit14:12:31

I would be very curious to figure out why this fails. And since then I try to stay away from this kind of queries that build clojure data.

Dustin Getz15:12:48

"This only happens in the transactor and not with d/with. "

eraserhd17:12:40

I had an issue much like this. I thought Datomic was reordering clauses, which they tell me they don't do.

eraserhd17:12:57

In my case, a bound variable was nil and I got an NPE.

eraserhd17:12:56

It had two characteristics of yours: calling a function that takes $, followed by calling regular clojure code.

eraserhd17:12:06

In my case, IIRC (I've lost the commit hash), the function which takes $ checked a precondition and failed, but the clojure code following it seem to run before the precondition was checked.

eraserhd17:12:44

er, by "and failed", I mean like Prolog's cut, not like it actually failed.

joshkh17:12:41

friday pre-holiday brain melt.. can i test a transaction against a db using d/with-db? it returns a db, but d/transact requires a connection.

tomjack17:12:58

so what? why do you want to put the square peg into the round hole?

joshkh18:12:27

no, of course not. just explaining my disconnect. i recall someone testing transactions against a with-db'ed version of the database and then checking the results, but only in memory.

tomjack18:12:30

yes, you can do that. I don't understand what the connection argument to d/transact has to do with it

tomjack18:12:54

you just use with-db

tomjack18:12:58

ahem, with

joshkh18:12:22

there's my disconnect. 🙂

tomjack18:12:29

if you want to later transact the transaction and be sure to get the same thing... you have to do something about it

joshkh18:12:20

yup. got it. forgot that with should replace transact, that's all. thanks!