Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix #430 where good floating point values were not added to the
data point queue during FSCK.

Signed-off-by: Chris Larsen <clarsen@yahoo-inc.com>
  • Loading branch information
tkrajca authored and manolama committed May 7, 2015
1 parent 3949408 commit dcf516f
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/tools/Fsck.java
Expand Up @@ -894,6 +894,10 @@ private boolean fsckFloat(final DP dp) throws Exception {
} else {
return true;
}
} else {
if (compact_row || options.compact()) {
appendDP(qual, value, value.length);
}
}
return false;
}
Expand Down
59 changes: 58 additions & 1 deletion test/tools/TestFsck.java
Expand Up @@ -2937,6 +2937,63 @@ public void compactedAndSingleWSameTSFix() throws Exception {
assertNull(storage.getColumn(ROW, qual4));
}

@Test
public void compactedAndSingleWSameTSFloat() throws Exception {
when(options.resolveDupes()).thenReturn(true);

final byte[] qual1 = { 0x0, 0x0B };
final byte[] val1 = Bytes.fromInt(Float.floatToRawIntBits(500.8F));
final byte[] qual2 = { 0x0, 0x20 };
final byte[] val2 = { 5 };
final byte[] qual3 = { 0x0, 0x30 };
final byte[] val3 = { 6 };
final byte[] qual4 = { 0x0, 0x0B };
final byte[] val4 = Bytes.fromInt(Float.floatToRawIntBits(500.8F));
storage.addColumn(ROW,
MockBase.concatByteArrays(qual1, qual2, qual3),
MockBase.concatByteArrays(val1, val2, val3, new byte[] { 0 }));
storage.addColumn(ROW, qual4, val4);
final Fsck fsck = new Fsck(tsdb, options);
fsck.runFullTable();
assertEquals(2, fsck.kvs_processed.get());
assertEquals(1, fsck.duplicates.get());
assertEquals(1, fsck.totalErrors());
assertEquals(1, fsck.correctable());
storage.dumpToSystemOut();
assertArrayEquals(MockBase.concatByteArrays(val1, val2, val3, new byte[] { 0 }),
storage.getColumn(ROW, MockBase.concatByteArrays(qual1, qual2, qual3)));
assertArrayEquals(val4, storage.getColumn(ROW, qual4));
}

@Test
public void compactedAndSingleWSameTSFloatFix() throws Exception {
when(options.fix()).thenReturn(true);
when(options.resolveDupes()).thenReturn(true);

final byte[] qual1 = { 0x0, 0x0B };
final byte[] val1 = Bytes.fromInt(Float.floatToRawIntBits(500.8F));
final byte[] qual2 = { 0x0, 0x20 };
final byte[] val2 = { 5 };
final byte[] qual3 = { 0x0, 0x30 };
final byte[] val3 = { 6 };
final byte[] qual4 = { 0x0, 0x0B };
final byte[] val4 = Bytes.fromInt(Float.floatToRawIntBits(500.8F));
storage.addColumn(ROW,
MockBase.concatByteArrays(qual1, qual2, qual3),
MockBase.concatByteArrays(val1, val2, val3, new byte[] { 0 }));
storage.addColumn(ROW, qual4, val4);
final Fsck fsck = new Fsck(tsdb, options);
fsck.runFullTable();
assertEquals(2, fsck.kvs_processed.get());
assertEquals(1, fsck.duplicates.get());
assertEquals(1, fsck.totalErrors());
assertEquals(1, fsck.correctable());
storage.dumpToSystemOut();
assertArrayEquals(MockBase.concatByteArrays(val1, val2, val3, new byte[] { 0 }),
storage.getColumn(ROW, MockBase.concatByteArrays(qual1, qual2, qual3)));
assertNull(storage.getColumn(ROW, qual4));
}

@Test
public void compactedAndSingleWSameTSLWW() throws Exception {
when(options.lastWriteWins()).thenReturn(true);
Expand Down Expand Up @@ -3460,7 +3517,7 @@ public void tripleCompactedColumnsWSameTSLWWFix() throws Exception {
assertNull(storage.getColumn(ROW, MockBase.concatByteArrays(qual3, qual4)));
assertNull(storage.getColumn(ROW, MockBase.concatByteArrays(qual5, qual6)));
}

// MULTIPLE ISSUES ----------------------------
// check for interactions between flags, e.g. compact + delete bad values
// + resolve duplicates, etc
Expand Down

0 comments on commit dcf516f

Please sign in to comment.