Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (let [reader (SequenceFile$Reader. file-system x hadoop-conf)
- key (ReflectionUtils/newInstance (.. reader
- getKeyClass
- (asSubclass WritableComparable))
- hadoop-conf)
- value (ReflectionUtils/newInstance (.. reader
- getValueClass
- (asSubclass Writable))
- hadoop-conf)
- inbuf (DataInputBuffer.)
- outbuf (DataOutputBuffer.)]
- (. stream close)
- (proxy [InputStream] []
- (read []
- (if (or (nil? inbuf) (= (. inbuf read) -1))
- (if (not (. reader (next key value)))
- -1
- (do
- (let [tmp (.. key toString getBytes)]
- (doto outbuf
- (.write tmp 0 (. tmp length))
- (.write \tab)))
- (let [tmp (.. value toString getBytes)]
- (doto outbuf
- (.write tmp 0 (. tmp length))
- (.write \newline)))
- (. inbuf (reset (. outbuf getData)
- (. outbuf getLength)))
- (. outbuf reset)
- (. read inbuf)))))))
Add Comment
Please, Sign In to add comment