use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestSpan method timestampFullSeconds.
@Test
public void timestampFullSeconds() throws Exception {
final byte[] qualifiers = new byte[3600 * 2];
final byte[] values = new byte[3600 * 8];
for (int i = 0; i < 3600; i++) {
final short qualifier = (short) (i << Const.FLAG_BITS | 0x07);
System.arraycopy(Bytes.fromShort(qualifier), 0, qualifiers, i * 2, 2);
System.arraycopy(Bytes.fromLong(i), 0, values, i * 8, 8);
}
final Span span = new Span(tsdb);
span.addRow(new KeyValue(HOUR1, FAMILY, qualifiers, values));
span.addRow(new KeyValue(HOUR2, FAMILY, qualifiers, values));
span.addRow(new KeyValue(HOUR3, FAMILY, qualifiers, values));
assertEquals(3600 * 3, span.size());
}
use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestSpan method lastTimestampInRowMs.
@Test
public void lastTimestampInRowMs() throws Exception {
final byte[] qual1 = { (byte) 0xF0, 0x00, 0x00, 0x07 };
final byte[] val1 = Bytes.fromLong(4L);
final byte[] qual2 = { (byte) 0xF0, 0x00, 0x02, 0x07 };
final byte[] val2 = Bytes.fromLong(5L);
final byte[] qual12 = MockBase.concatByteArrays(qual1, qual2);
final KeyValue kv = new KeyValue(HOUR1, FAMILY, qual12, MockBase.concatByteArrays(val1, val2, ZERO));
assertEquals(1356998400008L, Span.lastTimestampInRow((short) 3, kv));
}
use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestSpan method addRowBadKeyLength.
@Test(expected = IllegalArgumentException.class)
public void addRowBadKeyLength() {
final byte[] qual1 = { 0x00, 0x07 };
final byte[] val1 = Bytes.fromLong(4L);
final byte[] qual2 = { 0x00, 0x27 };
final byte[] val2 = Bytes.fromLong(5L);
final byte[] qual12 = MockBase.concatByteArrays(qual1, qual2);
final Span span = new Span(tsdb);
span.addRow(new KeyValue(HOUR1, FAMILY, qual12, MockBase.concatByteArrays(val1, val2, ZERO)));
final byte[] bad_key = new byte[] { 0, 0, 1, 0x50, (byte) 0xE2, 0x43, 0x20, 0, 0, 1 };
span.addRow(new KeyValue(bad_key, FAMILY, qual12, MockBase.concatByteArrays(val1, val2, ZERO)));
}
use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestSpan method addRow.
@Test
public void addRow() {
final byte[] qual1 = { 0x00, 0x07 };
final byte[] val1 = Bytes.fromLong(4L);
final byte[] qual2 = { 0x00, 0x27 };
final byte[] val2 = Bytes.fromLong(5L);
final byte[] qual12 = MockBase.concatByteArrays(qual1, qual2);
final Span span = new Span(tsdb);
span.addRow(new KeyValue(HOUR1, FAMILY, qual12, MockBase.concatByteArrays(val1, val2, ZERO)));
assertEquals(2, span.size());
}
use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestSpan method addRowOutOfOrder.
@Test
public void addRowOutOfOrder() {
final byte[] qual1 = { 0x00, 0x07 };
final byte[] val1 = Bytes.fromLong(4L);
final byte[] qual2 = { 0x00, 0x27 };
final byte[] val2 = Bytes.fromLong(5L);
final byte[] qual12 = MockBase.concatByteArrays(qual1, qual2);
final Span span = new Span(tsdb);
span.addRow(new KeyValue(HOUR2, FAMILY, qual12, MockBase.concatByteArrays(val1, val2, ZERO)));
span.addRow(new KeyValue(HOUR1, FAMILY, qual12, MockBase.concatByteArrays(val1, val2, ZERO)));
assertEquals(4, span.size());
assertEquals(1356998400000L, span.timestamp(0));
assertEquals(4, span.longValue(0));
assertEquals(1356998402000L, span.timestamp(1));
assertEquals(5, span.longValue(1));
assertEquals(1357002000000L, span.timestamp(2));
assertEquals(4, span.longValue(2));
assertEquals(1357002002000L, span.timestamp(3));
assertEquals(5, span.longValue(3));
}
Aggregations