org.apache.avro.mapreduce

## Class AvroKeyValueRecordReader<K,V>

- java.lang.Object
- - org.apache.hadoop.mapreduce.RecordReader<K,V>
  - - org.apache.avro.mapreduce.AvroRecordReaderBase<AvroKey<K>,AvroValue<V>,GenericRecord>
    - - org.apache.avro.mapreduce.AvroKeyValueRecordReader<K,V>

- Type Parameters:
    `K` - The type of the Avro key to read.
    `V` - The type of the Avro value to read.
  All Implemented Interfaces:
    Closeable, AutoCloseable

      public class AvroKeyValueRecordReader<K,V>
      extends AvroRecordReaderBase<AvroKey<K>,AvroValue<V>,GenericRecord>

  Reads Avro generic records from an Avro container file, where the records contain two fields: 'key' and 'value'.

  The contents of the 'key' field will be parsed into an AvroKey object. The contents of the 'value' field will be parsed into an AvroValue object.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AvroKeyValueRecordReader(Schema keyReaderSchema, Schema valueReaderSchema)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `AvroKey<K>` | `getCurrentKey()`
    `AvroValue<V>` | `getCurrentValue()`
    `boolean` | `nextKeyValue()`

    - ### Methods inherited from class org.apache.avro.mapreduce.AvroRecordReaderBase

      `close, createAvroFileReader, createSeekableInput, getCurrentRecord, getProgress, initialize`

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

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

- - ### Constructor Detail

    - #### AvroKeyValueRecordReader

          public AvroKeyValueRecordReader(Schema keyReaderSchema,
                                          Schema valueReaderSchema)

      Constructor.
      Parameters:
        `keyReaderSchema` - The reader schema for the key within the generic record.
        `valueReaderSchema` - The reader schema for the value within the generic record.

  - ### Method Detail

    - #### nextKeyValue

          public boolean nextKeyValue()
                               throws IOException,
                                      InterruptedException

      Overrides:
        `nextKeyValue` in class `AvroRecordReaderBase<AvroKey<K>,AvroValue<V>,GenericRecord>`
      Throws:
        `IOException`
        `InterruptedException`

    - #### getCurrentKey

          public AvroKey<K> getCurrentKey()
                                   throws IOException,
                                          InterruptedException

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

    - #### getCurrentValue

          public AvroValue<V> getCurrentValue()
                                       throws IOException,
                                              InterruptedException

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

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