edu.yale.cs.hadoopdb.connector
Class DBRecordReader<T extends DBWritable>
java.lang.Object
edu.yale.cs.hadoopdb.connector.AbstractDBRecordReader
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.
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 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 |
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
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
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