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

Method getRowKey

test/core/BaseTsdbTest.java:398–417  ·  view source on GitHub ↗

Generates a proper key storage row key based on the metric, base time and tags. Adds salting when mocked properly. @param metric A non-null byte array representing the metric. @param base_time The base time for the row. @param tags A non-null list of tag key/value pairs as UIDs. @return A row key to

(final byte[] metric, final int base_time, 
      final byte[]... tags)

Source from the content-addressed store, hash-verified

396 * @return A row key to check mock storage for.
397 */
398 public static byte[] getRowKey(final byte[] metric, final int base_time,
399 final byte[]... tags) {
400 int tags_length = 0;
401 for (final byte[] tag : tags) {
402 tags_length += tag.length;
403 }
404 final byte[] key = new byte[Const.SALT_WIDTH() + metric.length +
405 Const.TIMESTAMP_BYTES + tags_length];
406
407 System.arraycopy(metric, 0, key, Const.SALT_WIDTH(), metric.length);
408 System.arraycopy(Bytes.fromInt(base_time), 0, key,
409 Const.SALT_WIDTH() + metric.length, Const.TIMESTAMP_BYTES);
410 int offset = Const.SALT_WIDTH() + metric.length + Const.TIMESTAMP_BYTES;
411 for (final byte[] tag : tags) {
412 System.arraycopy(tag, 0, key, offset, tag.length);
413 offset += tag.length;
414 }
415 RowKey.prefixKeyWithSalt(key);
416 return key;
417 }
418
419 /**
420 * Generates a proper key storage row key based on the metric, base time

Callers 15

beforeMethod · 0.95
beforeMethod · 0.95
beforeMethod · 0.95
addHistogramPointMethod · 0.45
beforeLocalMethod · 0.45
beforeMethod · 0.45
oldStringPrefixMethod · 0.45
runWithOnlyAnnotationMethod · 0.45
beforeLocalMethod · 0.45
beforeLocalMethod · 0.45
beforeLocalMethod · 0.45
beforeLocalMethod · 0.45

Calls 6

SALT_WIDTHMethod · 0.95
prefixKeyWithSaltMethod · 0.95
metrics_widthMethod · 0.95
tagk_widthMethod · 0.95
tagv_widthMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected