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 -
Method Summary
Modifier and TypeMethodDescriptionabstract voidclose()Close the record reader.abstract KEYINGet the current keyabstract VALUEINGet the current value.abstract floatThe current progress of the record reader through its data.abstract voidinitialize(InputSplit split, TaskAttemptContext context) Called once at initialization.abstract booleanRead the next key, value pair.
-
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 readcontext- the information about the task- Throws:
IOExceptionInterruptedException
-
nextKeyValue
Read the next key, value pair.- Returns:
- true if a key/value pair was read
- Throws:
IOExceptionInterruptedException
-
getCurrentKey
Get the current key- Returns:
- the current key or null if there is no current key
- Throws:
IOExceptionInterruptedException
-
getCurrentValue
Get the current value.- Returns:
- the object that was read
- Throws:
IOExceptionInterruptedException
-
getProgress
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:
IOExceptionInterruptedException
-
close
Close the record reader.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-