@Override protected void reduce(Text line, Iterable<IntWritable> counts, Context context) throws IOException, InterruptedException { TextStats record = new TextStats(); record.count = 0; for (IntWritable count : counts) { record.count += count.get(); } record.name = line.toString(); mStats.datum(record); context.write(mStats, NullWritable.get()); } }
@Override protected void reduce(Text line, Iterable<IntWritable> counts, Context context) throws IOException, InterruptedException { TextStats record = new TextStats(); record.count = 0; for (IntWritable count : counts) { record.count += count.get(); } record.name = line.toString(); mStats.datum(record); context.write(mStats, NullWritable.get()); amos.write("myavro3", mStats, NullWritable.get()); }
@Override protected void reduce(Text line, Iterable<IntWritable> counts, Context context) throws IOException, InterruptedException { TextStats record = new TextStats(); record.count = 0; for (IntWritable count : counts) { record.count += count.get(); } record.name = line.toString(); mStats.datum(record); context.write(mStats, NullWritable.get()); amos.sync("myavro3","myavro3"); amos.write("myavro3",mStats,NullWritable.get()); } @Override
@Override @SuppressWarnings("unchecked") public TextStats build() { try { TextStats record = new TextStats(); record.name = fieldSetFlags()[0] ? this.name : (java.lang.CharSequence) defaultValue(fields()[0]); record.count = fieldSetFlags()[1] ? this.count : (java.lang.Integer) defaultValue(fields()[1]); return record; } catch (org.apache.avro.AvroMissingFieldException e) { throw e; } catch (java.lang.Exception e) { throw new org.apache.avro.AvroRuntimeException(e); } } }
= new AvroKeyValueRecordWriter<>(keyConverter, valueConverter, new ReflectData(), compressionCodec, outputStream); TextStats appleStats = new TextStats(); appleStats.name = "apple"; long pointOne = writer.sync(); writer.write(new Text("apple"), new AvroValue<>(appleStats)); TextStats bananaStats = new TextStats(); bananaStats.name = "banana"; long pointTwo = writer.sync();
= new AvroKeyValueRecordWriter<>(keyConverter, valueConverter, new ReflectData(), compressionCodec, outputStream); TextStats appleStats = new TextStats(); appleStats.name = "apple"; writer.write(new Text("apple"), new AvroValue<>(appleStats)); TextStats bananaStats = new TextStats(); bananaStats.name = "banana"; writer.write(new Text("banana"), new AvroValue<>(bananaStats));