/** * Constructor. */ public AvroKeyOutputFormat() { this(new RecordWriterFactory()); }
/** {@inheritDoc} */ @Override public RecordReader<K, V> createRecordReader(InputSplit inputSplit, TaskAttemptContext context) throws IOException { return new AvroSequenceFileRecordReader(); }
/** * Creates a new record writer instance. * * @param writerSchema The writer schema for the records to write. * @param compressionCodec The compression type for the writer file. * @param outputStream The target output stream for the records. * @param syncInterval The sync interval for the writer file. */ protected RecordWriter<AvroKey<T>, NullWritable> create( Schema writerSchema, GenericData dataModel, CodecFactory compressionCodec, OutputStream outputStream, int syncInterval) throws IOException { return new AvroKeyRecordWriter<>(writerSchema, dataModel, compressionCodec, outputStream, syncInterval); } }
/** {@inheritDoc} */ @Override public RecordReader<AvroKey<T>, NullWritable> createRecordReader( InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { Schema readerSchema = AvroJob.getInputKeySchema(context.getConfiguration()); if (null == readerSchema) { LOG.warn("Reader schema was not set. Use AvroJob.setInputKeySchema() if desired."); LOG.info("Using a reader schema equal to the writer schema."); } return new AvroKeyRecordReader<>(readerSchema); } }
@Override protected void cleanup(Context context) throws IOException, InterruptedException { amos.close(); } }
/** * Write key and value to the namedOutput. * * Output path is a unique file generated for the namedOutput. * For example, {namedOutput}-(m|r)-{part-number} * * @param namedOutput the named output name * @param key the key * @param value the value */ @SuppressWarnings("unchecked") public void write(String namedOutput, Object key, Object value) throws IOException, InterruptedException { write(namedOutput, key, value, namedOutput); }
@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); } } }
/** * Sets the value of the 'count' field. * @param value The value of 'count'. * @return This builder. */ public org.apache.avro.mapreduce.TextStats.Builder setCount(int value) { validate(fields()[1], value); this.count = value; fieldSetFlags()[1] = true; return this; }
/** {@inheritDoc} */ @Override public boolean nextKeyValue() throws IOException, InterruptedException { boolean hasNext = super.nextKeyValue(); mCurrentRecord.datum(getCurrentRecord()); return hasNext; }
/** * Clears the value of the 'name' field. * @return This builder. */ public org.apache.avro.mapreduce.TextStats.Builder clearName() { name = null; fieldSetFlags()[0] = false; return this; }
/** * Creates a new TextStats RecordBuilder. * @return A new TextStats RecordBuilder */ public static org.apache.avro.mapreduce.TextStats.Builder newBuilder() { return new org.apache.avro.mapreduce.TextStats.Builder(); }
@Override protected void cleanup(Context context) throws IOException, InterruptedException { amos.close(); } }
/** * Sets the value of the 'name' field. * @param value The value of 'name'. * @return This builder. */ public org.apache.avro.mapreduce.TextStats.Builder setName(java.lang.CharSequence value) { validate(fields()[0], value); this.name = value; fieldSetFlags()[0] = true; return this; }
/** * Clears the value of the 'count' field. * @return This builder. */ public org.apache.avro.mapreduce.TextStats.Builder clearCount() { fieldSetFlags()[1] = false; return this; }
/** * Creates a new TextStats RecordBuilder by copying an existing TextStats instance. * @param other The existing instance to copy. * @return A new TextStats RecordBuilder */ public static org.apache.avro.mapreduce.TextStats.Builder newBuilder(org.apache.avro.mapreduce.TextStats other) { if (other == null) { return new org.apache.avro.mapreduce.TextStats.Builder(); } else { return new org.apache.avro.mapreduce.TextStats.Builder(other); } }
@Override protected void cleanup(Context context) throws IOException,InterruptedException { amos.close(); } }
/** * Checks whether the 'count' field has been set. * @return True if the 'count' field has been set, false otherwise. */ public boolean hasCount() { return fieldSetFlags()[1]; }
/** * Creates a new TextStats RecordBuilder by copying an existing Builder. * @param other The existing builder to copy. * @return A new TextStats RecordBuilder */ public static org.apache.avro.mapreduce.TextStats.Builder newBuilder(org.apache.avro.mapreduce.TextStats.Builder other) { if (other == null) { return new org.apache.avro.mapreduce.TextStats.Builder(); } else { return new org.apache.avro.mapreduce.TextStats.Builder(other); } }
@Override protected void cleanup(Context context) throws IOException,InterruptedException { amos.close(); } }
/** * Checks whether the 'name' field has been set. * @return True if the 'name' field has been set, false otherwise. */ public boolean hasName() { return fieldSetFlags()[0]; }