This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-03
Channels
- # adventofcode (91)
- # announcements (7)
- # aws (3)
- # babashka (69)
- # beginners (46)
- # calva (30)
- # cider (12)
- # clj-kondo (88)
- # cljs-dev (11)
- # cljsrn (1)
- # clojure (195)
- # clojure-dev (21)
- # clojure-europe (2)
- # clojure-italy (13)
- # clojure-nl (56)
- # clojure-spec (4)
- # clojure-sweden (6)
- # clojure-uk (27)
- # clojurescript (179)
- # core-async (2)
- # cryogen (1)
- # cursive (2)
- # data-science (1)
- # datomic (57)
- # fulcro (15)
- # graalvm (9)
- # instaparse (6)
- # joker (18)
- # juxt (9)
- # leiningen (6)
- # off-topic (20)
- # other-languages (10)
- # pathom (5)
- # re-frame (20)
- # reitit (2)
- # rewrite-clj (5)
- # shadow-cljs (78)
- # sql (34)
- # tools-deps (128)
- # uncomplicate (16)
- # vim (6)
So, I'm looking to migrating to next-jdbc. We have a nice wraper around clojure.jdbc that we use for lazy batch processing(millions of rows, doseq/partition-all based).
I've written it in two different ways with next-jdbc and both feel "unnatural". I first wrote it with next.jdbc/plan + an eduction
(eduction (map transformation-goes-here) (partitiona-all batch-count) (jdbc/plan ....))
and afterwards a reduce over itThen with channels, dispatching from inside a simple reduce over jdbc/plan (and a lazy-seq on the channel). Neither, I feel, gives the flexibility of a simple "lazy-seq".
Am I missing something obvious or should I get used to transducers as the new reality for cursors?
How were you doing it with clojure.java.jdbc
?
plan
is a refinement of reducible-query
which is what you should have been using already I would expect.
But does what I wrote above make sense? Are those the two approaches we have with plan?
Then just use reduce
over plan
with a variant of that function
I think the two approaches you described are overkill
I am missing something them. My impression is that if I reduce the plan directly, I can't actually batch.
The result set fn must be eager by definition
A transducer can be stateful and handle partitioning if you need that
So transduce
over plan
if you need more than reduce
.
Right
And your result set fn before had to be eager
So you're not losing laziness here
That's just how transducers work : they are eager
I understand it, somehow. But still, I hope it actually picks up. The API is a lot nicer.
I'm actually quite pleased with how fast adoption is going -- given Clojure's slow pace of change in general 😁