org.apache.trevni.avro.mapreduce

## Class AvroTrevniKeyValueRecordWriter<K,V>

- java.lang.Object
- - org.apache.hadoop.mapreduce.RecordWriter<K,V>
  - - org.apache.trevni.avro.mapreduce.AvroTrevniRecordWriterBase<AvroKey<K>,AvroValue<V>,GenericRecord>
    - - org.apache.trevni.avro.mapreduce.AvroTrevniKeyValueRecordWriter<K,V>

- Type Parameters:
    `K` - The type of key to write.
    `V` - The type of value to write.

      public class AvroTrevniKeyValueRecordWriter<K,V>
      extends AvroTrevniRecordWriterBase<AvroKey<K>,AvroValue<V>,GenericRecord>

  Writes key/value pairs to an Trevni container file.

  Each entry in the Trevni container file will be a generic record with two fields, named 'key' and 'value'. The input types may be basic Writable objects like Text or IntWritable, or they may be AvroWrapper subclasses (AvroKey or AvroValue). Writable objects will be converted to their corresponding Avro types when written to the generic record key/value pair.

- - ### Field Summary

    - ### Fields inherited from class org.apache.trevni.avro.mapreduce.AvroTrevniRecordWriterBase

      `EXT, meta, META_PREFIX, part, schema, writer`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AvroTrevniKeyValueRecordWriter(TaskAttemptContext context)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Schema` | `initSchema(TaskAttemptContext context)` Use the task context to construct a schema for writing
    `void` | `write(AvroKey<K> key, AvroValue<V> value)`

    - ### Methods inherited from class org.apache.trevni.avro.mapreduce.AvroTrevniRecordWriterBase

      `close, flush`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AvroTrevniKeyValueRecordWriter

          public AvroTrevniKeyValueRecordWriter(TaskAttemptContext context)
                                         throws IOException

      Constructor.
      Parameters:
        `context` - The TaskAttempContext to supply the writer with information form the job configuration
      Throws:
        `IOException`

  - ### Method Detail

    - #### write

          public void write(AvroKey<K> key,
                            AvroValue<V> value)
                     throws IOException,
                            InterruptedException

      Specified by:
        `write` in class `RecordWriter<AvroKey<K>,AvroValue<V>>`
      Throws:
        `IOException`
        `InterruptedException`

    - #### initSchema

          protected Schema initSchema(TaskAttemptContext context)

      Use the task context to construct a schema for writing
      Specified by:
        `initSchema` in class `AvroTrevniRecordWriterBase<AvroKey<K>,AvroValue<V>,GenericRecord>`

Copyright © 2009–2024 The Apache Software Foundation. All rights reserved.