use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestCompactionQueue method weirdOverlappingCompactedCells.
@Test
public void weirdOverlappingCompactedCells() throws Exception {
// Here we have two partially compacted cell, but they contain different
// data points. Although a possible scenario, this is extremely unlikely,
// but we need to test that logic works in this case too.
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(5);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(0);
final byte[] qual1 = { 0x00, 0x07 };
final byte[] val1 = Bytes.fromLong(4L);
kvs.add(makekv(qual1, val1));
// Data points 1 + 2 compacted.
final byte[] qual2 = { 0x00, 0x27 };
final byte[] val2 = Bytes.fromLong(5L);
final byte[] qual12 = MockBase.concatByteArrays(qual1, qual2);
kvs.add(makekv(qual12, MockBase.concatByteArrays(val1, val2, ZERO)));
// This data point came late.
final byte[] qual3 = { 0x00, 0x17 };
final byte[] val3 = Bytes.fromLong(6L);
// Data points 1 + 3 compacted.
final byte[] qual13 = MockBase.concatByteArrays(qual1, qual3);
kvs.add(makekv(qual13, MockBase.concatByteArrays(val1, val3, ZERO)));
kvs.add(makekv(qual3, val3));
kvs.add(makekv(qual2, val2));
final KeyValue kv = compactionq.compact(kvs, annotations);
assertArrayEquals(MockBase.concatByteArrays(qual1, qual3, qual2), kv.qualifier());
assertArrayEquals(MockBase.concatByteArrays(val1, val3, val2, ZERO), kv.value());
// We had one row to compact, so one put to do.
verify(tsdb, times(1)).put(KEY, MockBase.concatByteArrays(qual1, qual3, qual2), MockBase.concatByteArrays(val1, val3, val2, ZERO));
// And we had to delete the 3 individual cells + 2 pre-existing
// compacted cells.
verify(tsdb, times(1)).delete(eq(KEY), eqAnyOrder(new byte[][] { qual1, qual12, qual13, qual3, qual2 }));
}
use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestCompactionQueue method twoCellAppend.
@Test
public void twoCellAppend() throws Exception {
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(1);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(0);
final byte[] qual = { 0x00, 0x07 };
final byte[] val = Bytes.fromLong(42L);
final byte[] qual2 = { 0x00, 0x17 };
final byte[] val2 = Bytes.fromLong(5L);
kvs.add(makekv(AppendDataPoints.APPEND_COLUMN_QUALIFIER, MockBase.concatByteArrays(qual, val, qual2, val2)));
final KeyValue kv = compactionq.compact(kvs, annotations);
assertArrayEquals(MockBase.concatByteArrays(qual, qual2), kv.qualifier());
assertArrayEquals(MockBase.concatByteArrays(val, val2, ZERO), kv.value());
// We had nothing to do so...
// ... verify there were no put.
verify(tsdb, never()).put(anyBytes(), anyBytes(), anyBytes());
// ... verify there were no delete.
verify(tsdb, never()).delete(anyBytes(), any(byte[][].class));
}
use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestCompactionQueue method msOutOfOrder.
@Test
public void msOutOfOrder() throws Exception {
// all rows with an ms qualifier will go through the compaction
// process and they'll be sorted
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(3);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(0);
final byte[] qual1 = { (byte) 0xF0, 0x00, 0x02, 0x07 };
final byte[] val1 = Bytes.fromLong(4L);
kvs.add(makekv(qual1, val1));
final byte[] qual2 = { (byte) 0xF0, 0x00, 0x00, 0x07 };
final byte[] val2 = Bytes.fromLong(5L);
kvs.add(makekv(qual2, val2));
final byte[] qual3 = { (byte) 0xF0, 0x00, 0x01, 0x07 };
final byte[] val3 = Bytes.fromLong(6L);
kvs.add(makekv(qual3, val3));
final KeyValue kv = compactionq.compact(kvs, annotations);
assertArrayEquals(MockBase.concatByteArrays(qual2, qual3, qual1), kv.qualifier());
assertArrayEquals(MockBase.concatByteArrays(val2, val3, val1, ZERO), kv.value());
// We had one row to compact, so one put to do.
verify(tsdb, times(1)).put(KEY, MockBase.concatByteArrays(qual2, qual3, qual1), MockBase.concatByteArrays(val2, val3, val1, ZERO));
// And we had to delete individual cells.
verify(tsdb, times(1)).delete(eq(KEY), eqAnyOrder(new byte[][] { qual1, qual2, qual3 }));
}
use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestCompactionQueue method tripleAppends.
@Test
public void tripleAppends() throws Exception {
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(1);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(0);
final byte[] qual = { 0x00, 0x07 };
final byte[] val = Bytes.fromLong(42L);
final byte[] qual2 = { 0x00, 0x17 };
final byte[] val2 = Bytes.fromLong(5L);
final byte[] qual3 = { 0x00, 0x27 };
final byte[] val3 = Bytes.fromLong(3L);
final byte[] qual4 = { 0x00, 0x37 };
final byte[] val4 = Bytes.fromLong(2L);
final byte[] qual5 = { 0x00, 0x47 };
final byte[] val5 = Bytes.fromLong(1L);
final byte[] qual6 = { 0x00, 0x57 };
final byte[] val6 = Bytes.fromLong(0L);
kvs.add(makekv(AppendDataPoints.APPEND_COLUMN_QUALIFIER, MockBase.concatByteArrays(qual, val, qual2, val2)));
kvs.add(makekv(AppendDataPoints.APPEND_COLUMN_QUALIFIER, MockBase.concatByteArrays(qual3, val3, qual4, val4)));
kvs.add(makekv(AppendDataPoints.APPEND_COLUMN_QUALIFIER, MockBase.concatByteArrays(qual5, val5, qual6, val6)));
final KeyValue kv = compactionq.compact(kvs, annotations);
assertArrayEquals(MockBase.concatByteArrays(qual, qual2, qual3, qual4, qual5, qual6), kv.qualifier());
assertArrayEquals(MockBase.concatByteArrays(val, val2, val3, val4, val5, val6, ZERO), kv.value());
// We had nothing to do so...
// ... verify there were no put.
verify(tsdb, never()).put(anyBytes(), anyBytes(), anyBytes());
// ... verify there were no delete.
verify(tsdb, never()).delete(anyBytes(), any(byte[][].class));
}
use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestCompactionQueue method doubleAppends.
@Test
public void doubleAppends() throws Exception {
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(1);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(0);
final byte[] qual = { 0x00, 0x07 };
final byte[] val = Bytes.fromLong(42L);
final byte[] qual2 = { 0x00, 0x17 };
final byte[] val2 = Bytes.fromLong(5L);
final byte[] qual3 = { 0x00, 0x27 };
final byte[] val3 = Bytes.fromLong(3L);
final byte[] qual4 = { 0x00, 0x37 };
final byte[] val4 = Bytes.fromLong(2L);
kvs.add(makekv(AppendDataPoints.APPEND_COLUMN_QUALIFIER, MockBase.concatByteArrays(qual, val, qual2, val2)));
kvs.add(makekv(AppendDataPoints.APPEND_COLUMN_QUALIFIER, MockBase.concatByteArrays(qual3, val3, qual4, val4)));
final KeyValue kv = compactionq.compact(kvs, annotations);
assertArrayEquals(MockBase.concatByteArrays(qual, qual2, qual3, qual4), kv.qualifier());
assertArrayEquals(MockBase.concatByteArrays(val, val2, val3, val4, ZERO), kv.value());
// We had nothing to do so...
// ... verify there were no put.
verify(tsdb, never()).put(anyBytes(), anyBytes(), anyBytes());
// ... verify there were no delete.
verify(tsdb, never()).delete(anyBytes(), any(byte[][].class));
}
Aggregations