use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestRowSeq method metricUID.
@Test
public void metricUID() throws Exception {
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 KeyValue kv = makekv(qual12, MockBase.concatByteArrays(val1, val2, ZERO));
final RowSeq rs = new RowSeq(tsdb);
rs.setRow(kv);
assertArrayEquals(new byte[] { 0, 0, 1 }, rs.metricUID());
}
use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestRowSeq method getTagUidsSalted.
@Test
public void getTagUidsSalted() throws Exception {
setupSalt();
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 KeyValue kv = makekv(qual12, MockBase.concatByteArrays(val1, val2, ZERO));
final RowSeq rs = new RowSeq(tsdb);
rs.setRow(kv);
final ByteMap<byte[]> uids = rs.getTagUids();
assertEquals(1, uids.size());
assertEquals(0, Bytes.memcmp(new byte[] { 0, 0, 1 }, uids.firstKey()));
assertEquals(0, Bytes.memcmp(new byte[] { 0, 0, 2 }, uids.firstEntry().getValue()));
}
use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestRowSeq method getTagUids.
@Test
public void getTagUids() throws Exception {
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 KeyValue kv = makekv(qual12, MockBase.concatByteArrays(val1, val2, ZERO));
final RowSeq rs = new RowSeq(tsdb);
rs.setRow(kv);
final ByteMap<byte[]> uids = rs.getTagUids();
assertEquals(1, uids.size());
assertArrayEquals(new byte[] { 0, 0, 1 }, uids.firstKey());
assertArrayEquals(new byte[] { 0, 0, 2 }, uids.firstEntry().getValue());
}
use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestRowSeq method getMs.
/** Helper that builds a KeyValue with millisecond timestamps */
private static KeyValue getMs(final boolean salted) {
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[] qual3 = { (byte) 0xF0, 0x00, 0x04, 0x07 };
final byte[] val3 = Bytes.fromLong(6L);
final byte[] qual123 = MockBase.concatByteArrays(qual1, qual2, qual3);
final KeyValue kv = makekv((salted ? SALTED_KEY : KEY), qual123, MockBase.concatByteArrays(val1, val2, val3, ZERO));
return kv;
}
use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestSpan method addRowMissMatchedMetric.
@Test(expected = IllegalArgumentException.class)
public void addRowMissMatchedMetric() {
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, 2, 0x50, (byte) 0xE2, 0x35, 0x10, 0, 0, 1, 0, 0, 2 };
span.addRow(new KeyValue(bad_key, FAMILY, qual12, MockBase.concatByteArrays(val1, val2, ZERO)));
}
Aggregations