org.apache.hadoop.mapred
Class KeyValueLineRecordReader

java.lang.Object
  extended by org.apache.hadoop.mapred.KeyValueLineRecordReader
All Implemented Interfaces:
RecordReader<Text,Text>

public class KeyValueLineRecordReader
extends Object
implements RecordReader<Text,Text>

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 key.value.separator.in.input.line. The default separator is the tab character ('\t').


Constructor Summary
KeyValueLineRecordReader(Configuration job, FileSplit split)
           
 
Method Summary
 void close()
          Close this InputSplit to future operations.
 Text createKey()
          Create an object of the appropriate type to be used as a key.
 Text createValue()
          Create an object of the appropriate type to be used as a value.
static int findSeparator(byte[] utf, int start, int length, byte sep)
           
 Class getKeyClass()
           
 long getPos()
          Returns the current position in the input.
 float getProgress()
          How much of the input has the RecordReader consumed i.e.
 boolean next(Text key, Text value)
          Read key/value pair in a line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyValueLineRecordReader

public KeyValueLineRecordReader(Configuration job,
                                FileSplit split)
                         throws IOException
Throws:
IOException
Method Detail

getKeyClass

public Class getKeyClass()

createKey

public Text createKey()
Description copied from interface: RecordReader
Create an object of the appropriate type to be used as a key.

Specified by:
createKey in interface RecordReader<Text,Text>
Returns:
a new key object.

createValue

public Text createValue()
Description copied from interface: RecordReader
Create an object of the appropriate type to be used as a value.

Specified by:
createValue in interface RecordReader<Text,Text>
Returns:
a new value object.

findSeparator

public static int findSeparator(byte[] utf,
                                int start,
                                int length,
                                byte sep)

next

public boolean next(Text key,
                    Text value)
             throws IOException
Read key/value pair in a line.

Specified by:
next in interface RecordReader<Text,Text>
Parameters:
key - the key to read data into
value - the value to read data into
Returns:
true iff a key/value was read, false if at EOF
Throws:
IOException

getProgress

public float getProgress()
                  throws IOException
Description copied from interface: RecordReader
How much of the input has the RecordReader consumed i.e. has been processed by?

Specified by:
getProgress in interface RecordReader<Text,Text>
Returns:
progress from 0.0 to 1.0.
Throws:
IOException

getPos

public long getPos()
            throws IOException
Description copied from interface: RecordReader
Returns the current position in the input.

Specified by:
getPos in interface RecordReader<Text,Text>
Returns:
the current position in the input.
Throws:
IOException

close

public void close()
           throws IOException
Description copied from interface: RecordReader
Close this InputSplit to future operations.

Specified by:
close in interface RecordReader<Text,Text>
Throws:
IOException


Copyright © 2009 The Apache Software Foundation