Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns org.clojars.making.cloudure.conv
- (:import (org.apache.hadoop.io IntWritable LongWritable DoubleWritable Text))
- )
- (defmulti conv class)
- (defmethod conv :default [x]
- x)
- (defmacro defconv [conv-map]
- `(do
- ~@(for [c conv-map]
- `(defmethod conv ~(first c) [x#]
- (new ~(second c) x#)))))
- (defn conv-write [key value context]
- (.write context (conv key) (conv value)))
- (defconv {Integer IntWritable,
- Double DoubleWritable,
- Long LongWritable,
- String Text
- ;; and more
- })
- (comment
- (do
- (defmethod
- conv
- Integer
- [x__4915__auto__]
- (new IntWritable x__4915__auto__))
- (defmethod
- conv
- Double
- [x__4915__auto__]
- (new DoubleWritable x__4915__auto__))
- (defmethod
- conv
- Long
- [x__4915__auto__]
- (new LongWritable x__4915__auto__))
- (defmethod conv String [x__4915__auto__] (new Text x__4915__auto__)))
- )
Add Comment
Please, Sign In to add comment