Created
March 14, 2012 20:57
-
-
Save rplevy/2039468 to your computer and use it in GitHub Desktop.
possible solution to fake being able to serialize lambdas in Cascalog?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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