本文整理汇总了Java中org.apache.avro.mapreduce.AvroMultipleOutputs.addNamedOutput方法的典型用法代码示例。如果您正苦于以下问题:Java AvroMultipleOutputs.addNamedOutput方法的具体用法?Java AvroMultipleOutputs.addNamedOutput怎么用?Java AvroMultipleOutputs.addNamedOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.avro.mapreduce.AvroMultipleOutputs
的用法示例。
在下文中一共展示了AvroMultipleOutputs.addNamedOutput方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.apache.avro.mapreduce.AvroMultipleOutputs; //导入方法依赖的package包/类
@Override
public void process(Annotation annotation, Job job, Object target)
throws ToolException {
AvroNamedOutput avroOut = (AvroNamedOutput)annotation;
Schema schema = getSchema(avroOut.record());
String[] names = getNames(avroOut);
for (String name : names) {
name = (String)evaluateExpression(name);
if (!configured.contains(name)) {
AvroMultipleOutputs.addNamedOutput(job, name, avroOut.format(), schema);
AvroMultipleOutputs.setCountersEnabled(job, avroOut.countersEnabled());
configured.add(name);
}
}
AvroSerialization.addToConfiguration(job.getConfiguration());
}
示例2: internalRun
import org.apache.avro.mapreduce.AvroMultipleOutputs; //导入方法依赖的package包/类
public Job internalRun(Path origInput, Path destInput, Path outputDir, Configuration conf) throws Exception {
conf.set("viadeo.diff.diffinpath", origInput.toString());
conf.set("viadeo.diff.diffoutpath", destInput.toString());
Job job = new Job(conf);
job.setJarByClass(DiffJob.class);
job.setJobName("diff");
Schema schema = SchemaUtils.getConfSchema(conf);
if(schema == null) schema = SchemaUtils.getSchema(conf, destInput);
FileInputFormat.setInputPaths(job, origInput, destInput);
job.setInputFormatClass(AvroKeyInputFormat.class);
job.setMapperClass(DiffMapper.class);
AvroJob.setInputKeySchema(job, schema);
AvroJob.setMapOutputKeySchema(job, schema);
job.setMapOutputValueClass(Text.class);
job.setReducerClass(DiffReducer.class);
AvroJob.setOutputKeySchema(job, schema);
job.setOutputValueClass(Text.class);
job.setOutputFormatClass(AvroKeyOutputFormat.class);
// ~ OUTPUT
FileOutputFormat.setOutputPath(job, outputDir);
AvroMultipleOutputs.addNamedOutput(job, "kernel", AvroKeyOutputFormat.class, schema);
AvroMultipleOutputs.addNamedOutput(job, "add", AvroKeyOutputFormat.class, schema);
AvroMultipleOutputs.addNamedOutput(job, "del", AvroKeyOutputFormat.class, schema);
AvroMultipleOutputs.setCountersEnabled(job, true);
return job;
}
示例3: run
import org.apache.avro.mapreduce.AvroMultipleOutputs; //导入方法依赖的package包/类
public Job run() throws Exception {
Job job = Job.getInstance(getConf());
job.setJobName(name);
job.setJarByClass(DerivedColumnTransformationPhaseJob.class);
Configuration configuration = job.getConfiguration();
FileSystem fs = FileSystem.get(configuration);
// Input Path
String inputPathDir = getAndSetConfiguration(configuration, DERIVED_COLUMN_TRANSFORMATION_PHASE_INPUT_PATH);
LOGGER.info("Input path dir: " + inputPathDir);
for (String inputPath : inputPathDir.split(",")) {
LOGGER.info("Adding input:" + inputPath);
Path input = new Path(inputPath);
FileInputFormat.addInputPath(job, input);
}
// Topk path
String topkPath = getAndSetConfiguration(configuration, DERIVED_COLUMN_TRANSFORMATION_PHASE_TOPK_PATH);
LOGGER.info("Topk path : " + topkPath);
// Output path
Path outputPath = new Path(getAndSetConfiguration(configuration, DERIVED_COLUMN_TRANSFORMATION_PHASE_OUTPUT_PATH));
LOGGER.info("Output path dir: " + outputPath.toString());
if (fs.exists(outputPath)) {
fs.delete(outputPath, true);
}
FileOutputFormat.setOutputPath(job, outputPath);
// Schema
Schema avroSchema = ThirdeyeAvroUtils.getSchema(inputPathDir);
LOGGER.info("Schema : {}", avroSchema.toString(true));
// ThirdEyeConfig
String dimensionTypesProperty = ThirdeyeAvroUtils.getDimensionTypesProperty(
props.getProperty(ThirdEyeConfigProperties.THIRDEYE_DIMENSION_NAMES.toString()), avroSchema);
props.setProperty(ThirdEyeConfigProperties.THIRDEYE_DIMENSION_TYPES.toString(), dimensionTypesProperty);
String metricTypesProperty = ThirdeyeAvroUtils.getMetricTypesProperty(
props.getProperty(ThirdEyeConfigProperties.THIRDEYE_METRIC_NAMES.toString()),
props.getProperty(ThirdEyeConfigProperties.THIRDEYE_METRIC_TYPES.toString()), avroSchema);
props.setProperty(ThirdEyeConfigProperties.THIRDEYE_METRIC_TYPES.toString(), metricTypesProperty);
ThirdEyeConfig thirdeyeConfig = ThirdEyeConfig.fromProperties(props);
job.getConfiguration().set(DERIVED_COLUMN_TRANSFORMATION_PHASE_THIRDEYE_CONFIG.toString(),
OBJECT_MAPPER.writeValueAsString(thirdeyeConfig));
LOGGER.info("ThirdEyeConfig {}", thirdeyeConfig.encode());
// New schema
Schema outputSchema = newSchema(thirdeyeConfig);
job.getConfiguration().set(DERIVED_COLUMN_TRANSFORMATION_PHASE_OUTPUT_SCHEMA.toString(), outputSchema.toString());
// Map config
job.setMapperClass(DerivedColumnTransformationPhaseMapper.class);
job.setInputFormatClass(AvroKeyInputFormat.class);
job.setMapOutputKeyClass(AvroKey.class);
job.setMapOutputValueClass(NullWritable.class);
AvroJob.setOutputKeySchema(job, outputSchema);
LazyOutputFormat.setOutputFormatClass(job, AvroKeyOutputFormat.class);
AvroMultipleOutputs.addNamedOutput(job, "avro", AvroKeyOutputFormat.class, outputSchema);
job.setNumReduceTasks(0);
job.waitForCompletion(true);
return job;
}