use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestCompactionQueue method doubleFailedCompactNoop.
@Test
public void doubleFailedCompactNoop() throws Exception {
// In this test the row has already been compacted once, but we didn't
// clean up the individual data points. Then another data point was
// written, another compaction ran, but once again didn't delete the
// individual data points. So the rows contains 2 compacted cells and
// several individual cells.
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);
final byte[] qual2 = { 0x00, 0x27 };
final byte[] val2 = Bytes.fromLong(5L);
// Data points 1 + 2 compacted.
final byte[] qual12 = MockBase.concatByteArrays(qual1, qual2);
// This data point came late.
final byte[] qual3 = { 0x00, 0x17 };
final byte[] val3 = Bytes.fromLong(6L);
// Data points 1 + 3 + 2 compacted.
final byte[] qual132 = MockBase.concatByteArrays(qual1, qual3, qual2);
kvs.add(makekv(qual1, val1));
kvs.add(makekv(qual132, MockBase.concatByteArrays(val1, val3, val2, ZERO)));
kvs.add(makekv(qual12, MockBase.concatByteArrays(val1, val2, ZERO)));
kvs.add(makekv(qual3, val3));
kvs.add(makekv(qual2, val2));
final KeyValue kv = compactionq.compact(kvs, annotations);
assertArrayEquals(qual132, kv.qualifier());
assertArrayEquals(MockBase.concatByteArrays(val1, val3, val2, ZERO), kv.value());
// We didn't have anything to write, the last cell is already the correct
// compacted version of the row.
verify(tsdb, never()).put(anyBytes(), anyBytes(), anyBytes());
// And we had to delete the 3 individual cells + the first pre-existing
// compacted cell.
verify(tsdb, times(1)).delete(eq(KEY), eqAnyOrder(new byte[][] { qual1, qual12, qual3, qual2 }));
}
use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestCompactionQueue method appendsAndInterspersedPuts.
@Test
public void appendsAndInterspersedPuts() 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(qual, val));
kvs.add(makekv(qual3, val3));
kvs.add(makekv(AppendDataPoints.APPEND_COLUMN_QUALIFIER, MockBase.concatByteArrays(qual2, val2, 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));
}
use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestCompactionQueue method tripleCompactedSecondsAndMs.
@Test
public void tripleCompactedSecondsAndMs() throws Exception {
// Here we have a row with #kvs > scanner.maxNumKeyValues and the result
// that was compacted during a query. The result is a bunch of compacted
// columns. We want to make sure that we can merge them nicely
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(5);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(0);
// start one off w ms
final byte[] qual1 = { (byte) 0xF0, 0x00, 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);
// 2nd compaction
final byte[] qual3 = { 0x00, 0x37 };
final byte[] val3 = Bytes.fromLong(6L);
final byte[] qual4 = { (byte) 0xF0, 0x04, 0x65, 0x07 };
final byte[] val4 = Bytes.fromLong(7L);
final byte[] qual34 = MockBase.concatByteArrays(qual3, qual4);
// 3rd compaction
final byte[] qual5 = { (byte) 0xF0, 0x05, 0x5F, 0x07 };
final byte[] val5 = Bytes.fromLong(8L);
final byte[] qual6 = { 0x00, 0x67 };
final byte[] val6 = Bytes.fromLong(9L);
final byte[] qual56 = MockBase.concatByteArrays(qual5, qual6);
kvs.add(makekv(qual12, MockBase.concatByteArrays(val1, val2, ZERO)));
kvs.add(makekv(qual34, MockBase.concatByteArrays(val3, val4, ZERO)));
kvs.add(makekv(qual56, MockBase.concatByteArrays(val5, val6, ZERO)));
final KeyValue kv = compactionq.compact(kvs, annotations);
assertArrayEquals(MockBase.concatByteArrays(qual12, qual34, qual56), kv.qualifier());
// TODO(jat): metadata byte should be 0x01?
assertArrayEquals(MockBase.concatByteArrays(val1, val2, val3, val4, val5, val6, MIXED_FLAG), kv.value());
// We wrote only the combined column.
verify(tsdb, times(1)).put(KEY, MockBase.concatByteArrays(qual1, qual2, qual3, qual4, qual5, qual6), MockBase.concatByteArrays(val1, val2, val3, val4, val5, val6, MIXED_FLAG));
// And we had to delete the 3 partially compacted columns.
verify(tsdb, times(1)).delete(eq(KEY), eqAnyOrder(new byte[][] { qual12, qual34, qual56 }));
}
use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestCompactionQueue method twoCellRowMS.
@Test
public void twoCellRowMS() throws Exception {
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(2);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(0);
final byte[] qual1 = { (byte) 0xF0, 0x00, 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, ZERO), 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, ZERO));
// And we had to delete individual cells.
verify(tsdb, times(1)).delete(eq(KEY), eqAnyOrder(new byte[][] { qual1, qual2 }));
}
use of org.hbase.async.KeyValue in project opentsdb by OpenTSDB.
the class TestCompactionQueue method appendsAndCompacted.
@Test
public void appendsAndCompacted() 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(MockBase.concatByteArrays(qual3, qual4), MockBase.concatByteArrays(val3, val4, ZERO)));
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