MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / getMetricScanner

Method getMetricScanner

src/query/QueryUtil.java:558–584  ·  view source on GitHub ↗

Compiles an HBase scanner against the main data table @param tsdb The TSDB with a configured HBaseClient @param salt_bucket An optional salt bucket ID for salting the start/stop keys. @param metric The metric to scan for @param start The start time stamp in seconds @param stop The stop timestamp in

(final TSDB tsdb, final int salt_bucket, 
      final byte[] metric, final int start, final int stop, 
      final byte[] table, final byte[] family)

Source from the content-addressed store, hash-verified

556 * @return A scanner ready for processing.
557 */
558 public static Scanner getMetricScanner(final TSDB tsdb, final int salt_bucket,
559 final byte[] metric, final int start, final int stop,
560 final byte[] table, final byte[] family) {
561 final short metric_width = TSDB.metrics_width();
562 final int metric_salt_width = metric_width + Const.SALT_WIDTH();
563 final byte[] start_row = new byte[metric_salt_width + Const.TIMESTAMP_BYTES];
564 final byte[] end_row = new byte[metric_salt_width + Const.TIMESTAMP_BYTES];
565
566 if (Const.SALT_WIDTH() > 0) {
567 final byte[] salt = RowKey.getSaltBytes(salt_bucket);
568 System.arraycopy(salt, 0, start_row, 0, Const.SALT_WIDTH());
569 System.arraycopy(salt, 0, end_row, 0, Const.SALT_WIDTH());
570 }
571
572 Bytes.setInt(start_row, start, metric_salt_width);
573 Bytes.setInt(end_row, stop, metric_salt_width);
574
575 System.arraycopy(metric, 0, start_row, Const.SALT_WIDTH(), metric_width);
576 System.arraycopy(metric, 0, end_row, Const.SALT_WIDTH(), metric_width);
577
578 final Scanner scanner = tsdb.getClient().newScanner(table);
579 scanner.setMaxNumRows(tsdb.getConfig().scanner_maxNumRows());
580 scanner.setStartKey(start_row);
581 scanner.setStopKey(end_row);
582 scanner.setFamily(family);
583 return scanner;
584 }
585
586 /**
587 * Appends the given UID to the given regular expression buffer

Callers 1

getScannerMethod · 0.95

Calls 7

metrics_widthMethod · 0.95
SALT_WIDTHMethod · 0.95
getSaltBytesMethod · 0.95
scanner_maxNumRowsMethod · 0.80
setFamilyMethod · 0.80
getClientMethod · 0.45
getConfigMethod · 0.45

Tested by

no test coverage detected