This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-29
Channels
- # admin-announcements (2)
- # beginners (4)
- # boot (6)
- # cider (18)
- # cljs-dev (22)
- # cljsrn (13)
- # clojure (76)
- # clojure-czech (2)
- # clojure-dusseldorf (2)
- # clojure-russia (45)
- # clojure-sg (1)
- # clojure-spec (15)
- # clojurebridge-ams (6)
- # clojurescript (58)
- # cursive (4)
- # datomic (14)
- # dirac (31)
- # emacs (6)
- # funcool (2)
- # hoplon (2)
- # lein-figwheel (1)
- # om (124)
- # planck (17)
- # re-frame (12)
- # slack-help (11)
- # specter (12)
- # tmp-json-parsing (6)
- # yada (4)
hi all, I’m new to datomic and I have a datalog question. This is my query:
'[:find (pull ?p [:]) (count ?v)
:where
[?p :]
[?v :td.vote/post ?p]]
and it returns no result if there are no votes for a post. I’d like datomic to put count 0 instead of omitting the post from results. Is there a nice way to achieve that?Not a nice way, no.
At present to get any value for an aggregate you have to have some tuple that matches in the intermediate set. I think @marshall may have an example using or or not with ground and missing or something as a workaround hack for this or a similar problem.
Pull does support default expressions so it may make more sense to get all values with a 0 as a default in the pull and do count or sum outside the query.
Yes, you can sort of get that behavior with or and missing?, but it's not great. @bkamphaus suggestion of pull with default is probably cleaner
The only thing that scares me is, what if I have too many votes so they don’t fit in memory (very unlikely, but I’m curious)? With aggregation functions this problem should be avoided, but not with manual counting.
The intermediate rep has to fit in mem for the query to work in the first place (query runs on peer).