RecordWriter接口解析

RecordWriter是将Map/Reduce结果(Key-Value)输出到文件系统中。

/**
 * <code>RecordWriter</code> writes the output &lt;key, value&gt; pairs 
 * to an output file.
 
 * <p><code>RecordWriter</code> implementations write the job outputs to the
 * {@link FileSystem}.
 * 
 * @see OutputFormat
 */
@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract class RecordWriter<K, V> {
  /** 
   * Writes a key/value pair.
   * 将Map/Reduce结果的key/value写到文件系统中去。
   * @param key the key to write.
   * @param value the value to write.
   * @throws IOException
   */      
  public abstract void write(K key, V value) throws IOException, InterruptedException;

  /** 
   * Close this <code>RecordWriter</code> to future operations.
   * 关闭输出操作
   * @param context the context of the task
   * @throws IOException
   */ 
  public abstract void close(TaskAttemptContext context) 
          throws IOException, InterruptedException;
}

 

posted on 2014-05-02 16:23  月下美妞1314  阅读(988)  评论(0编辑  收藏  举报