Class CombineFileRecordReader<K,V>
java.lang.Object
org.apache.hadoop.mapreduce.RecordReader<K,V>
org.apache.hadoop.mapreduce.lib.input.CombineFileRecordReader<K,V>
- All Implemented Interfaces:
Closeable,AutoCloseable
A generic RecordReader that can hand out different recordReaders
for each chunk in a
CombineFileSplit.
A CombineFileSplit can combine data chunks from multiple files.
This class allows using different RecordReaders for processing
these data chunks from different files.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TaskAttemptContextprotected RecordReader<K,V> protected intprotected longprotected Constructor<? extends RecordReader<K,V>> protected CombineFileSplit -
Constructor Summary
ConstructorsConstructorDescriptionCombineFileRecordReader(CombineFileSplit split, TaskAttemptContext context, Class<? extends RecordReader<K, V>> rrClass) A generic RecordReader that can hand out different recordReaders for each chunk in the CombineFileSplit. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the record reader.Get the current keyGet the current value.floatreturn progress based on the amount of data processed so far.voidinitialize(InputSplit split, TaskAttemptContext context) Called once at initialization.protected booleanGet the record reader for the next chunk in this CombineFileSplit.booleanRead the next key, value pair.
-
Field Details
-
split
-
rrConstructor
-
context
-
idx
protected int idx -
progress
protected long progress -
curReader
-
-
Constructor Details
-
CombineFileRecordReader
public CombineFileRecordReader(CombineFileSplit split, TaskAttemptContext context, Class<? extends RecordReader<K, V>> rrClass) throws IOExceptionA generic RecordReader that can hand out different recordReaders for each chunk in the CombineFileSplit.- Throws:
IOException
-
-
Method Details
-
initialize
public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException Description copied from class:RecordReaderCalled once at initialization.- Specified by:
initializein classRecordReader<K,V> - Parameters:
split- the split that defines the range of records to readcontext- the information about the task- Throws:
IOExceptionInterruptedException
-
nextKeyValue
Description copied from class:RecordReaderRead the next key, value pair.- Specified by:
nextKeyValuein classRecordReader<K,V> - Returns:
- true if a key/value pair was read
- Throws:
IOExceptionInterruptedException
-
getCurrentKey
Description copied from class:RecordReaderGet the current key- Specified by:
getCurrentKeyin classRecordReader<K,V> - Returns:
- the current key or null if there is no current key
- Throws:
IOExceptionInterruptedException
-
getCurrentValue
Description copied from class:RecordReaderGet the current value.- Specified by:
getCurrentValuein classRecordReader<K,V> - Returns:
- the object that was read
- Throws:
IOExceptionInterruptedException
-
close
Description copied from class:RecordReaderClose the record reader.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classRecordReader<K,V> - Throws:
IOException
-
getProgress
return progress based on the amount of data processed so far.- Specified by:
getProgressin classRecordReader<K,V> - Returns:
- a number between 0.0 and 1.0 that is the fraction of the data read
- Throws:
IOExceptionInterruptedException
-
initNextRecordReader
Get the record reader for the next chunk in this CombineFileSplit.- Throws:
IOException
-