Skip to content

Instantly share code, notes, and snippets.

@bcg
Created April 27, 2011 16:18
Show Gist options
  • Save bcg/944581 to your computer and use it in GitHub Desktop.
Save bcg/944581 to your computer and use it in GitHub Desktop.
Problems with scala
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