use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestCompactionQueue method oneCellRowMS.
@Test
public void oneCellRowMS() throws Exception {
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(1);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(0);
final byte[] qual = { (byte) 0xF0, 0x00, 0x00, 0x07 };
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());
// 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 overlappingDataPointsFix.
@Test
public void overlappingDataPointsFix() 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));
// Same data point (same time delta, 0), but encoded on 4 bytes, not 8.
final byte[] qual2 = { 0x00, 0x03 };
final byte[] val2 = Bytes.fromInt(4);
kvs.add(makekv(qual2, val2));
final KeyValue kv = compactionq.compact(kvs, annotations);
assertArrayEquals(qual2, kv.qualifier());
assertArrayEquals(val2, kv.value());
// We didn't have anything to write.
verify(tsdb, never()).put(anyBytes(), anyBytes(), anyBytes());
// We had to delete the first entry as it was older.
verify(tsdb, times(1)).delete(KEY, new byte[][] { qual1 });
}
use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestCompactionQueue method fullRowSeconds.
@Test
public void fullRowSeconds() throws Exception {
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(3600);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(0);
byte[] qualifiers = new byte[] {};
byte[] values = new byte[] {};
for (int i = 0; i < 3600; i++) {
final short qualifier = (short) (i << Const.FLAG_BITS | 0x07);
kvs.add(makekv(Bytes.fromShort(qualifier), Bytes.fromLong(i)));
qualifiers = MockBase.concatByteArrays(qualifiers, Bytes.fromShort(qualifier));
values = MockBase.concatByteArrays(values, Bytes.fromLong(i));
}
final KeyValue kv = compactionq.compact(kvs, annotations);
assertArrayEquals(MockBase.concatByteArrays(qualifiers), kv.qualifier());
assertArrayEquals(MockBase.concatByteArrays(values, ZERO), kv.value());
// We had one row to compact, so one put to do.
verify(tsdb, times(1)).put(KEY, qualifiers, MockBase.concatByteArrays(values, ZERO));
// And we had to delete individual cells.
verify(tsdb, times(1)).delete((byte[]) any(), (byte[][]) any());
}
use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestCompactionQueue method secondCompactMixedMS.
@Test
public void secondCompactMixedMS() throws Exception {
// In this test the row has already been compacted, and another data
// point was written in the mean time.
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(2);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(0);
// This is 2 values already compacted together.
final byte[] qual1 = { 0x00, 0x07 };
final byte[] val1 = Bytes.fromLong(4L);
final byte[] qual2 = { (byte) 0xF0, 0x0A, 0x41, 0x07 };
final byte[] val2 = Bytes.fromLong(5L);
final byte[] qual12 = MockBase.concatByteArrays(qual1, qual2);
kvs.add(makekv(qual12, MockBase.concatByteArrays(val1, val2, new byte[] { 1 })));
// This data point came late. Note that its time delta falls in between
// that of the two data points above.
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(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 the individual cell + pre-existing compacted cell.
verify(tsdb, times(1)).delete(eq(KEY), eqAnyOrder(new byte[][] { qual12, qual3 }));
}
use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestCompactionQueue method secondCompactWAnnotation.
@Test
public void secondCompactWAnnotation() throws Exception {
// In this test the row has already been compacted, and another data
// point was written in the mean time.
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(2);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(1);
kvs.add(makekv(note_qual, note));
// This is 2 values already compacted together.
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);
kvs.add(makekv(qual12, MockBase.concatByteArrays(val1, val2, ZERO)));
// This data point came late. Note that its time delta falls in between
// that of the two data points above.
final byte[] qual3 = { 0x00, 0x17 };
final byte[] val3 = Bytes.fromLong(6L);
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, ZERO), kv.value());
assertEquals(1, annotations.size());
// 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 individual cell + pre-existing compacted cell.
verify(tsdb, times(1)).delete(eq(KEY), eqAnyOrder(new byte[][] { qual12, qual3 }));
}
Aggregations