Fork me on GitHub
#datomic
<
2016-03-14
>
tianshu14:03:01

How to sort and limit result in datomic query? I saw seek-datoms, but it seems that can only query one attribute?

casperc15:03:02

I have this database function where I require a namespace in my own project, using the requires syntax. This is working when using the in memory database, but not in one that is backed by a Cassandra base.

casperc15:03:48

Do I need to put the namespace on the transactor classpath somehow to make it work?

casperc15:03:39

@bkamphaus: I have read it and I don’t think it explains the issue very well. It just says to use require or imports, but not how to get that that code loaded in the transactor

casperc15:03:53

Can you elaborate what should be done?

Ben Kamphaus15:03:30

jar in the lib subdirectory of the Datomic distribution, i.e. datomic-pro-0.9.5350/lib - I can re-read and see if we need to add it.

casperc15:03:21

@bkamphaus: Ok thanks. I guess it makes it a bit harder to use. I think it makes more sense to define the functions in the scope of the code block then (even though that is a bit ugly)

casperc15:03:48

And regarding the docs, IMO the documentation is quite weak for database functions, so I think it could use a brush off with some more examples, e.g. with a :require in there.

casperc15:03:30

Thanks for the swift answer though simple_smile

Ben Kamphaus15:03:55

I can take a look at improving the dbfn docs. I will say, that it’s not a path that we want to be too encouraging simple_smile but maybe we can document that to some extent as well.

Ben Kamphaus15:03:43

there aren’t a lot of use cases for dbfns outside of a transaction function, and transaction function uses should be really limited — i.e. when you need to guarantee ACID isolation and can’t do so with a builtin like cas and an optimistic concurrency strategy.

casperc15:03:31

@bkamphaus: Well maybe there is a better way to do what I am doing then. simple_smile I have made a replace-entity function, which takes an entity id and a new “version” of the entity which should replace the old. The function makes retractions for the fields that are not present in the new version and updates the fields that are still present - cardinality many attrs are retracted and new values are inserted.

casperc15:03:33

@bkamphaus: So it is a CAS-like functionality. Actually I would have expected it to be a built-in, since would seem like a fairly common use case in my mind.

Ben Kamphaus15:03:53

I would say what you’re doing matches the transaction function use case fine. When you say “CAS-like” do you mean it should fail on update from time of submission, or is the transaction written so that it should ignore any updates made (i.e. implicit retract) between transaction submission and write time?

casperc15:03:19

@bkamphaus: Well actually no, it’s not really cas-like come to think of it. It only updates the current entity with a sort of “overwrite” semantic on the current entity.

casperc15:03:42

So it uses the current database value to see which adds and retracts it should make, but doesn’t really compare and fail if the value is not the expected like cas

casperc15:03:20

But doing it in the peer would allow for a race condition i believe

Ben Kamphaus15:03:46

yep, it matches the transaction function use case shape pretty well, so I think your approach makes sense.

casperc15:03:25

@bkamphaus: On a different note, I read your blog post about AlphaGo and the previous one. I liked them simple_smile

casperc15:03:14

I am trying to get a grasp of deep learning so I appreciate your approach of trying to address obstacles when looking into it

Ben Kamphaus16:03:12

glad to hear you’ve found it to be worthwhile reading. The way I find it helpful to think about it is frequently different than what I see in my own reading and research, so I’m happy to write the posts as an exercise in understanding for my own benefit. I’m doubly glad if anyone else gets anything out of it.

Ben Kamphaus16:03:45

I definitely plan to continue with the deep learning theme and touch on other frameworks, probably at the same 1-2 post/month rate for now.

casperc16:03:15

Sounds good, I’ll keep an eye out then.