Mapper reducer 的生命周期

来源:互联网 发布:raysource mac版 编辑:程序博客网 时间:2024/05/19 09:04
/**   * Called once at the start of the task.只在任务开始的时候 运行一次   */  protected void setup(Context context                       ) throws IOException, InterruptedException {    // NOTHING  }  /**   * This method is called once for each key. Most applications will define   * their reduce class by overriding this method. The default implementation   * is an identity function.每个key都运行一次。   */  @SuppressWarnings("unchecked")  protected void reduce(KEYIN key, Iterable<VALUEIN> values, Context context                        ) throws IOException, InterruptedException {    for(VALUEIN value: values) {      context.write((KEYOUT) key, (VALUEOUT) value);    }  }  /**   * Called once at the end of the task.只在任务结束的时候运行一次   */  protected void cleanup(Context context                         ) throws IOException, InterruptedException {    // NOTHING  }