我使用try catch作为mapreduce代码的一部分。我在以下代码中根据COUNT减少了我的值。如何使用下面的代码
终止作业class RepReducer extends Reducer[NullWritable, Text, Text, IntWritable] {
override def reduce(key: NullWritable, values: Iterable[Text], context: Reducer[NullWritable, Text, Text, IntWritable]#Context): Unit = {
val count = values.toList.length
if (count == 0){
try {
context.write(new Text("Number of tables with less than 40% coverage"), new IntWritable(count))
} catch {
case e: Exception =>
Console.err.println(" ")
e.printStackTrace()
}
}
else
{
System.out.println("terminate job") //here i want to terminate if count is not equal to 0
}
}
}
答案 0 :(得分:0)
我认为你仍然需要调用context.write将控件返回给Hadoop,即使你决定跳过' else'中的某些数据。