org.apache.hadoop.mapred.lib.db
Class DBInputFormat.DBRecordReader

java.lang.Object
  extended by org.apache.hadoop.mapred.lib.db.DBInputFormat.DBRecordReader
All Implemented Interfaces:
RecordReader<LongWritable,T>
Enclosing class:
DBInputFormat<T extends DBWritable>

protected class DBInputFormat.DBRecordReader
extends Object
implements RecordReader<LongWritable,T>

A RecordReader that reads records from a SQL table. Emits LongWritables containing the record number as key and DBWritables as value.


Constructor Summary
protected DBInputFormat.DBRecordReader(DBInputFormat.DBInputSplit split, Class<T> inputClass, JobConf job)
           
 
Method Summary
 void close()
          Close this InputSplit to future operations.
 LongWritable createKey()
          Create an object of the appropriate type to be used as a key.
 T 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.
protected  String getSelectQuery()
          Returns the query for selecting the records, subclasses can override this for custom behaviour.
 boolean next(LongWritable key, T 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

DBInputFormat.DBRecordReader

protected DBInputFormat.DBRecordReader(DBInputFormat.DBInputSplit split,
                                       Class<T> inputClass,
                                       JobConf job)
                                throws SQLException
Parameters:
split - The InputSplit to read data for
Throws:
SQLException
Method Detail

getSelectQuery

protected String getSelectQuery()
Returns the query for selecting the records, subclasses can override this for custom behaviour.


close

public void close()
           throws IOException
Close this InputSplit to future operations.

Specified by:
close in interface RecordReader<LongWritable,T extends DBWritable>
Throws:
IOException

createKey

public LongWritable createKey()
Create an object of the appropriate type to be used as a key.

Specified by:
createKey in interface RecordReader<LongWritable,T extends DBWritable>
Returns:
a new key object.

createValue

public T createValue()
Create an object of the appropriate type to be used as a value.

Specified by:
createValue in interface RecordReader<LongWritable,T extends DBWritable>
Returns:
a new value object.

getPos

public long getPos()
            throws IOException
Returns the current position in the input.

Specified by:
getPos in interface RecordReader<LongWritable,T extends DBWritable>
Returns:
the current position in the input.
Throws:
IOException

getProgress

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

Specified by:
getProgress in interface RecordReader<LongWritable,T extends DBWritable>
Returns:
progress from 0.0 to 1.0.
Throws:
IOException

next

public boolean next(LongWritable key,
                    T value)
             throws IOException
Reads the next key/value pair from the input for processing.

Specified by:
next in interface RecordReader<LongWritable,T extends DBWritable>
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


Copyright © 2009 The Apache Software Foundation