当前位置: 首页>>代码示例>>Java>>正文


Java AvroWrapper类代码示例

本文整理汇总了Java中org.apache.avro.mapred.AvroWrapper的典型用法代码示例。如果您正苦于以下问题:Java AvroWrapper类的具体用法?Java AvroWrapper怎么用?Java AvroWrapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AvroWrapper类属于org.apache.avro.mapred包,在下文中一共展示了AvroWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: nextKeyValue

import org.apache.avro.mapred.AvroWrapper; //导入依赖的package包/类
@Override
public boolean nextKeyValue() throws IOException, InterruptedException {
  if (!reader.hasNext() || reader.pastSync(end)) {
    key = null;
    value = null;
    return false;
  }
  if (key == null) {
    key = new AvroWrapper<T>();
  }
  if (value == null) {
    value = NullWritable.get();
  }
  key.datum(reader.next(key.datum()));
  return true;
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:17,代码来源:AvroRecordReader.java

示例2: reduce

import org.apache.avro.mapred.AvroWrapper; //导入依赖的package包/类
public void reduce(Text key,
                   Iterator<DoubleWritable> values,
                   OutputCollector<AvroWrapper<StockAvg>,
                       NullWritable> output,
                   Reporter reporter) throws IOException {

  Mean mean = new Mean();
  while (values.hasNext()) {
    mean.increment(values.next().get());
  }
  StockAvg avg = new StockAvg();
  avg.setSymbol(key.toString());
  avg.setAvg(mean.getResult());
  output.collect(new AvroWrapper<StockAvg>(avg),
      NullWritable.get());
}
 
开发者ID:Hanmourang,项目名称:hiped2,代码行数:17,代码来源:AvroMixedMapReduce.java

示例3: write

import org.apache.avro.mapred.AvroWrapper; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void write(AvroWrapper<Pair<Utf8, T>> record, NullWritable n) throws IOException, InterruptedException {
  String key = record.datum().key().toString();
  if (!key.equals(currentKey)) {
    if (currentWriter != null) {
      currentWriter.close(null); // TaskAttemptContext not used for close
    }
    currentKey = key;
    Path dir = new Path(basePath, key);
    FileSystem fs = dir.getFileSystem(conf);
    if (!fs.exists(dir)) {
      fs.mkdirs(dir);
    }
    currentWriter = (RecordWriter<Void, T>)
        new AvroParquetFileTarget.CrunchAvroParquetOutputFormat().getRecordWriter(conf,
            new Path(dir, uniqueFileName),
            AvroParquetFileTarget.CrunchAvroParquetOutputFormat.getCompression(conf));
  }
  currentWriter.write(null, record.datum().value());
}
 
开发者ID:cloudera,项目名称:quince,代码行数:22,代码来源:AvroParquetPathPerKeyOutputFormat.java

示例4: map

import org.apache.avro.mapred.AvroWrapper; //导入依赖的package包/类
public void map(LongWritable key, Text value, OutputCollector<AvroWrapper, NullWritable> oc, Reporter rprtr) throws IOException {
    String[] tokens = value.toString().split("\t");
    String cookie = tokens[0];
    String page = tokens[1];
    String date = tokens[2];
    String time = tokens[3];
    String formatedDate = date + ":" + time;
    Date timestamp = null;
    try {
        timestamp = dateFormatter.parse(formatedDate);
    } catch(ParseException ex) {
        //ignore records with invalid dates
        return;
    }
    String ip = tokens[4];
    
    weblogRecord.setCookie(cookie);
    weblogRecord.setDate(timestamp);
    weblogRecord.setIp(ip);
    weblogRecord.setPage(page);
    outputRecord.datum(weblogRecord);
    oc.collect(outputRecord, NullWritable.get());
}
 
开发者ID:willddy,项目名称:bigdata_pattern,代码行数:24,代码来源:WeblogMapper.java

示例5: setup

import org.apache.avro.mapred.AvroWrapper; //导入依赖的package包/类
@Override
protected void setup(Context context) throws IOException, InterruptedException {
  wrapper = new AvroWrapper<GenericRecord>();
  schema = AvroJob.getOutputSchema(context.getConfiguration());
  bigDecimalFormatString = context.getConfiguration().getBoolean(
      ImportJobBase.PROPERTY_BIGDECIMAL_FORMAT, ImportJobBase.PROPERTY_BIGDECIMAL_FORMAT_DEFAULT);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:8,代码来源:MergeAvroReducer.java

示例6: getRecordWriter

import org.apache.avro.mapred.AvroWrapper; //导入依赖的package包/类
@Override
public RecordWriter<AvroWrapper<T>, NullWritable> getRecordWriter(
  TaskAttemptContext context) throws IOException, InterruptedException {

  boolean isMapOnly = context.getNumReduceTasks() == 0;
  Schema schema =
    isMapOnly ? AvroJob.getMapOutputSchema(context.getConfiguration())
      : AvroJob.getOutputSchema(context.getConfiguration());

  final DataFileWriter<T> WRITER =
    new DataFileWriter<T>(new ReflectDatumWriter<T>());

  configureDataFileWriter(WRITER, context);

  Path path = getDefaultWorkFile(context, EXT);
  WRITER.create(schema,
    path.getFileSystem(context.getConfiguration()).create(path));

  return new RecordWriter<AvroWrapper<T>, NullWritable>() {
    @Override
    public void write(AvroWrapper<T> wrapper, NullWritable ignore)
      throws IOException {
      WRITER.append(wrapper.datum());
    }

    @Override
    public void close(TaskAttemptContext taskAttemptContext)
      throws IOException, InterruptedException {
      WRITER.close();
    }
  };
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:33,代码来源:AvroOutputFormat.java

示例7: createRecordReader

import org.apache.avro.mapred.AvroWrapper; //导入依赖的package包/类
@Override
public RecordReader<AvroWrapper<T>, NullWritable> createRecordReader(
    InputSplit split, TaskAttemptContext context) throws IOException,
    InterruptedException {
  context.setStatus(split.toString());
  return new AvroRecordReader<T>();
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:8,代码来源:AvroInputFormat.java

示例8: map

import org.apache.avro.mapred.AvroWrapper; //导入依赖的package包/类
public void map(LongWritable key,
                StockDbWritable value,
                OutputCollector<AvroWrapper<Stock>, NullWritable> output,
                Reporter reporter) throws IOException {
  output.collect(
      new AvroWrapper<Stock>(writableToAvro(value)),
      NullWritable.get());
}
 
开发者ID:Hanmourang,项目名称:hiped2,代码行数:9,代码来源:DBImportMapReduce.java

示例9: map

import org.apache.avro.mapred.AvroWrapper; //导入依赖的package包/类
public void map(AvroWrapper<Stock> key,
                NullWritable value,
                OutputCollector<Text, DoubleWritable> output,
                Reporter reporter) throws IOException {
  output.collect(new Text(key.datum().getSymbol().toString()),
      new DoubleWritable(key.datum().getOpen()));
}
 
开发者ID:Hanmourang,项目名称:hiped2,代码行数:8,代码来源:AvroMixedMapReduce.java

示例10: map

import org.apache.avro.mapred.AvroWrapper; //导入依赖的package包/类
public void map(AvroWrapper<GenericRecord> key,
                NullWritable value,
                OutputCollector<Text, Text> output,
                Reporter reporter) throws IOException {
  outKey.set(
    key.datum().get(SmallFilesWrite.FIELD_FILENAME).toString());
  outValue.set(DigestUtils.md5Hex(
        ((ByteBuffer) key.datum().get(SmallFilesWrite.FIELD_CONTENTS))
          .array()));

  output.collect(outKey, outValue);
}
 
开发者ID:Hanmourang,项目名称:hiped2,代码行数:13,代码来源:SmallFilesMapReduce.java

示例11: reduce

import org.apache.avro.mapred.AvroWrapper; //导入依赖的package包/类
@Override
public void reduce(NullWritable key, Iterator<BloomFilter> values,
                   OutputCollector<AvroWrapper<GenericRecord>,
                       NullWritable> output,
                   Reporter reporter) throws IOException {
  while (values.hasNext()) {
    BloomFilter bf = values.next();
    filter.or(bf);
    System.out.println(filter);
  }
  collector = output;
}
 
开发者ID:Hanmourang,项目名称:hiped2,代码行数:13,代码来源:BloomFilterCreator.java

示例12: close

import org.apache.avro.mapred.AvroWrapper; //导入依赖的package包/类
@Override
public void close() throws IOException {
  System.out.println(filter);
  if (collector != null) {
    collector.collect(
        new AvroWrapper<GenericRecord>(
            AvroBytesRecord.toGenericRecord(filter)),
        NullWritable.get());
  }
}
 
开发者ID:Hanmourang,项目名称:hiped2,代码行数:11,代码来源:BloomFilterCreator.java

示例13: next

import org.apache.avro.mapred.AvroWrapper; //导入依赖的package包/类
@Override
public boolean next(AvroWrapper<T> wrapper, NullWritable ignore)
    throws IOException {
  try {
    if (!records_.hasNext()) return false;
    wrapper.datum(records_.next());
    return true;
  } catch (RecordServiceException e) {
    throw new IOException("Could not get next record.", e);
  }
}
 
开发者ID:cloudera,项目名称:RecordServiceClient,代码行数:12,代码来源:AvroInputFormat.java

示例14: getRecordWriter

import org.apache.avro.mapred.AvroWrapper; //导入依赖的package包/类
@Override
public RecordWriter<AvroWrapper<Pair<Utf8, T>>, NullWritable> getRecordWriter(TaskAttemptContext taskAttemptContext)
    throws IOException, InterruptedException {
  Configuration conf = taskAttemptContext.getConfiguration();
  Path basePath = new Path(getOutputPath(taskAttemptContext), conf.get("mapreduce.output.basename", "part"));
  return new AvroParquetFilePerKeyRecordWriter<T>(basePath,
      getUniqueFile(taskAttemptContext, "part", ".parquet"), conf);
}
 
开发者ID:cloudera,项目名称:quince,代码行数:9,代码来源:AvroParquetPathPerKeyOutputFormat.java

示例15: write

import org.apache.avro.mapred.AvroWrapper; //导入依赖的package包/类
@Override
public void write(K2 k, V2 v) throws IOException {

    GenericRecord record = fromText(k.toString() + "\t" + v.toString(), schema);
    AvroWrapper<GenericRecord> wrapper = new AvroWrapper<GenericRecord>(record);
    writer.append(wrapper.datum());
}
 
开发者ID:whale2,项目名称:iow-hadoop-streaming,代码行数:8,代码来源:AvroAsTextOutputFormat.java


注:本文中的org.apache.avro.mapred.AvroWrapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。