终止scala程序?

时间:2014-10-29 15:02:00

标签: scala hadoop2

我使用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
    }
  }
}

1 个答案:

答案 0 :(得分:0)

我认为你仍然需要调用context.write将控件返回给Hadoop,即使你决定跳过' else'中的某些数据。