Search in sources :

Example 6 with KeyValue

use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.

the class TestRowSeq method timestampMixedNormalized.

@Test
public void timestampMixedNormalized() throws Exception {
    final byte[] qual1 = { 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 = makekv(KEY, qual12, MockBase.concatByteArrays(val1, val2, ZERO));
    final RowSeq rs = new RowSeq(tsdb);
    rs.setRow(kv);
    assertEquals(1356998400000L, rs.timestamp(0));
    assertEquals(1356998400008L, rs.timestamp(1));
}
Also used : KeyValue(org.hbase.async.KeyValue) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 7 with KeyValue

use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.

the class TestRowSeq method iterateMs.

@Test
public void iterateMs() 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 = makekv(KEY, qual12, MockBase.concatByteArrays(val1, val2, ZERO));
    final RowSeq rs = new RowSeq(tsdb);
    rs.setRow(kv);
    final SeekableView it = rs.iterator();
    DataPoint dp = it.next();
    assertEquals(1356998400000L, dp.timestamp());
    assertEquals(4, dp.longValue());
    dp = it.next();
    assertEquals(1356998400008L, dp.timestamp());
    assertEquals(5, dp.longValue());
    assertFalse(it.hasNext());
}
Also used : KeyValue(org.hbase.async.KeyValue) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 8 with KeyValue

use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.

the class TestRowSeq method setRowAlreadySet.

@Test(expected = IllegalStateException.class)
public void setRowAlreadySet() 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(KEY, qual12, MockBase.concatByteArrays(val1, val2, ZERO));
    final RowSeq rs = new RowSeq(tsdb);
    rs.setRow(kv);
    assertEquals(2, rs.size());
    rs.setRow(kv);
}
Also used : KeyValue(org.hbase.async.KeyValue) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 9 with KeyValue

use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.

the class TestRowSeq method timestamp.

@Test
public void timestamp() 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(KEY, qual12, MockBase.concatByteArrays(val1, val2, ZERO));
    final RowSeq rs = new RowSeq(tsdb);
    rs.setRow(kv);
    assertEquals(1356998400000L, rs.timestamp(0));
    assertEquals(1356998402000L, rs.timestamp(1));
}
Also used : KeyValue(org.hbase.async.KeyValue) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 10 with KeyValue

use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.

the class TestRowSeq method timestampNormalizeMS.

@Test
public void timestampNormalizeMS() 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(KEY, qual12, MockBase.concatByteArrays(val1, val2, ZERO));
    final RowSeq rs = new RowSeq(tsdb);
    rs.setRow(kv);
    assertEquals(1356998400000L, rs.timestamp(0));
    assertEquals(1356998402000L, rs.timestamp(1));
}
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