Search in sources :

Example 6 with RollupSpan

use of net.opentsdb.rollup.RollupSpan in project opentsdb by OpenTSDB.

the class TestRollupSpan method timestampMS.

@Test
public void timestampMS() throws Exception {
    final byte[] qual1 = { 0x73, 0x75, 0x6D, 0x3A, (byte) 0xF0, 0x00, 0x00, 0x07 };
    final byte[] val1 = Bytes.fromLong(4L);
    final byte[] qual2 = { 0x73, 0x75, 0x6D, 0x3A, (byte) 0xF0, 0x00, 0x02, 0x07 };
    final byte[] val2 = Bytes.fromLong(5L);
    final Span span = new RollupSpan(tsdb, rollup_query);
    span.addRow(new KeyValue(hour1, TSDB.FAMILY(), qual1, val1));
    span.addRow(new KeyValue(hour1, TSDB.FAMILY(), qual2, val2));
    span.addRow(new KeyValue(hour2, TSDB.FAMILY(), qual1, val1));
    span.addRow(new KeyValue(hour2, TSDB.FAMILY(), qual2, val2));
    span.addRow(new KeyValue(hour3, TSDB.FAMILY(), qual1, val1));
    span.addRow(new KeyValue(hour3, TSDB.FAMILY(), qual2, val2));
    assertEquals(6, span.size());
    assertEquals(1356998400000L, span.timestamp(0));
    assertEquals(1356998400000L, span.timestamp(1));
    assertEquals(1357002000000L, span.timestamp(2));
    assertEquals(1357002000000L, span.timestamp(3));
    assertEquals(1357005600000L, span.timestamp(4));
    assertEquals(1357005600000L, span.timestamp(5));
}
Also used : KeyValue(org.hbase.async.KeyValue) RollupSpan(net.opentsdb.rollup.RollupSpan) RollupSpan(net.opentsdb.rollup.RollupSpan) Test(org.junit.Test)

Example 7 with RollupSpan

use of net.opentsdb.rollup.RollupSpan in project opentsdb by OpenTSDB.

the class TestRollupSpan method addRow.

@Test
public void addRow() {
    final byte[] qual1 = { 0x73, 0x75, 0x6D, 0x3A, 0x00, 0x07 };
    final byte[] val1 = Bytes.fromLong(4L);
    final Span span = new RollupSpan(tsdb, rollup_query);
    span.addRow(new KeyValue(hour1, TSDB.FAMILY(), qual1, val1));
    assertEquals(1, span.size());
}
Also used : KeyValue(org.hbase.async.KeyValue) RollupSpan(net.opentsdb.rollup.RollupSpan) RollupSpan(net.opentsdb.rollup.RollupSpan) Test(org.junit.Test)

Example 8 with RollupSpan

use of net.opentsdb.rollup.RollupSpan in project opentsdb by OpenTSDB.

the class TestRollupSpan method timestampFullSeconds.

// @Test
public void timestampFullSeconds() throws Exception {
    // 6 = num of bytes ("sum) + num of bytes (":") + num of bytes in actual qual
    final byte[] agg = (aggr_sum.toString() + ROLLUP_QUAL_DELIM).getBytes(Const.ASCII_CHARSET);
    final byte[] qualifiers = new byte[agg.length + 2];
    System.arraycopy(agg, 0, qualifiers, 0, agg.length);
    final Span span = new RollupSpan(tsdb, rollup_query);
    for (int i = 0; i < 100; i++) {
        final short qualifier = (short) (i << Const.FLAG_BITS | 0x07);
        System.arraycopy(Bytes.fromShort(qualifier), 0, qualifiers, agg.length, 2);
        span.addRow(new KeyValue(hour1, TSDB.FAMILY(), qualifiers, Bytes.fromLong(i)));
        span.addRow(new KeyValue(hour2, TSDB.FAMILY(), qualifiers, Bytes.fromLong(i)));
        span.addRow(new KeyValue(hour3, TSDB.FAMILY(), qualifiers, Bytes.fromLong(i)));
    }
    assertEquals(3600 * 3, span.size());
}
Also used : KeyValue(org.hbase.async.KeyValue) RollupSpan(net.opentsdb.rollup.RollupSpan) RollupSpan(net.opentsdb.rollup.RollupSpan)

Aggregations

RollupSpan (net.opentsdb.rollup.RollupSpan)8 KeyValue (org.hbase.async.KeyValue)7 Test (org.junit.Test)5 Annotation (net.opentsdb.meta.Annotation)2