RecordReader (Apache Hadoop Main 3.5.0 API)
Description: declaration: package: org.apache.hadoop.mapreduce, class: RecordReader

Package org.apache.hadoop.mapreduce

# Class RecordReader<KEYIN,VALUEIN>

java.lang.Object
org.apache.hadoop.mapreduce.RecordReader<KEYIN,VALUEIN>

Type Parameters:
  `KEYIN` -
  `VALUEIN` -

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

Direct Known Subclasses:
  `CombineFileRecordReader`, `CombineFileRecordReaderWrapper`, `ComposableRecordReader`, `DBRecordReader`, `KeyValueLineRecordReader`, `SequenceFileAsTextRecordReader`, `SequenceFileRecordReader`

@Public @Stable public abstract class RecordReader<KEYIN,VALUEIN> extends Object implements Closeable
The record reader breaks the data into key/value pairs for input to the `Mapper`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RecordReader()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract void`
  `close()`
  Close the record reader.
  `abstract KEYIN`
  `getCurrentKey()`
  Get the current key
  `abstract VALUEIN`
  `getCurrentValue()`
  Get the current value.
  `abstract float`
  `getProgress()`
  The current progress of the record reader through its data.
  `abstract void`
  `initialize(InputSplit split, TaskAttemptContext context)`
  Called once at initialization.
  `abstract boolean`
  `nextKeyValue()`
  Read the next key, value pair.

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

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

- ## Constructor Details

  - ### RecordReader

    public RecordReader()

- ## Method Details

  - ### initialize

    public abstract void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException
    Called once at initialization.
    Parameters:
      `split` - the split that defines the range of records to read
      `context` - the information about the task
    Throws:
      `IOException`
      `InterruptedException`

  - ### nextKeyValue

    public abstract boolean nextKeyValue() throws IOException, InterruptedException
    Read the next key, value pair.
    Returns:
      true if a key/value pair was read
    Throws:
      `IOException`
      `InterruptedException`

  - ### getCurrentKey

    public abstract KEYIN getCurrentKey() throws IOException, InterruptedException
    Get the current key
    Returns:
      the current key or null if there is no current key
    Throws:
      `IOException`
      `InterruptedException`

  - ### getCurrentValue

    public abstract VALUEIN getCurrentValue() throws IOException, InterruptedException
    Get the current value.
    Returns:
      the object that was read
    Throws:
      `IOException`
      `InterruptedException`

  - ### getProgress

    public abstract float getProgress() throws IOException, InterruptedException
    The current progress of the record reader through its data.
    Returns:
      a number between 0.0 and 1.0 that is the fraction of the data read
    Throws:
      `IOException`
      `InterruptedException`

  - ### close

    public abstract void close() throws IOException
    Close the record reader.
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Throws:
      `IOException`