Fork me on GitHub
#datomic
<
2019-09-18
>
Andrey Popelo12:09:11

Hey Datomic On-Prem currently requires JDK 7 or 8. Is this also true for the peer library? Can the peer library be used with the latest JDK?

favila13:09:10

I don’t know if this is supported but I have used the peer on jdk 11 without problems. (or maybe there were problems getting it to work but I’ve forgotten them and they are non-issues now)

favila13:09:21

I’ve never successfully used a transactor on java 11

favila13:09:22

(I probably encountered minor opposition and decided it was safer not to even try to work through it, but honestly I don’t remember clearly)

marshall14:09:27

The latest release should run on jdk 11

marshall14:09:42

If you have any issues or problems doing so, please let us know

andrew.sinclair16:09:32

The peer or the transactor can run on jdk 11, or both?

Andrey Popelo06:09:54

Great, thank you

jeroenvandijk14:09:50

Did anyone happen to try and use the Github package registry to push the datomic-pro jar to their private repo?

jeroenvandijk14:09:26

I did and I'm failing to pull it back in with lein. I've asked Github for support

timgilbert21:09:49

Haven't tried on github but we've got it published on a private S3 repo via mvn deploy-file without too much trouble

jeroenvandijk08:09:41

@U08QZ7Y5S yeah I did that with other libraries too. This did result in AWS credentials in the project files as something else got too involved. I could probably do better here. Now I was hoping Github would be a nice alternative. Maybe it needs some time

eraad17:09:13

Hi! I would appreciate help with the following: I have a composite tuple that includes 5 unique attributes and I want to add a new unique attribute. What is the correct way to do it?

eraad17:09:51

The docs say that :tupleAttrs cannot be altered so the option would be to add a new composite tuple. I created one with the extra attribute, but the old one gets in the way.

ivana20:09:45

Hi! Is it possible to get db/id via get-else or use underscore reverse link in query?

favila20:09:02

[(get-else ?e :ref-attr ?not-found) ?v] -> ?v is your “:db/id” (if I understand your question correctly?)

favila20:09:16

The reverse form of an attr isn’t recognized in query clauses; reverse the clause order instead: [?v :attr ?e] instead of [?e :_attr ?v]

ivana20:09:38

Thanks, but reversing order makes me disappointed how to use get-else. I'l try you first suggestion

favila20:09:49

get-else only works on cardinality-one attributes; the reverse would be cardinality-many

favila20:09:54

so it wouldn’t work anyway

favila20:09:33

you could do an explicit d/datoms and check it for emptiness

ivana20:09:27

(d/q '[:find [(count-distinct ?item)]
         :in $
         :where
         [?o :order/pickup-items ?item]
         [?r :recycle/items ?item]]
       db)
=> [541]

ivana20:09:26

(d/q '[:find [(count-distinct ?item)]
         :in $
         :where
         [?o :order/pickup-items ?item]
        ;  [?r :recycle/items ?item]
         ]
       db)
=> [1561]

ivana20:09:13

I want all 1561 rows but with ?r when it present. What should I do?

ivana20:09:54

Mmmm, maybe I have to read more about it

favila20:09:27

I’m not 100 % sure what you want the output to be

favila20:09:05

something like [[?item (?r1 ?r2 ,,,)],,,]?

favila20:09:15

i.e. all the ?r reachable from an item?

ivana20:09:01

No. I want all 1561 items as a separate rows, but if item choosen also in recycle, I want its id, otherwise false by get-else or something similar

favila20:09:55

how is that different from what I said?

ivana20:09:39

I do not want any aggregations

favila20:09:16

if you don’t aggregate, you may get [item1 r1] [item1 r2] etc

favila20:09:23

i.e. item repeats

ivana20:09:48

it is not bad, I can process them in clojure

favila20:09:58

and if item doesn’t join to an r, what would you treat that as? having a single r?

favila20:09:04

with some sentinel?

ivana20:09:20

something default

ivana20:09:29

maybe false

ivana20:09:02

get-else works good, but not with db/id , only with values

favila20:09:02

what do you ultimately want? {:item item-eid :recycles #{recycle1 recycle2,,,}}?

favila20:09:35

but if item doesn’t have a recycle, what would it be? {:item item-eid :recycles #{:default}}?

favila20:09:04

^^ this is what I don’t get

ivana20:09:27

[item1 order1 rec1] [item1 order2 rec2] [item2 order2 false] ....

favila20:09:05

you mean [item2 order3 false] for that last one?

favila20:09:33

what you wrote isn’t possible

ivana20:09:38

it can be the same order

favila20:09:57

nm I missed that item1->2

favila20:09:19

if your query is simple, consider two queries and cat them together

favila20:09:29

`’[:find ?item ?o ?r :where [?o :order/pickup-items ?item] [?r :recycle/items ?item]]` if they have an item

ivana20:09:33

unfortunately my query sufficiently complex, I typed a simple example above for only to show the problem

favila20:09:52

ok, then you can use d/datoms directly

favila20:09:59

e.g a rule like this:

ivana20:09:10

Yes, code above extracts ONLY if item has recycle

ivana20:09:50

Simply speaking I want get-else for db/id

favila20:09:05

it’s not that simple because of cardinality

ivana20:09:58

ok, thanks again, I'l think about another way

favila20:09:26

nm you don’t need datoms, a rule can do it

favila20:09:03

(d/q
  '[:find ?i ?o ?r
    :where
    [?o :order/pickup-items ?i]
    (or-join [?i ?r]
      (and
        (not [_ :recycle/items ?i])
        [(ground false) ?r])
      [?r :recycle/items ?i])
    ]
  '[[o1 :order/pickup-items i1]
    [o2 :order/pickup-items i1]
    [o2 :order/pickup-items i2]
    [r1 :recycle/items i1]
    [r2 :recycle/items i1]]
  )
=> #{[i2 o2 false] [i1 o1 r2] [i1 o2 r2] [i1 o1 r1] [i1 o2 r1]}

👍 4
favila20:09:13

my other approach was call (d/datoms), perform a bounded count, and either destructure if nonzero or bind to your sentinel if zero

favila20:09:56

I’m still not convinced this is advisable, but there you go

ivana20:09:55

Thanks, I'l try you suggestion in a some minutes

ivana20:09:54

First impression that it is great and what I need!

ivana20:09:52

I have not discovered or-join magic with ground yet )

Brian20:09:05

Hey! I can do (d/transact db {:tx-data some-map}) to add a map of data to my database. Is there a way to do the opposite? If I have some-map or stuff and I want to retract those from the database?

favila20:09:53

the map form of a transaction is purely syntactic sugar for a bunch of [:db/add ...] clauses (which is what everything ultimately expands to. There’s no syntactic sugar for :db/retract

favila20:09:58

when you say {:db/id e :attr v} in a tx, you are only adding assertions to the entity, you are not making the entity look like your map.

favila20:09:18

that said there are some transaction functions floating around which can make your entity “look like” the argument, i.e. do whatever adds/retracts are necessary atomically

favila20:09:35

here’s some I wrote a long time ago, I’m sure there are better ones now: https://gist.github.com/favila/8ce31de4b2cb04cf202687c6a8fa4c94

Brian20:09:16

Okay copy copy. With that, let me give you a little more context. So I have a vector of vectors with 3 values in them. I was very easily able to zipmap keys into those vectors and turn them into a vector of maps, then boom I could add them to the database. Now I have that same vector of vectors and I want to instead retract that information from the database. Should I just put all that information through a function which returns [:db/retract ...] until I have a bunch of those?

Brian20:09:06

Looking at that code now. Would that solve the problem given the context I just shared? If so, I'll run with that. Otherwise, it's a bit complicated for me to off-the-bat understand what it's doing. I'm a bit new to Clojure I must admit

favila20:09:38

yes, just generate retractions

favila20:09:59

{:db/id id :attr v} => [:db/add id :attr v]