Skip to content

Instantly share code, notes, and snippets.

@rplevy
Created March 14, 2012 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rplevy/2039468 to your computer and use it in GitHub Desktop.
Save rplevy/2039468 to your computer and use it in GitHub Desktop.
possible solution to fake being able to serialize lambdas in Cascalog?
(import 'java.util.UUID)
(defn uuid-gensym [& [prefix]]
(gensym (format "%suuid%s-"
(str (when prefix (str prefix "-")))
(UUID/randomUUID))))
(defmacro mk-var [to-bind]
`(def ~(uuid-gensym) ~to-bind))
;; example use in a cascalog query
(defparallelagg count
:init-var (mk-var (fn [] 1))
:combine-var #'+)
;; ... OR
;; ... somewhere in the Cascalog code where it handles functions:
(if (var? f) f
(mk-var f))
;; then you should be able to instead say
(defparallelagg count
:init-var (fn [] 1)
:combine-var +)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment