RecordWriter接口解析

时间:2021-11-07 03:10:03

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;
}