@Override
protected RecordReader<LongWritable, GenericDBWritable> createDBRecordReader(
DBInputSplit split, Configuration conf) throws IOException {
DBConfiguration dbConf = getDBConf();
@SuppressWarnings("unchecked")
// Class<T> inputClass = (Class<T>) (dbConf.getInputClass());
String dbProductName = getDBProductName();
logger.debug("Creating db record reader for db product: "
+ dbProductName);
ArrayList params = null;
try {
if (conf.get(HIHOConf.QUERY_PARAMS) != null) {
logger.debug("creating stringifier in DBQueryInputFormat");
DefaultStringifier<ArrayList> stringifier = new DefaultStringifier<ArrayList>(
conf, ArrayList.class);
logger.debug("created stringifier");
params = stringifier
.fromString(conf.get(HIHOConf.QUERY_PARAMS));
logger.debug("created params");
}
// use database product name to determine appropriate record reader.
if (dbProductName.startsWith("MYSQL")) {
// use MySQL-specific db reader.
return new MySQLQueryRecordReader(split, conf, getConnection(),
dbConf, dbConf.getInputConditions(),
dbConf.getInputFieldNames(),
dbConf.getInputTableName(), params);
} else {
// Generic reader.
return new DBQueryRecordReader(split, conf, getConnection(),
dbConf, dbConf.getInputConditions(),
dbConf.getInputFieldNames(),
dbConf.getInputTableName(), dbProductName, params);
}
} catch (SQLException ex) {
throw new IOException(ex.getMessage());
}
}