Search in sources :

Example 11 with KeyValue

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());
}
Also used : KeyValue(org.hbase.async.KeyValue) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 12 with KeyValue

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()));
}
Also used : KeyValue(org.hbase.async.KeyValue) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 13 with KeyValue

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());
}
Also used : KeyValue(org.hbase.async.KeyValue) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 14 with KeyValue

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;
}
Also used : KeyValue(org.hbase.async.KeyValue)

Example 15 with KeyValue

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)));
}
Also used : KeyValue(org.hbase.async.KeyValue) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

KeyValue (org.hbase.async.KeyValue)171 Test (org.junit.Test)127 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)121 ArrayList (java.util.ArrayList)101 Annotation (net.opentsdb.meta.Annotation)50 Callback (com.stumbleupon.async.Callback)30 GetRequest (org.hbase.async.GetRequest)21 Scanner (org.hbase.async.Scanner)19 Deferred (com.stumbleupon.async.Deferred)14 HBaseException (org.hbase.async.HBaseException)13 TSDB (net.opentsdb.core.TSDB)12 Matchers.anyString (org.mockito.Matchers.anyString)11 Config (net.opentsdb.utils.Config)10 UniqueIdType (net.opentsdb.uid.UniqueId.UniqueIdType)9 DeleteRequest (org.hbase.async.DeleteRequest)8 DeferredGroupException (com.stumbleupon.async.DeferredGroupException)7 Map (java.util.Map)7 HashMap (java.util.HashMap)6 PutRequest (org.hbase.async.PutRequest)6 List (java.util.List)5