Package org.apache.avro.mapreduce
Class AvroKeyRecordWriter<T>
java.lang.Object
org.apache.hadoop.mapreduce.RecordWriter<AvroKey<T>,NullWritable>
org.apache.avro.mapreduce.AvroKeyRecordWriter<T>
- Type Parameters:
T
- The Java type of the Avro data to write.
- All Implemented Interfaces:
Syncable
public class AvroKeyRecordWriter<T>
extends RecordWriter<AvroKey<T>,NullWritable>
implements Syncable
Writes Avro records to an Avro container file output stream.
-
Constructor Summary
ConstructorDescriptionAvroKeyRecordWriter
(Schema writerSchema, GenericData dataModel, CodecFactory compressionCodec, OutputStream outputStream) Constructor.AvroKeyRecordWriter
(Schema writerSchema, GenericData dataModel, CodecFactory compressionCodec, OutputStream outputStream, int syncInterval) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close
(TaskAttemptContext context) long
sync()
Return the current position as a value that may be passed to DataFileReader.seek(long).void
write
(AvroKey<T> record, NullWritable ignore)
-
Constructor Details
-
AvroKeyRecordWriter
public AvroKeyRecordWriter(Schema writerSchema, GenericData dataModel, CodecFactory compressionCodec, OutputStream outputStream, int syncInterval) throws IOException Constructor.- Parameters:
writerSchema
- The writer schema for the records in the Avro container file.compressionCodec
- A compression codec factory for the Avro container file.outputStream
- The output stream to write the Avro container file to.syncInterval
- The sync interval for the Avro container file.- Throws:
IOException
- If the record writer cannot be opened.
-
AvroKeyRecordWriter
public AvroKeyRecordWriter(Schema writerSchema, GenericData dataModel, CodecFactory compressionCodec, OutputStream outputStream) throws IOException Constructor.- Parameters:
writerSchema
- The writer schema for the records in the Avro container file.compressionCodec
- A compression codec factory for the Avro container file.outputStream
- The output stream to write the Avro container file to.- Throws:
IOException
- If the record writer cannot be opened.
-
-
Method Details
-
write
- Specified by:
write
in classRecordWriter<AvroKey<T>,
NullWritable> - Throws:
IOException
-
close
- Specified by:
close
in classRecordWriter<AvroKey<T>,
NullWritable> - Throws:
IOException
-
sync
Return the current position as a value that may be passed to DataFileReader.seek(long). Forces the end of the current block, emitting a synchronization marker.- Specified by:
sync
in interfaceSyncable
- Throws:
IOException
- - if an error occurred while attempting to sync.
-