Created
April 27, 2011 16:18
-
-
Save bcg/944581 to your computer and use it in GitHub Desktop.
Problems with scala
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
class MyReducer extends Reducer[Text, Text, Text, Text] { | |
// How does one define a class level variable in Scala? Below does not work ... | |
var mo: MultipleOutputs[Context] | |
def setup(context : Context) { | |
mo = new MultipleOutputs(context) | |
} | |
def reduce(key : Text, values : java.util.Iterator[Text], context : Context) { | |
for(log <- values) { | |
mo.write(key, new Text(log), "/tmp/file-" + key) | |
} | |
} | |
def cleanup(context : Context) { | |
mo.close() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment