Search in sources :

Example 1 with KeyValue

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

the class TestRowSeq method addRowDiffBaseTime.

@Test(expected = IllegalDataException.class)
public void addRowDiffBaseTime() 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 RowSeq rs = new RowSeq(tsdb);
    rs.setRow(makekv(KEY, qual12, MockBase.concatByteArrays(val1, val2, ZERO)));
    assertEquals(2, rs.size());
    final byte[] qual3 = { 0x00, 0x37 };
    final byte[] val3 = Bytes.fromLong(6L);
    final byte[] qual4 = { 0x00, 0x47 };
    final byte[] val4 = Bytes.fromLong(7L);
    final byte[] qual34 = MockBase.concatByteArrays(qual3, qual4);
    final byte[] row2 = { 0, 0, 1, 0x50, (byte) 0xE2, 0x35, 0x10, 0, 0, 1, 0, 0, 2 };
    rs.addRow(new KeyValue(row2, FAMILY, qual34, MockBase.concatByteArrays(val3, val4, ZERO)));
}
Also used : KeyValue(org.hbase.async.KeyValue) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with KeyValue

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

the class TestRowSeq method addRowDiffBaseTimeSalt.

@Test(expected = IllegalDataException.class)
public void addRowDiffBaseTimeSalt() 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 RowSeq rs = new RowSeq(tsdb);
    rs.setRow(makekv(SALTED_KEY, qual12, MockBase.concatByteArrays(val1, val2, ZERO)));
    assertEquals(2, rs.size());
    final byte[] qual3 = { 0x00, 0x37 };
    final byte[] val3 = Bytes.fromLong(6L);
    final byte[] qual4 = { 0x00, 0x47 };
    final byte[] val4 = Bytes.fromLong(7L);
    final byte[] qual34 = MockBase.concatByteArrays(qual3, qual4);
    final byte[] row2 = { 1, 0, 0, 1, 0x50, (byte) 0xE2, 0x35, 0x10, 0, 0, 1, 0, 0, 2 };
    rs.addRow(new KeyValue(row2, FAMILY, qual34, MockBase.concatByteArrays(val3, val4, ZERO)));
}
Also used : KeyValue(org.hbase.async.KeyValue) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with KeyValue

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

the class TestRowSeq method timestampSalted.

@Test
public void timestampSalted() 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(SALTED_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 4 with KeyValue

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

the class TestRowSeq method timestampOutofBounds.

@Test(expected = IndexOutOfBoundsException.class)
public void timestampOutofBounds() 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);
    assertEquals(1356998400000L, rs.timestamp(0));
    assertEquals(1356998400008L, rs.timestamp(1));
    rs.timestamp(2);
}
Also used : KeyValue(org.hbase.async.KeyValue) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 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)

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