org.apache.hadoop.mapreduce.lib.input
Class FixedLengthRecordReader

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

@InterfaceAudience.Private
@InterfaceStability.Evolving
public class FixedLengthRecordReader
extends 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(int recordLength)
           
 
Method Summary
 void close()
          Close the record reader.
 org.apache.hadoop.io.LongWritable getCurrentKey()
          Get the current key
 org.apache.hadoop.io.BytesWritable getCurrentValue()
          Get the current value.
 long getPos()
           
 float getProgress()
          The current progress of the record reader through its data.
 void initialize(org.apache.hadoop.conf.Configuration job, long splitStart, long splitLength, org.apache.hadoop.fs.Path file)
           
 void initialize(InputSplit genericSplit, TaskAttemptContext context)
          Called once at initialization.
 boolean nextKeyValue()
          Read the next key, value pair.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedLengthRecordReader

public FixedLengthRecordReader(int recordLength)
Method Detail

initialize

public void initialize(InputSplit genericSplit,
                       TaskAttemptContext context)
                throws IOException
Description copied from class: RecordReader
Called once at initialization.

Specified by:
initialize in class RecordReader<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.BytesWritable>
Parameters:
genericSplit - the split that defines the range of records to read
context - the information about the task
Throws:
IOException

initialize

public void initialize(org.apache.hadoop.conf.Configuration job,
                       long splitStart,
                       long splitLength,
                       org.apache.hadoop.fs.Path file)
                throws IOException
Throws:
IOException

nextKeyValue

public boolean nextKeyValue()
                     throws IOException
Description copied from class: RecordReader
Read the next key, value pair.

Specified by:
nextKeyValue in class RecordReader<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.BytesWritable>
Returns:
true if a key/value pair was read
Throws:
IOException

getCurrentKey

public org.apache.hadoop.io.LongWritable getCurrentKey()
Description copied from class: RecordReader
Get the current key

Specified by:
getCurrentKey in class RecordReader<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.BytesWritable>
Returns:
the current key or null if there is no current key

getCurrentValue

public org.apache.hadoop.io.BytesWritable getCurrentValue()
Description copied from class: RecordReader
Get the current value.

Specified by:
getCurrentValue in class RecordReader<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.BytesWritable>
Returns:
the object that was read

getProgress

public float getProgress()
                  throws IOException
Description copied from class: RecordReader
The current progress of the record reader through its data.

Specified by:
getProgress in class RecordReader<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.BytesWritable>
Returns:
a number between 0.0 and 1.0 that is the fraction of the data read
Throws:
IOException

close

public void close()
           throws IOException
Description copied from class: RecordReader
Close the record reader.

Specified by:
close in interface Closeable
Specified by:
close in class RecordReader<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.BytesWritable>
Throws:
IOException

getPos

public long getPos()


Copyright © 2014 Apache Software Foundation. All Rights Reserved.