edu.yale.cs.hadoopdb.sms.connector
Class SMSRecordReader
java.lang.Object
edu.yale.cs.hadoopdb.connector.AbstractDBRecordReader
edu.yale.cs.hadoopdb.sms.connector.SMSRecordReader
- All Implemented Interfaces:
- org.apache.hadoop.mapred.RecordReader<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.Text>
public class SMSRecordReader
- extends AbstractDBRecordReader
- implements org.apache.hadoop.mapred.RecordReader<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.Text>
SMSRecordReaders extends AbstractDBRecordReader and specializes the
value class to Text (in contrast to DBRecordReader that allows
arbitrary value classes). Hive expects the value to be set of field values
delimited by a special character ParseSchema
.
Constructor Summary |
SMSRecordReader(SMSInputSplit split,
org.apache.hadoop.mapred.JobConf conf)
Each relation is associated with a SQL query and schema in
the job configuration. |
Method Summary |
org.apache.hadoop.io.Text |
createValue()
|
protected java.lang.String |
getSqlQuery()
Abstract method definition. |
boolean |
next(org.apache.hadoop.io.LongWritable key,
org.apache.hadoop.io.Text value)
Retrieves each row from the result set, serializes it
using ParseSchema and increments the number of rows
read in. |
private java.lang.String |
parseResults()
|
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
LOG
public static final org.apache.commons.logging.Log LOG
parser
private ParseSchema parser
split
private SMSInputSplit split
SMSRecordReader
public SMSRecordReader(SMSInputSplit split,
org.apache.hadoop.mapred.JobConf conf)
throws java.sql.SQLException
- Each relation is associated with a SQL query and schema in
the job configuration. This is retrieved and a
ParseSchema
object
is created to retrieve the required fields from the result set
and serialize them into a delimited string.
- Throws:
java.sql.SQLException
createValue
public org.apache.hadoop.io.Text createValue()
- Specified by:
createValue
in interface org.apache.hadoop.mapred.RecordReader<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.Text>
getSqlQuery
protected java.lang.String getSqlQuery()
- Description copied from class:
AbstractDBRecordReader
- Abstract method definition. All extensions need to provide a sql query necessary
for retrieving rows from the database.
- Specified by:
getSqlQuery
in class AbstractDBRecordReader
- Returns:
- String standard SQL query
next
public boolean next(org.apache.hadoop.io.LongWritable key,
org.apache.hadoop.io.Text value)
throws java.io.IOException
- Retrieves each row from the result set, serializes it
using
ParseSchema
and increments the number of rows
read in.
- Specified by:
next
in interface org.apache.hadoop.mapred.RecordReader<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.Text>
- Returns:
- false if no more rows exist.
- Throws:
java.io.IOException
parseResults
private java.lang.String parseResults()
throws java.sql.SQLException
- Throws:
java.sql.SQLException