diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/DoubleType.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/DoubleType.java index 1fe10746b..14c6160be 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/DoubleType.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/DoubleType.java @@ -449,7 +449,8 @@ public void serializeArray(Object array, int rowSize, DataOutputStream stream) public void serializeArray(Object array, int length, ByteBuffer buffer) { double[] values = (double[]) array; for (int i = 0; i < length; i++) { - buffer.putDouble(values[i]); + // Match the canonical NaN representation of the stream serialization. + buffer.putLong(Double.doubleToLongBits(values[i])); } } diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/FloatType.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/FloatType.java index 14458dde9..0300b1629 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/FloatType.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/FloatType.java @@ -447,7 +447,8 @@ public void serializeArray(Object array, int rowSize, DataOutputStream stream) public void serializeArray(Object array, int length, ByteBuffer buffer) { float[] values = (float[]) array; for (int i = 0; i < length; i++) { - buffer.putFloat(values[i]); + // Match the canonical NaN representation of the stream serialization. + buffer.putInt(Float.floatToIntBits(values[i])); } } diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/reader/page/AbstractAlignedPageReader.java b/java/tsfile/src/main/java/org/apache/tsfile/read/reader/page/AbstractAlignedPageReader.java index 2a95472b6..d990a8850 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/reader/page/AbstractAlignedPageReader.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/reader/page/AbstractAlignedPageReader.java @@ -129,7 +129,10 @@ public abstract class AbstractAlignedPageReader implements IPageReader { public BatchData getAllSatisfiedPageData(boolean ascending) throws IOException { BatchData pageData = BatchDataFactory.createBatchData(TSDataType.VECTOR, ascending, false); int timeIndex = -1; - Object[] rowValues = new Object[valueCount]; + // Without record filters, only the presence of each value is needed. Avoid boxing every + // primitive just to check whether the row is all null. + Object[] rowValues = + globalTimeFilter == null && pushDownFilter == null ? null : new Object[valueCount]; while (timePageReader.hasNextTime()) { long timestamp = timePageReader.nextTime(); timeIndex++; @@ -141,13 +144,14 @@ public BatchData getAllSatisfiedPageData(boolean ascending) throws IOException { ValuePageReader pageReader = valuePageReaderList.get(i); if (pageReader != null) { v[i] = pageReader.nextValue(timestamp, timeIndex); - rowValues[i] = (v[i] == null) ? null : v[i].getValue(); } else { v[i] = null; - rowValues[i] = null; } - if (rowValues[i] != null) { - hasNotNullValues = true; + if (rowValues == null) { + hasNotNullValues |= v[i] != null; + } else { + rowValues[i] = v[i] == null ? null : v[i].getValue(); + hasNotNullValues |= rowValues[i] != null; } } diff --git a/java/tsfile/src/main/java/org/apache/tsfile/utils/ReadWriteIOUtils.java b/java/tsfile/src/main/java/org/apache/tsfile/utils/ReadWriteIOUtils.java index 187cc616c..8b6eefe08 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/utils/ReadWriteIOUtils.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/utils/ReadWriteIOUtils.java @@ -257,6 +257,11 @@ public static int write(byte n, OutputStream outputStream) throws IOException { return Byte.BYTES; } + public static int write(byte n, DataOutputStream outputStream) throws IOException { + outputStream.writeByte(n); + return Byte.BYTES; + } + /** * write a short n. * @@ -268,6 +273,11 @@ public static int write(short n, OutputStream outputStream) throws IOException { return bytes.length; } + public static int write(short n, DataOutputStream outputStream) throws IOException { + outputStream.writeShort(n); + return SHORT_LEN; + } + /** * write a byte n to byteBuffer. * @@ -311,6 +321,11 @@ public static int write(int n, OutputStream outputStream) throws IOException { return INT_LEN; } + public static int write(int n, DataOutputStream outputStream) throws IOException { + outputStream.writeInt(n); + return INT_LEN; + } + /** write the size (int) of the binary and then the bytes in binary */ public static int write(Binary binary, OutputStream outputStream) throws IOException { byte[] size = BytesUtils.intToBytes(binary.getValues().length); @@ -319,6 +334,13 @@ public static int write(Binary binary, OutputStream outputStream) throws IOExcep return size.length + binary.getValues().length; } + public static int write(Binary binary, DataOutputStream outputStream) throws IOException { + byte[] values = binary.getValues(); + outputStream.writeInt(values.length); + outputStream.write(values); + return INT_LEN + values.length; + } + /** * write a int n to byteBuffer. * @@ -340,6 +362,11 @@ public static int write(float n, OutputStream outputStream) throws IOException { return FLOAT_LEN; } + public static int write(float n, DataOutputStream outputStream) throws IOException { + outputStream.writeFloat(n); + return FLOAT_LEN; + } + /** * Write a double n to outputStream. * @@ -351,6 +378,11 @@ public static int write(double n, OutputStream outputStream) throws IOException return DOUBLE_LEN; } + public static int write(double n, DataOutputStream outputStream) throws IOException { + outputStream.writeDouble(n); + return DOUBLE_LEN; + } + /** * write a long n to outputStream. * @@ -362,6 +394,11 @@ public static int write(long n, OutputStream outputStream) throws IOException { return LONG_LEN; } + public static int write(long n, DataOutputStream outputStream) throws IOException { + outputStream.writeLong(n); + return LONG_LEN; + } + /** write a long n to byteBuffer. */ public static int write(long n, ByteBuffer buffer) { buffer.putLong(n); diff --git a/java/tsfile/src/main/java/org/apache/tsfile/write/record/Tablet.java b/java/tsfile/src/main/java/org/apache/tsfile/write/record/Tablet.java index 843588c59..81ac940f9 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/write/record/Tablet.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/write/record/Tablet.java @@ -33,7 +33,6 @@ import org.apache.tsfile.utils.Binary; import org.apache.tsfile.utils.BitMap; import org.apache.tsfile.utils.BytesUtils; -import org.apache.tsfile.utils.PublicBAOS; import org.apache.tsfile.utils.RamUsageEstimator; import org.apache.tsfile.utils.ReadWriteIOUtils; import org.apache.tsfile.write.schema.IMeasurementSchema; @@ -42,6 +41,7 @@ import java.io.DataOutputStream; import java.io.IOException; import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.time.LocalDate; import java.util.ArrayList; import java.util.Arrays; @@ -601,11 +601,29 @@ private Object createValueColumnOfDataType(TSDataType dataType, int capacity) { /** Serialize {@link Tablet} */ public ByteBuffer serialize() throws IOException { - final int serializedSize = serializedSize(); - try (PublicBAOS byteArrayOutputStream = new PublicBAOS(serializedSize); - DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream)) { - serialize(outputStream); - return ByteBuffer.wrap(byteArrayOutputStream.getBuf(), 0, byteArrayOutputStream.size()); + final ByteBuffer buffer = ByteBuffer.allocate(serializedSize()); + serialize(buffer); + buffer.flip(); + return buffer; + } + + /** + * Serialize this tablet at the buffer's current position using the same big-endian format as + * {@link #serialize(DataOutputStream)}. The buffer's position advances and its byte order is + * preserved. The caller must provide at least {@link #serializedSize()} remaining bytes. + */ + public void serialize(ByteBuffer buffer) { + final ByteOrder previousOrder = buffer.order(); + buffer.order(ByteOrder.BIG_ENDIAN); + try { + ReadWriteIOUtils.write(insertTargetName, buffer); + ReadWriteIOUtils.write(rowSize, buffer); + writeMeasurementSchemas(buffer); + writeTimes(buffer); + writeBitMaps(buffer); + writeValues(buffer); + } finally { + buffer.order(previousOrder); } } @@ -713,6 +731,21 @@ private void writeMeasurementSchemas(DataOutputStream stream) throws IOException } } + private void writeMeasurementSchemas(ByteBuffer buffer) { + ReadWriteIOUtils.write(BytesUtils.boolToByte(schemas != null), buffer); + if (schemas != null) { + ReadWriteIOUtils.write(schemas.size(), buffer); + for (int i = 0; i < schemas.size(); i++) { + IMeasurementSchema schema = schemas.get(i); + ReadWriteIOUtils.write(BytesUtils.boolToByte(schema != null), buffer); + if (schema != null) { + schema.serializeTo(buffer); + ReadWriteIOUtils.write((byte) columnCategories.get(i).ordinal(), buffer); + } + } + } + } + private void writeTimes(DataOutputStream stream) throws IOException { ReadWriteIOUtils.write(BytesUtils.boolToByte(timestamps != null), stream); if (timestamps != null) { @@ -722,6 +755,15 @@ private void writeTimes(DataOutputStream stream) throws IOException { } } + private void writeTimes(ByteBuffer buffer) { + ReadWriteIOUtils.write(BytesUtils.boolToByte(timestamps != null), buffer); + if (timestamps != null) { + for (int i = 0; i < rowSize; i++) { + buffer.putLong(timestamps[i]); + } + } + } + /** Serialize {@link BitMap}s */ private void writeBitMaps(DataOutputStream stream) throws IOException { ReadWriteIOUtils.write(BytesUtils.boolToByte(bitMaps != null), stream); @@ -739,6 +781,23 @@ private void writeBitMaps(DataOutputStream stream) throws IOException { } } + private void writeBitMaps(ByteBuffer buffer) { + ReadWriteIOUtils.write(BytesUtils.boolToByte(bitMaps != null), buffer); + if (bitMaps != null) { + int size = schemas == null ? 0 : schemas.size(); + for (int i = 0; i < size; i++) { + final boolean hasNull = bitMaps[i] != null && !bitMaps[i].isAllUnmarked(rowSize); + ReadWriteIOUtils.write(BytesUtils.boolToByte(hasNull), buffer); + if (hasNull) { + ReadWriteIOUtils.write(rowSize, buffer); + final byte[] bytes = bitMaps[i].getTruncatedByteArray(rowSize); + ReadWriteIOUtils.write(bytes.length, buffer); + buffer.put(bytes); + } + } + } + } + /** Serialize values */ private void writeValues(DataOutputStream stream) throws IOException { ReadWriteIOUtils.write(BytesUtils.boolToByte(values != null), stream); @@ -750,6 +809,20 @@ private void writeValues(DataOutputStream stream) throws IOException { } } + private void writeValues(ByteBuffer buffer) { + ReadWriteIOUtils.write(BytesUtils.boolToByte(values != null), buffer); + if (values != null) { + int size = schemas == null ? 0 : schemas.size(); + for (int i = 0; i < size; i++) { + final Object column = values[i]; + ReadWriteIOUtils.write(BytesUtils.boolToByte(column != null), buffer); + if (column != null) { + Type.fromTsDataType(schemas.get(i).getType()).serializeArray(column, rowSize, buffer); + } + } + } + } + private void serializeColumn(Type type, Object column, DataOutputStream stream) throws IOException { ReadWriteIOUtils.write(BytesUtils.boolToByte(column != null), stream); diff --git a/java/tsfile/src/test/java/org/apache/tsfile/read/reader/AlignedPageReaderPushDownTest.java b/java/tsfile/src/test/java/org/apache/tsfile/read/reader/AlignedPageReaderPushDownTest.java index c529d8917..90a64dce8 100644 --- a/java/tsfile/src/test/java/org/apache/tsfile/read/reader/AlignedPageReaderPushDownTest.java +++ b/java/tsfile/src/test/java/org/apache/tsfile/read/reader/AlignedPageReaderPushDownTest.java @@ -29,6 +29,7 @@ import org.apache.tsfile.enums.TSDataType; import org.apache.tsfile.file.header.PageHeader; import org.apache.tsfile.file.metadata.enums.CompressionType; +import org.apache.tsfile.read.common.BatchData; import org.apache.tsfile.read.common.TimeRange; import org.apache.tsfile.read.common.block.TsBlock; import org.apache.tsfile.read.filter.basic.Filter; @@ -36,6 +37,7 @@ import org.apache.tsfile.read.filter.factory.ValueFilterApi; import org.apache.tsfile.read.reader.page.AlignedPageReader; import org.apache.tsfile.read.reader.page.LazyLoadPageData; +import org.apache.tsfile.read.reader.page.TablePageReader; import org.apache.tsfile.read.reader.series.PaginationController; import org.apache.tsfile.write.page.TimePageWriter; import org.apache.tsfile.write.page.ValuePageWriter; @@ -62,6 +64,110 @@ public class AlignedPageReaderPushDownTest { private static final PageHeader testValuePageHeader2; private static ByteBuffer testValuePageData2; + @Test + public void testBatchDataWithoutRecordFilters() throws IOException { + for (boolean lazy : new boolean[] {false, true}) { + AlignedPageReader reader = + lazy ? generateAlignedPageReaderUsingLazyLoad(null) : generateAlignedPageReader(null); + BatchData data = reader.getAllSatisfiedPageData(true); + for (int time = 0; time < 100; time++, data.next()) { + Assert.assertTrue(data.hasCurrent()); + Assert.assertEquals(time, data.currentTime()); + Assert.assertEquals(time, data.getVector()[0].getInt()); + if (time >= 10 && time < 90) { + Assert.assertEquals(time, data.getVector()[1].getInt()); + } else { + Assert.assertNull(data.getVector()[1]); + } + } + Assert.assertFalse(data.hasCurrent()); + + reader = + lazy + ? generateSingleColumnAlignedPageReaderUsingLazyLoad(null, false) + : generateSingleColumnAlignedPageReader(null, false); + data = reader.getAllSatisfiedPageData(true); + for (int time = 10; time < 90; time++, data.next()) { + Assert.assertTrue(data.hasCurrent()); + Assert.assertEquals(time, data.currentTime()); + Assert.assertEquals(time, data.getVector()[0].getInt()); + } + Assert.assertFalse(data.hasCurrent()); + } + } + + @Test + public void testBatchDataWithoutRecordFiltersHonorsDeletes() throws IOException { + AlignedPageReader reader = generateAlignedPageReader(null, Arrays.asList(true, true)); + reader.setDeleteIntervalList( + Arrays.asList( + Collections.singletonList(new TimeRange(0, 29)), + Collections.singletonList(new TimeRange(20, 39)))); + BatchData data = reader.getAllSatisfiedPageData(true); + for (int time = 0; time < 100; time++) { + if (time < 10 || (time >= 20 && time < 30)) { + continue; + } + Assert.assertTrue(data.hasCurrent()); + Assert.assertEquals(time, data.currentTime()); + if (time < 30) { + Assert.assertNull(data.getVector()[0]); + } else { + Assert.assertEquals(time, data.getVector()[0].getInt()); + } + if ((time >= 10 && time < 20) || (time >= 40 && time < 90)) { + Assert.assertEquals(time, data.getVector()[1].getInt()); + } else { + Assert.assertNull(data.getVector()[1]); + } + data.next(); + } + Assert.assertFalse(data.hasCurrent()); + } + + @Test + public void testBatchDataWithRecordFilters() throws IOException { + for (Filter timeFilter : new Filter[] {null, TimeFilterApi.between(30, 69)}) { + AlignedPageReader reader = generateAlignedPageReader(timeFilter); + reader.addRecordFilter(ValueFilterApi.gtEq(DEFAULT_MEASUREMENT_INDEX, 50, TSDataType.INT32)); + BatchData data = reader.getAllSatisfiedPageData(true); + int end = timeFilter == null ? 100 : 70; + for (int time = 50; time < end; time++, data.next()) { + Assert.assertTrue(data.hasCurrent()); + Assert.assertEquals(time, data.currentTime()); + Assert.assertEquals(time, data.getVector()[0].getInt()); + } + Assert.assertFalse(data.hasCurrent()); + } + } + + @Test + public void testTableBatchDataKeepsAllNullRowsWithoutRecordFilters() throws IOException { + resetDataBuffer(); + TablePageReader reader = + new TablePageReader( + testTimePageHeader, + testTimePageData, + new DeltaBinaryDecoder.LongDeltaDecoder(), + Arrays.asList(null, testValuePageHeader2), + Arrays.asList(null, testValuePageData2), + Arrays.asList(TSDataType.INT32, TSDataType.INT32), + Arrays.asList(new IntRleDecoder(), new IntRleDecoder()), + null); + BatchData data = reader.getAllSatisfiedPageData(true); + for (int time = 0; time < 100; time++, data.next()) { + Assert.assertTrue(data.hasCurrent()); + Assert.assertEquals(time, data.currentTime()); + Assert.assertNull(data.getVector()[0]); + if (time >= 10 && time < 90) { + Assert.assertEquals(time, data.getVector()[1].getInt()); + } else { + Assert.assertNull(data.getVector()[1]); + } + } + Assert.assertFalse(data.hasCurrent()); + } + static { TimePageWriter timePageWriter = new TimePageWriter( diff --git a/java/tsfile/src/test/java/org/apache/tsfile/utils/ReadWriteIOUtilsTest.java b/java/tsfile/src/test/java/org/apache/tsfile/utils/ReadWriteIOUtilsTest.java index 01f747c6c..950f6296e 100644 --- a/java/tsfile/src/test/java/org/apache/tsfile/utils/ReadWriteIOUtilsTest.java +++ b/java/tsfile/src/test/java/org/apache/tsfile/utils/ReadWriteIOUtilsTest.java @@ -47,6 +47,63 @@ public class ReadWriteIOUtilsTest { protected static final int DEFAULT_BUFFER_SIZE = 4096; + @Test + public void testDataOutputStreamWritesMatchOutputStreamFormat() throws IOException { + ByteArrayOutputStream reference = new ByteArrayOutputStream(); + ByteArrayOutputStream actual = new ByteArrayOutputStream(); + try (DataOutputStream stream = new DataOutputStream(actual)) { + for (byte value : new byte[] {Byte.MIN_VALUE, -1, 0, Byte.MAX_VALUE}) { + ReadWriteIOUtils.write(value, reference); + Assert.assertEquals(Byte.BYTES, ReadWriteIOUtils.write(value, stream)); + } + for (short value : new short[] {Short.MIN_VALUE, -1, 0, Short.MAX_VALUE}) { + ReadWriteIOUtils.write(value, reference); + Assert.assertEquals(Short.BYTES, ReadWriteIOUtils.write(value, stream)); + } + for (int value : new int[] {Integer.MIN_VALUE, -1, 0, Integer.MAX_VALUE}) { + ReadWriteIOUtils.write(value, reference); + Assert.assertEquals(Integer.BYTES, ReadWriteIOUtils.write(value, stream)); + } + for (long value : new long[] {Long.MIN_VALUE, -1, 0, Long.MAX_VALUE}) { + ReadWriteIOUtils.write(value, reference); + Assert.assertEquals(Long.BYTES, ReadWriteIOUtils.write(value, stream)); + } + for (float value : + new float[] { + -0.0f, + 0.0f, + Float.MIN_VALUE, + Float.MAX_VALUE, + Float.NEGATIVE_INFINITY, + Float.POSITIVE_INFINITY, + Float.intBitsToFloat(0x7fa12345) + }) { + ReadWriteIOUtils.write(value, reference); + Assert.assertEquals(Float.BYTES, ReadWriteIOUtils.write(value, stream)); + } + for (double value : + new double[] { + -0.0, + 0.0, + Double.MIN_VALUE, + Double.MAX_VALUE, + Double.NEGATIVE_INFINITY, + Double.POSITIVE_INFINITY, + Double.longBitsToDouble(0x7ff123456789abcdL) + }) { + ReadWriteIOUtils.write(value, reference); + Assert.assertEquals(Double.BYTES, ReadWriteIOUtils.write(value, stream)); + } + for (Binary value : new Binary[] {Binary.EMPTY_VALUE, new Binary(new byte[] {0, -1, 1, 0})}) { + ReadWriteIOUtils.write(value, reference); + Assert.assertEquals( + Integer.BYTES + value.getLength(), ReadWriteIOUtils.write(value, stream)); + } + Assert.assertEquals(reference.size(), stream.size()); + } + Assert.assertArrayEquals(reference.toByteArray(), actual.toByteArray()); + } + @Test public void testReadLongFromFragmentedStream() throws IOException { long expected = 0x8123456789ABCDEFL; diff --git a/java/tsfile/src/test/java/org/apache/tsfile/write/record/TabletTest.java b/java/tsfile/src/test/java/org/apache/tsfile/write/record/TabletTest.java index 660fe8534..358f2d85f 100644 --- a/java/tsfile/src/test/java/org/apache/tsfile/write/record/TabletTest.java +++ b/java/tsfile/src/test/java/org/apache/tsfile/write/record/TabletTest.java @@ -39,7 +39,9 @@ import java.io.DataOutputStream; import java.io.IOException; +import java.nio.BufferOverflowException; import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.nio.charset.StandardCharsets; import java.time.LocalDate; import java.util.ArrayList; @@ -823,11 +825,98 @@ private void assertSerializedSizeMatches(Tablet tablet, String scenario) throws DataOutputStream outputStream = new DataOutputStream(baos)) { tablet.serialize(outputStream); assertEquals(scenario + ": serialize(stream) size", expectedSize, baos.size()); + Assert.assertArrayEquals( + scenario + ": buffer and stream wire format", + Arrays.copyOf(baos.getBuf(), baos.size()), + buffer.array()); } buffer.rewind(); assertEquals(scenario + ": deserialize roundtrip", tablet, Tablet.deserialize(buffer)); } + @Test + public void testSerializeToExistingByteBuffer() throws IOException { + final List types = + Arrays.asList( + TSDataType.BOOLEAN, + TSDataType.INT32, + TSDataType.INT64, + TSDataType.FLOAT, + TSDataType.DOUBLE, + TSDataType.TEXT, + TSDataType.STRING, + TSDataType.BLOB, + TSDataType.DATE, + TSDataType.TIMESTAMP, + TSDataType.OBJECT); + final Tablet tablet = + createAndFillTreeTablet("root.设备.d1", buildColumnNames(types), types, 9, 0, true, true); + final byte[] expected = tablet.serialize().array(); + final int size = expected.length; + final ByteBuffer sliced = ByteBuffer.allocate(size + 13); + sliced.position(7); + for (ByteBuffer buffer : + new ByteBuffer[] { + ByteBuffer.allocate(size + 6), ByteBuffer.allocateDirect(size + 6), sliced.slice() + }) { + while (buffer.hasRemaining()) { + buffer.put((byte) 0x5a); + } + buffer.position(2); + buffer.limit(2 + size); + buffer.order(ByteOrder.LITTLE_ENDIAN); + tablet.serialize(buffer); + assertEquals(2 + size, buffer.position()); + assertEquals(2 + size, buffer.limit()); + assertEquals(ByteOrder.LITTLE_ENDIAN, buffer.order()); + buffer.position(2); + final byte[] actual = new byte[size]; + buffer.get(actual); + Assert.assertArrayEquals(expected, actual); + assertEquals(tablet, Tablet.deserialize(ByteBuffer.wrap(actual))); + buffer.clear(); + assertEquals((byte) 0x5a, buffer.get(0)); + assertEquals((byte) 0x5a, buffer.get(1)); + for (int i = 2 + size; i < buffer.capacity(); i++) { + assertEquals((byte) 0x5a, buffer.get(i)); + } + } + final ByteBuffer tooSmall = ByteBuffer.allocate(size - 1).order(ByteOrder.LITTLE_ENDIAN); + Assert.assertThrows(BufferOverflowException.class, () -> tablet.serialize(tooSmall)); + assertEquals(ByteOrder.LITTLE_ENDIAN, tooSmall.order()); + } + + @Test + public void testSerializationCanonicalizesNaNs() throws IOException { + final Tablet tablet = + new Tablet( + "root.sg.d1", + Arrays.asList( + new MeasurementSchema("f", TSDataType.FLOAT), + new MeasurementSchema("d", TSDataType.DOUBLE)), + 5); + final float[] floats = { + Float.intBitsToFloat(0x7fa12345), + Float.intBitsToFloat(0xffc12345), + -0.0f, + Float.POSITIVE_INFINITY, + Float.MIN_VALUE + }; + final double[] doubles = { + Double.longBitsToDouble(0x7ff123456789abcdL), + Double.longBitsToDouble(0xfff123456789abcdL), + -0.0, + Double.NEGATIVE_INFINITY, + Double.MIN_VALUE + }; + for (int i = 0; i < floats.length; i++) { + tablet.addTimestamp(i, i); + tablet.addValue("f", i, floats[i]); + tablet.addValue("d", i, doubles[i]); + } + assertSerializedSizeMatches(tablet, "floating-point wire format"); + } + @Test public void testAppendInconsistent() { Tablet t1 =