Skip to content

Commit

Permalink
Configure maximum number of rows that asynchbase reads. Setting to be…
Browse files Browse the repository at this point in the history
… provided as export HBASE_MAX_ROWS=nnn in src/tsdb.local
  • Loading branch information
anomalizer committed Mar 27, 2011
1 parent bc4d17e commit c01cf6b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/core/TsdbQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ final class TsdbQuery implements Query {
/** Minimum time interval (in seconds) wanted between each data point. */
private int sample_interval;

/** Number of hbase rows to scan in one pass */
private int max_row_scan;

/** Constructor. */
public TsdbQuery(final TSDB tsdb) {
this.tsdb = tsdb;
Expand Down Expand Up @@ -386,6 +389,7 @@ private Scanner getScanner() throws HBaseException {
createAndSetFilter(scanner);
}
scanner.setFamily(TSDB.FAMILY);
scanner.setMaxNumRows(getMaxHbaseRows());
return scanner;
}

Expand Down Expand Up @@ -578,6 +582,30 @@ public String toString() {
return buf.toString();
}

/**
* Return the number of rows asynchbase should scan in one call
*/
private int getMaxHbaseRows() {
if(max_row_scan == 0) {
String rows = System.getenv("HBASE_MAX_ROWS");
try {
if(rows != null) {
max_row_scan = Integer.parseInt(rows);
} else {
max_row_scan = 128;
}
} catch (NumberFormatException e) {
// Do nothing
}
if(max_row_scan <= 0) {
LOG.error(rows + " is not a legit value for HBASE_MAX_ROWS");
max_row_scan = 128;
}
LOG.info("HBASE_MAX_ROWS set to " + max_row_scan);
}
return max_row_scan;
}

/**
* Comparator that ignores timestamps in row keys.
*/
Expand Down

0 comments on commit c01cf6b

Please sign in to comment.