2014-10-29 5 views
0

나는 mapreduce 코드의 일부로 try catch를 사용했습니다. 아래 코드에서 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

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

+2

'sys.exit()', 기술적으로 질문에 대한 대답은 거의 올바른 행동이 아닙니다. 아마 하둡 (Hadoop)에있는 것이지만, 이것이 XY 문제인지 아닌지를 파악하기 위해서는 더 자세한 정보가 필요하다고 생각합니다. –

답변

0

아래의 코드를 사용하여 작업을 종료 할 나는 여전히 다시 하둡에 당신이 '다른'에서 특정 데이터를 생략하기로 결정하는 경우에도 제어를 반환 context.write를 호출 할 필요가 있다고 생각합니다.