• (preduce f data)
Similar to merge-with, but the contents of each key are merged in
parallel using f.

f - a function of 2 arguments.
data - a collection of hashes.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/datalog/util.clj:62 top

(defn preduce
  "Similar to merge-with, but the contents of each key are merged in
   parallel using f.

   f - a function of 2 arguments.
   data - a collection of hashes."
  [f data]
  (let [data-1 (map (fn [h] (map-values #(list %) h)) data)
        merged (doall (apply merge-with concat data-1))
        ; Groups w/ multiple elements are identified for parallel processing
        [complex simple] (separate (fn [[key vals]] (> (count vals) 1)) merged)
        fold-group (fn [[key vals]] {key (reduce f vals)})
        fix-single (fn [[key [val]]] [key val])]
    (apply merge (concat (pmap fold-group merged) (map fix-single simple)))))
Vars in clojure.contrib.datalog.util/preduce: apply concat defn let map merge pmap
Used in 0 other vars

Comments top

No comments for preduce. Log in to add a comment.