use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestCompactionQueue method twoCellAppendWAnnotations.
@Test
public void twoCellAppendWAnnotations() throws Exception {
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(1);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(1);
kvs.add(makekv(note_qual, note));
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());
assertEquals(1, annotations.size());
// 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 secondAndMs.
@Test
public void secondAndMs() throws Exception {
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(2);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(0);
final byte[] qual1 = { 0x00, 0x07 };
final byte[] val1 = Bytes.fromLong(4L);
kvs.add(makekv(qual1, val1));
final byte[] qual2 = { (byte) 0xF0, 0x00, 0x01, 0x07 };
final byte[] val2 = Bytes.fromLong(5L);
kvs.add(makekv(qual2, val2));
final KeyValue kv = compactionq.compact(kvs, annotations);
assertArrayEquals(MockBase.concatByteArrays(qual1, qual2), kv.qualifier());
assertArrayEquals(MockBase.concatByteArrays(val1, val2, new byte[] { 1 }), kv.value());
// We had one row to compact, so one put to do.
verify(tsdb, times(1)).put(KEY, MockBase.concatByteArrays(qual1, qual2), MockBase.concatByteArrays(val1, val2, new byte[] { 1 }));
// And we had to delete individual cells.
verify(tsdb, times(1)).delete(eq(KEY), eqAnyOrder(new byte[][] { qual1, qual2 }));
}
use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestCompactionQueue method sortMsAndS.
@Test
public void sortMsAndS() throws Exception {
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(2);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(0);
final byte[] qual1 = { 0x00, 0x07 };
final byte[] val1 = Bytes.fromLong(4L);
kvs.add(makekv(qual1, val1));
final byte[] qual2 = { (byte) 0xF0, 0x00, 0x02, 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(5L);
kvs.add(makekv(qual3, val3));
final KeyValue kv = compactionq.compact(kvs, annotations);
assertArrayEquals(MockBase.concatByteArrays(qual1, qual3, qual2), kv.qualifier());
assertArrayEquals(MockBase.concatByteArrays(val1, val3, val2, new byte[] { 1 }), 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, new byte[] { 1 }));
// 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 annotationsOnly.
@Test
public void annotationsOnly() throws Exception {
// Two annotations in a row only (the value of the second isn't parsed at
// this time)
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(2);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(2);
kvs.add(makekv(note_qual, note));
kvs.add(makekv(new byte[] { 1, 0, 1 }, note));
final KeyValue kv = compactionq.compact(kvs, annotations);
assertNull(kv);
assertEquals(2, annotations.size());
// ... 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 oneCellRowWAnnotationMS.
@Test
public void oneCellRowWAnnotationMS() throws Exception {
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(1);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(1);
kvs.add(makekv(new byte[] { 1, 0, 0, 0, 0 }, note));
final byte[] qual = { 0x00, 0x07 };
final byte[] val = Bytes.fromLong(42L);
kvs.add(makekv(qual, val));
final KeyValue kv = compactionq.compact(kvs, annotations);
assertArrayEquals(qual, kv.qualifier());
assertArrayEquals(val, kv.value());
assertEquals(1, annotations.size());
// 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