Created
February 14, 2013 05:10
-
-
Save omnisis/4950714 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Write key and value to baseOutputPath using the namedOutput. | |
* | |
* @param namedOutput the named output name | |
* @param key the key | |
* @param value the value | |
* @param baseOutputPath base-output path to write the record to. | |
* Note: Framework will generate unique filename for the baseOutputPath | |
*/ | |
@SuppressWarnings("unchecked") | |
public <K, V> void write(String namedOutput, K key, V value, | |
String baseOutputPath) throws IOException, InterruptedException { | |
checkNamedOutputName(context, namedOutput, false); | |
checkBaseOutputPath(baseOutputPath); | |
if (!namedOutputs.contains(namedOutput)) { | |
throw new IllegalArgumentException("Undefined named output '" + | |
namedOutput + "'"); | |
} | |
TaskAttemptContext taskContext = getContext(namedOutput); | |
getRecordWriter(taskContext, baseOutputPath).write(key, value); | |
} | |
/** | |
* Write key value to an output file name. | |
* | |
* Gets the record writer from job's output format. | |
* Job's output format should be a FileOutputFormat. | |
* | |
* @param key the key | |
* @param value the value | |
* @param baseOutputPath base-output path to write the record to. | |
* Note: Framework will generate unique filename for the baseOutputPath | |
*/ | |
@SuppressWarnings("unchecked") | |
public void write(KEYOUT key, VALUEOUT value, String baseOutputPath) | |
throws IOException, InterruptedException { | |
checkBaseOutputPath(baseOutputPath); | |
TaskAttemptContext taskContext = new TaskAttemptContext( | |
context.getConfiguration(), context.getTaskAttemptID()); | |
getRecordWriter(taskContext, baseOutputPath).write(key, value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment