本文整理汇总了Java中org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter.getWorkPath方法的典型用法代码示例。如果您正苦于以下问题:Java FileOutputCommitter.getWorkPath方法的具体用法?Java FileOutputCommitter.getWorkPath怎么用?Java FileOutputCommitter.getWorkPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter
的用法示例。
在下文中一共展示了FileOutputCommitter.getWorkPath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRecordWriter
import org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter; //导入方法依赖的package包/类
/**
* Creates a new {@link RecordWriter} to output temporary data.
* @param <V> value type
* @param context current context
* @param name output name
* @param dataType value type
* @return the created writer
* @throws IOException if failed to create a new {@link RecordWriter}
* @throws InterruptedException if interrupted
*/
public <V> RecordWriter<NullWritable, V> createRecordWriter(
TaskAttemptContext context,
String name,
Class<V> dataType) throws IOException, InterruptedException {
Configuration conf = context.getConfiguration();
FileOutputCommitter committer = (FileOutputCommitter) getOutputCommitter(context);
Path file = new Path(
committer.getWorkPath(),
FileOutputFormat.getUniqueFile(context, name, "")); //$NON-NLS-1$
ModelOutput<V> out = TemporaryStorage.openOutput(conf, dataType, file);
return new RecordWriter<NullWritable, V>() {
@Override
public void write(NullWritable key, V value) throws IOException {
out.write(value);
}
@Override
public void close(TaskAttemptContext ignored) throws IOException {
out.close();
}
@Override
public String toString() {
return String.format("TemporaryOutput(%s)", file); //$NON-NLS-1$
}
};
}
示例2: init
import org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter; //导入方法依赖的package包/类
@Override
public void init() throws IOException {
super.init();
Configuration taskConf = new Configuration();
Path stagingResultDir = new Path(stagingDir, TajoConstants.RESULT_DIR_NAME);
taskConf.set(FileOutputFormat.OUTDIR, stagingResultDir.toString());
ExecutionBlockId ebId = taskAttemptId.getTaskId().getExecutionBlockId();
writerContext = new TaskAttemptContextImpl(taskConf,
new TaskAttemptID(ebId.getQueryId().toString(), ebId.getId(), TaskType.MAP,
taskAttemptId.getTaskId().getId(), taskAttemptId.getId()));
HFileOutputFormat2 hFileOutputFormat2 = new HFileOutputFormat2();
try {
writer = hFileOutputFormat2.getRecordWriter(writerContext);
committer = new FileOutputCommitter(FileOutputFormat.getOutputPath(writerContext), writerContext);
workingFilePath = committer.getWorkPath();
} catch (InterruptedException e) {
throw new IOException(e.getMessage(), e);
}
LOG.info("Created hbase file writer: " + workingFilePath);
}
示例3: getDefaultWorkFile
import org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter; //导入方法依赖的package包/类
@Override
public Path getDefaultWorkFile(TaskAttemptContext context,
String extension) throws IOException {
FileOutputCommitter committer =
(FileOutputCommitter) super.getOutputCommitter(context);
return new Path(committer.getWorkPath(), getUniqueFile(context,
"part", extension));
}
示例4: getDefaultWorkFile
import org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter; //导入方法依赖的package包/类
public static <K, V> Path getDefaultWorkFile(FileOutputFormat<K, V> format,
TaskAttemptContext context) throws IOException {
FileOutputCommitter committer =
(FileOutputCommitter) format.getOutputCommitter(context);
return new Path(committer.getWorkPath(), getOutputFile(context));
}
示例5: getDefaultWorkFile
import org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter; //导入方法依赖的package包/类
/**
* Get the default path and filename for the output format.
* @param context the task context
* @param extension an extension to add to the filename
* @return a full path $output/_temporary/$task-id/part-[mr]-$id
* @throws java.io.IOException
*/
@Override
public Path getDefaultWorkFile(TaskAttemptContext context, String extension) throws IOException {
FileOutputCommitter committer = (FileOutputCommitter) getOutputCommitter(context);
return new Path(committer.getWorkPath(), getCustomFileName(context, getOutputName(context), extension));
}