()
| 638 | } |
| 639 | |
| 640 | @Test |
| 641 | public void fixFloatingPoint() throws Exception { |
| 642 | // Check that the compaction process is fixing incorrectly encoded |
| 643 | // floating point values. |
| 644 | ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(2); |
| 645 | ArrayList<Annotation> annotations = new ArrayList<Annotation>(0); |
| 646 | // Note: here the flags pretend the value is on 4 bytes, but it's actually |
| 647 | // on 8 bytes, so we expect the code to fix the flags as it's compacting. |
| 648 | final byte[] qual1 = { 0x00, 0x07 }; |
| 649 | final byte[] val1 = Bytes.fromLong(4L); |
| 650 | kvs.add(makekv(qual1, val1)); |
| 651 | final byte[] qual2 = { 0x00, 0x1B }; // +1s, float, 4 bytes. |
| 652 | final byte[] val2 = Bytes.fromLong(Float.floatToRawIntBits(4.2F)); |
| 653 | final byte[] cval2 = Bytes.fromInt(Float.floatToRawIntBits(4.2F)); |
| 654 | kvs.add(makekv(qual2, val2)); |
| 655 | |
| 656 | final KeyValue kv = compactionq.compact(kvs, annotations, null); |
| 657 | assertArrayEquals(MockBase.concatByteArrays(qual1, qual2), kv.qualifier()); |
| 658 | assertArrayEquals(MockBase.concatByteArrays(val1, cval2, ZERO), kv.value()); |
| 659 | |
| 660 | // We had one row to compact, so one put to do. |
| 661 | verify(tsdb, times(1)).put(KEY, MockBase.concatByteArrays(qual1, qual2), |
| 662 | MockBase.concatByteArrays(val1, cval2, ZERO), kvCount - 1); |
| 663 | // And we had to delete individual cells. |
| 664 | verify(tsdb, times(1)).delete(eq(KEY), eqAnyOrder(new byte[][] { qual1, qual2, })); |
| 665 | } |
| 666 | |
| 667 | @Test (expected = IllegalDataException.class) |
| 668 | public void overlappingDataPoints() throws Exception { |
nothing calls this directly
no test coverage detected