MCPcopy
hub / github.com/OpenTSDB/opentsdb / getQualifier

Method getQualifier

src/meta/Annotation.java:599–629  ·  view source on GitHub ↗

Calculates and returns the column qualifier. The qualifier is the offset of the #start_time from the row key's base time stamp in seconds with a prefix of #PREFIX. Thus if the offset is 0 and the prefix is 1 and the timestamp is in seconds, the qualifier would be [1, 0, 0]. Milliseco

(final long start_time)

Source from the content-addressed store, hash-verified

597 * @throws IllegalArgumentException if the start_time has not been set
598 */
599 private static byte[] getQualifier(final long start_time) {
600 if (start_time < 1) {
601 throw new IllegalArgumentException("The start timestamp has not been set");
602 }
603
604 final long base_time;
605 final byte[] qualifier;
606 long timestamp = start_time;
607 // downsample to seconds to save space AND prevent duplicates if the time
608 // is on a second boundary (e.g. if someone posts at 1328140800 with value A
609 // and 1328140800000L with value B)
610 if (timestamp % 1000 == 0) {
611 timestamp = timestamp / 1000;
612 }
613
614 if ((timestamp & Const.SECOND_MASK) != 0) {
615 // drop the ms timestamp to seconds to calculate the base timestamp
616 base_time = ((timestamp / 1000) -
617 ((timestamp / 1000) % Const.MAX_TIMESPAN));
618 qualifier = new byte[5];
619 final int offset = (int) (timestamp - (base_time * 1000));
620 System.arraycopy(Bytes.fromInt(offset), 0, qualifier, 1, 4);
621 } else {
622 base_time = (timestamp - (timestamp % Const.MAX_TIMESPAN));
623 qualifier = new byte[3];
624 final short offset = (short) (timestamp - base_time);
625 System.arraycopy(Bytes.fromShort(offset), 0, qualifier, 1, 2);
626 }
627 qualifier[0] = PREFIX;
628 return qualifier;
629 }
630
631 /**
632 * Returns a timestamp after parsing an annotation qualifier.

Callers 3

deleteMethod · 0.95
getAnnotationMethod · 0.95
callMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected