seriesName.append(":");
seriesName.append(family);
seriesName.append(":");
seriesName.append(column);
Series series = new Series(seriesName.toString());
try {
HTableInterface table = pool.getTable(tableName);
Calendar c = Calendar.getInstance();
c.setTimeInMillis(startTime);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
String startRow = c.getTimeInMillis()+rkey;
Scan scan = new Scan();
scan.addColumn(family.getBytes(), column.getBytes());
scan.setStartRow(startRow.getBytes());
scan.setTimeRange(startTime, endTime);
scan.setMaxVersions();
if(filterByRowKey) {
RowFilter rf = new RowFilter(CompareOp.EQUAL, new
RegexStringComparator("[0-9]+-"+rkey+"$"));
scan.setFilter(rf);
}
ResultScanner results = table.getScanner(scan);
Iterator<Result> it = results.iterator();
// TODO: Apply discrete wavelet transformation to limit the output
// size to 1000 data points for graphing optimization. (i.e jwave)
while(it.hasNext()) {
Result result = it.next();
String temp = new String(result.getValue(family.getBytes(), column.getBytes()));
double value = Double.parseDouble(temp);
// TODO: Pig Store function does not honor HBase timestamp, hence need to parse rowKey for timestamp.
String buf = new String(result.getRow());
Long timestamp = Long.parseLong(buf.split("-")[0]);
// If Pig Store function can honor HBase timestamp, use the following line is better.
// series.add(result.getCellValue().getTimestamp(), value);
series.add(timestamp, value);
}
results.close();
table.close();
} catch(Exception e) {
log.error(ExceptionUtil.getStackTrace(e));