Class KeyValueLineRecordReader
java.lang.Object
org.apache.hadoop.mapreduce.RecordReader<Text,Text>
org.apache.hadoop.mapreduce.lib.input.KeyValueLineRecordReader
- All Implemented Interfaces:
Closeable,AutoCloseable
This class treats a line in the input as a key/value pair separated by a
separator character. The separator can be specified in config file
under the attribute name mapreduce.input.keyvaluelinerecordreader.key.value.separator. The default
separator is the tab character ('\t').
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the record reader.static intfindSeparator(byte[] utf, int start, int length, byte sep) Get the current keyGet the current value.floatThe current progress of the record reader through its data.voidinitialize(InputSplit genericSplit, TaskAttemptContext context) Called once at initialization.booleanRead key/value pair in a line.static voidsetKeyValue(Text key, Text value, byte[] line, int lineLen, int pos)
-
Field Details
-
KEY_VALUE_SEPARATOR
- See Also:
-
KEY_VALUE_SEPERATOR
Deprecated.- See Also:
-
-
Constructor Details
-
KeyValueLineRecordReader
- Throws:
IOException
-
-
Method Details
-
getKeyClass
-
initialize
Description copied from class:RecordReaderCalled once at initialization.- Specified by:
initializein classRecordReader<Text,Text> - Parameters:
genericSplit- the split that defines the range of records to readcontext- the information about the task- Throws:
IOException
-
findSeparator
public static int findSeparator(byte[] utf, int start, int length, byte sep) -
setKeyValue
-
nextKeyValue
Read key/value pair in a line.- Specified by:
nextKeyValuein classRecordReader<Text,Text> - Returns:
- true if a key/value pair was read
- Throws:
IOException
-
getCurrentKey
Description copied from class:RecordReaderGet the current key- Specified by:
getCurrentKeyin classRecordReader<Text,Text> - Returns:
- the current key or null if there is no current key
-
getCurrentValue
Description copied from class:RecordReaderGet the current value.- Specified by:
getCurrentValuein classRecordReader<Text,Text> - Returns:
- the object that was read
-
getProgress
Description copied from class:RecordReaderThe current progress of the record reader through its data.- Specified by:
getProgressin classRecordReader<Text,Text> - Returns:
- a number between 0.0 and 1.0 that is the fraction of the data read
- Throws:
IOException
-
close
Description copied from class:RecordReaderClose the record reader.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classRecordReader<Text,Text> - Throws:
IOException
-
KEY_VALUE_SEPARATOR