is it possible to join on lazy seqs?

139 views
Skip to first unread message

mond

unread,
Jul 16, 2013, 10:43:21 AM7/16/13
to clo...@googlegroups.com
Sorry if this is a RTFM style question ... this is what I have in terms of types and was wondering if there is another form of join or another library / collection combination that can achieve the same relational join?

Thanks in advance,

Ray

check-delta-feeds.core=> (def changed-records (map find-changed-records (set/select #(= (:entity %) (entity-names :project))  query-parts)))               
#'check-delta-feeds.core/changed-records
check-delta-feeds.core=>check-delta-feeds.core=> 
check-delta-feeds.core=> (def feed-entries (obtain-feed-entries (fetch-atom-feed-until tgb-feed-url until-datetime)))
#'check-delta-feeds.core/feed-entries
check-delta-feeds.core=> (type changed-records )
clojure.lang.LazySeq
check-delta-feeds.core=> (type feed-entries)
clojure.lang.LazySeq
check-delta-feeds.core=> (set/join changed-records feed-entries {:ID :dh-uuid})
ClassCastException clojure.lang.LazySeq cannot be cast to java.util.Map  clojure.lang.RT.find (RT.java:733)



Michael Klishin

unread,
Jul 16, 2013, 10:48:25 AM7/16/13
to clo...@googlegroups.com
2013/7/16 mond <r...@mcdermott.be>

check-delta-feeds.core=> (set/join changed-records feed-entries {:ID :dh-uuid})
ClassCastException clojure.lang.LazySeq cannot be cast to java.util.Map  clojure.lang.RT.find (RT.java:733)

You can use clojure.set/join on lazy sequences but joining a list (produced by a sequence) with
a map makes no sense.

You have {:ID :dh-uuid} in the code above. Maybe you want #{:ID :dh-uuid}, another set?

mond

unread,
Jul 16, 2013, 11:18:04 AM7/16/13
to clo...@googlegroups.com
I am trying to produce a list of records where the keys match. It makes sense to me ;-)

The examples from the docs show this:

(join animals personalities {:kind :species})

and the third argument is a key map to show which fields from the two collections should be treated as the same key

Niels van Klaveren

unread,
Jul 17, 2013, 5:33:04 AM7/17/13
to clo...@googlegroups.com
Perhaps you could post a minimal example of the two datasets you're trying to join ?

To do multiple types of joins (left, right, inner, natural & cross) on collections of maps/records, I use Sean Devlin's table-utils library. There's no jar, but there's instructions on how to make a version without dependencies other than Clojure in this stackoverflow question.
Reply all
Reply to author
Forward
0 new messages