org.apache.hadoop.mapred
Class FixedLengthRecordReader

java.lang.Object
  extended by org.apache.hadoop.mapred.FixedLengthRecordReader
All Implemented Interfaces:
RecordReader<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.BytesWritable>

@InterfaceAudience.Private
@InterfaceStability.Evolving
public class FixedLengthRecordReader
extends Object
implements RecordReader<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.BytesWritable>

A reader to read fixed length records from a split. Record offset is returned as key and the record as bytes is returned in value.


Constructor Summary
FixedLengthRecordReader(org.apache.hadoop.conf.Configuration job, FileSplit split, int recordLength)
           
 
Method Summary
 void close()
          Close this InputSplit to future operations.
 org.apache.hadoop.io.LongWritable createKey()
          Create an object of the appropriate type to be used as a key.
 org.apache.hadoop.io.BytesWritable createValue()
          Create an object of the appropriate type to be used as a value.
 long getPos()
          Returns the current position in the input.
 float getProgress()
          How much of the input has the RecordReader consumed i.e.
 boolean next(org.apache.hadoop.io.LongWritable key, org.apache.hadoop.io.BytesWritable value)
          Reads the next key/value pair from the input for processing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedLengthRecordReader

public FixedLengthRecordReader(org.apache.hadoop.conf.Configuration job,
                               FileSplit split,
                               int recordLength)
                        throws IOException
Throws:
IOException
Method Detail

createKey

public org.apache.hadoop.io.LongWritable 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<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.BytesWritable>
Returns:
a new key object.

createValue

public org.apache.hadoop.io.BytesWritable 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<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.BytesWritable>
Returns:
a new value object.

next

public boolean next(org.apache.hadoop.io.LongWritable key,
                    org.apache.hadoop.io.BytesWritable value)
             throws IOException
Description copied from interface: RecordReader
Reads the next key/value pair from the input for processing.

Specified by:
next in interface RecordReader<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.BytesWritable>
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<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.BytesWritable>
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<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.BytesWritable>
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<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.BytesWritable>
Throws:
IOException


Copyright © 2014 Apache Software Foundation. All Rights Reserved.