终止scala程序?

问题描述:

我已经使用try catch作为我的mapreduce代码的一部分。我在下面的代码中基于COUNT减少了我的值。我我如何终止使用该代码的工作在以下终止scala程序?

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

'sys.exit()' http://www.scala-lang.org/api/current/index.html#[email protected](status:Int):Nothing – lea 2014-10-29 15:05:18

+2

'sys.exit ()',虽然技术上这个问题的答案很少是正确的行为。也许在Hadoop中,但我认为我们需要更多的细节来弄清楚这是否是XY问题。 – 2014-10-29 15:13:23

觉得你还是需要调用context.write返回控制返回到Hadoop的,即使你决定在“其他”跳过某些数据。