Fork me on GitHub

I have the result of a clojure.jdbc/reducible-query that I’d like to put onto a channel, however both to-chan and onto-chan appear to rely on the seq interface, which is giving me this error. (I also happen to be applying an eduction to the query result, but i don’t think that’s relevant):

java.lang.IllegalArgumentException: Don't know how to create ISeq from:$reducible_query$reify__16834
        at clojure.lang.RT.seqFrom(
        at clojure.lang.RT.seq(
        at clojure.lang.RT.iter(
        at clojure.core.Eduction.iterator(core.clj:7560)
        at clojure.lang.RT.seqFrom(
        at clojure.lang.RT.seq(
        at clojure.core$seq__6407.invokeStatic(core.clj:137)
        at clojure.core$seq__6407.invoke(core.clj:137)
        at clojure.core.async$bounded_count.invokeStatic(async.clj:629)
        at clojure.core.async$bounded_count.invoke(async.clj:623)
        at clojure.core.async$to_chan.invokeStatic(async.clj:653)
        at clojure.core.async$to_chan.invoke(async.clj:649)


@uwo Yeah, I was a bit surprised that there doesn't seem to be an obvious way to reduce a collection onto a channel. It's been a while since I looked at it, and I didn't dig very deeply.


@seancorfield interesting! thanks for the response.


@seancorfield do you remember why you decided to go with IReduce, instead of IReduceInit?


@uwo To support more use cases. A number of constructs in core support IReduce (cycle, repeat, range, iterable, persistent list, persistent vector), and IReduce is a superset of IReduceInit so reducible-query is acceptable to both.


any idea why an eduction over the result of reducible-query would lead to at clojure.lang.RT.seq getting called?


it appears my problem was further up the chain, before onto-chan was called. attempts to reduce over (eduction xf (clojure.jdbc/reducible-query ...)) ultimately result in clojure.lang.RT.iter calling seq.


what version of clojure?


I guess reducible-query requires something with IReduce


are you reducing without giving an initial value?


Eduction only implements clojure.lang.IReduceInit not clojure.lang.IReduce


(so because it doesn't implement IReduce, reducing goes through its implementation of Iterable, which is what calls RT.iter)