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)
| 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 |
no test coverage detected