use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestCompactionQueue method secondCompactOverwriteFix.
@Test
public void secondCompactOverwriteFix() throws Exception {
// In this test the row has already been compacted, and a new value for an
// old 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 = { 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 matches the first point with
// a different value, so it should replace the earlier one.
final byte[] qual3 = { 0x00, 0x07 };
final byte[] val3 = Bytes.fromLong(6L);
kvs.add(makekv(qual3, val3));
final KeyValue kv = compactionq.compact(kvs, annotations);
assertArrayEquals(MockBase.concatByteArrays(qual3, qual2), kv.qualifier());
assertArrayEquals(MockBase.concatByteArrays(val3, val2, new byte[] { 0 }), kv.value());
// We had one row to compact, so one put to do.
verify(tsdb, times(1)).put(KEY, MockBase.concatByteArrays(qual3, qual2), MockBase.concatByteArrays(val3, val2, new byte[] { 0 }));
// And we had to delete the individual cell, but we overwrite the pre-existing compacted cell
// rather than delete it.
verify(tsdb, times(1)).delete(eq(KEY), eqAnyOrder(new byte[][] { qual3 }));
}
use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestCompactionQueue method appendsDuplicateCompacted.
@Test
public void appendsDuplicateCompacted() 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)));
kvs.add(makekv(MockBase.concatByteArrays(qual, qual2), MockBase.concatByteArrays(val, val2, ZERO)));
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 org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestCompactionQueue method emptyRow.
@Test
public void emptyRow() throws Exception {
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(0);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(0);
final KeyValue kv = compactionq.compact(kvs, annotations);
assertNull(kv);
// 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 org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestCompactionQueue method oneCellAppendWAnnotiation.
@Test
public void oneCellAppendWAnnotiation() 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);
kvs.add(makekv(AppendDataPoints.APPEND_COLUMN_QUALIFIER, MockBase.concatByteArrays(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));
}
use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestCompactionQueue method oneCellAppend.
@Test
public void oneCellAppend() 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);
kvs.add(makekv(AppendDataPoints.APPEND_COLUMN_QUALIFIER, MockBase.concatByteArrays(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));
}
Aggregations