Last active
December 17, 2015 07:09
-
-
Save sritchie/5571012 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(defn cascalog-map | |
[op-var output-fields & {:keys [stateful?]}] | |
(let [ser (KryoService/serialize (ops/fn-spec op-var))] | |
(proxy [BaseOperation Function] [^Fields output-fields] | |
(prepare [^FlowProcess flow-process ^OperationCall op-call] | |
(let [op (Util/bootFn (KryoService/deserialize ser))] | |
(-> op-call | |
(.setContext [op (if stateful? (op))])))) | |
(operate [^FlowProcess flow-process ^FunctionCall fn-call] | |
(let [[op] (.getContext fn-call) | |
collector (-> fn-call .getOutputCollector) | |
^Tuple tuple (-> fn-call .getArguments .getTuple)] | |
(->> (Util/coerceFromTuple tuple) | |
(apply op) | |
(Util/coerceToTuple) | |
(.add collector)))) | |
(cleanup [flow-process ^OperationCall op-call] | |
(if stateful? | |
(let [[op state] (.getContext op-call)] | |
(op state))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment