edu.yale.cs.hadoopdb.connector
Class DBRecordReader<T extends DBWritable>

java.lang.Object
  extended by edu.yale.cs.hadoopdb.connector.AbstractDBRecordReader
      extended by edu.yale.cs.hadoopdb.connector.DBRecordReader<T>
Type Parameters:
T -
All Implemented Interfaces:
org.apache.hadoop.mapred.RecordReader<org.apache.hadoop.io.LongWritable,T>

public class DBRecordReader<T extends DBWritable>
extends AbstractDBRecordReader
implements org.apache.hadoop.mapred.RecordReader<org.apache.hadoop.io.LongWritable,T>

Implementation of DBRecordReader for HadoopDB jobs. Records returned include a key (meaningless long) and an value object. All jobs need to specify this class.


Field Summary
private  org.apache.hadoop.mapred.JobConf conf
           
private  DBConfiguration dbConf
           
static org.apache.commons.logging.Log LOG
           
private  java.lang.Class<T> valueClass
           
 
Fields inherited from class edu.yale.cs.hadoopdb.connector.AbstractDBRecordReader
connection, connTime, MAX_CONNECTION_TRIALS, pos, queryTime, results, startTime, statement
 
Constructor Summary
DBRecordReader(DBConfiguration dbConf, DBInputSplit split, org.apache.hadoop.mapred.JobConf conf)
          Constructor requires DBConfiguration to set up DB connection.
 
Method Summary
 T createValue()
           
protected  java.lang.String getSqlQuery()
          Provides a SQL query
 boolean next(org.apache.hadoop.io.LongWritable key, T value)
          Reads the next record from the result set and passes the result set to the value Object to extract necessary fields.
 
Methods inherited from class edu.yale.cs.hadoopdb.connector.AbstractDBRecordReader
close, createKey, getConnection, getPos, getProgress, setupDB
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.mapred.RecordReader
close, createKey, getPos, getProgress
 

Field Detail

conf

private org.apache.hadoop.mapred.JobConf conf

dbConf

private DBConfiguration dbConf

LOG

public static final org.apache.commons.logging.Log LOG

valueClass

private java.lang.Class<T extends DBWritable> valueClass
Constructor Detail

DBRecordReader

public DBRecordReader(DBConfiguration dbConf,
                      DBInputSplit split,
                      org.apache.hadoop.mapred.JobConf conf)
               throws java.sql.SQLException
Constructor requires DBConfiguration to set up DB connection.

Throws:
java.sql.SQLException
Method Detail

createValue

public T createValue()
Specified by:
createValue in interface org.apache.hadoop.mapred.RecordReader<org.apache.hadoop.io.LongWritable,T extends DBWritable>

getSqlQuery

protected java.lang.String getSqlQuery()
Provides a SQL query

Specified by:
getSqlQuery in class AbstractDBRecordReader
Returns:
String standard SQL query

next

public boolean next(org.apache.hadoop.io.LongWritable key,
                    T value)
             throws java.io.IOException
Reads the next record from the result set and passes the result set to the value Object to extract necessary fields. Increments the number of rows read in.

Specified by:
next in interface org.apache.hadoop.mapred.RecordReader<org.apache.hadoop.io.LongWritable,T extends DBWritable>
Returns:
false if no more rows exist.
Throws:
java.io.IOException