From c5a51496793fc68b1e55ad9098ce2547c3bfecc6 Mon Sep 17 00:00:00 2001 From: Caideyipi <87789683+Caideyipi@users.noreply.github.com> Date: Mon, 16 Nov 2026 09:41:05 +0800 Subject: [PATCH] [Pipe] Reduce allocations in query Field copying and Tablet batch encoding --- .../event/common/tablet/PipeTabletUtils.java | 53 ++++++ ...sertionEventQueryParserTabletIterator.java | 4 +- .../batch/PipeTabletEventPlainBatch.java | 29 ++-- .../common/tablet/PipeTabletUtilsTest.java | 68 ++++++++ ...ionEventQueryParserTabletIteratorTest.java | 115 +++++++++++++ ...abletEventPlainBatchSerializationTest.java | 153 ++++++++++++++++++ pom.xml | 2 +- 7 files changed, 401 insertions(+), 23 deletions(-) create mode 100644 iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/event/common/tsfile/parser/query/TsFileInsertionEventQueryParserTabletIteratorTest.java create mode 100644 iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/sink/payload/evolvable/batch/PipeTabletEventPlainBatchSerializationTest.java diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tablet/PipeTabletUtils.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tablet/PipeTabletUtils.java index 8d341fa9b9d53..120b98978660f 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tablet/PipeTabletUtils.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tablet/PipeTabletUtils.java @@ -24,6 +24,7 @@ import org.apache.tsfile.common.conf.TSFileConfig; import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.read.common.Field; import org.apache.tsfile.read.common.type.Type; import org.apache.tsfile.utils.Binary; import org.apache.tsfile.utils.BitMap; @@ -31,6 +32,7 @@ import org.apache.tsfile.write.schema.IMeasurementSchema; import org.apache.tsfile.write.schema.MeasurementSchema; +import java.time.LocalDate; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -171,6 +173,57 @@ public static void putValue( unmarkNullValue(tablet, rowIndex, columnIndex); } + /** Copy a query field without boxing primitive values on the way to the tablet. */ + public static void putFieldValue( + final Tablet tablet, + final int rowIndex, + final int columnIndex, + final TSDataType dataType, + final Field field) { + if (field.getDataType() == null) { + putValue(tablet, rowIndex, columnIndex, dataType, null); + return; + } + + final Object column = tablet.getValues()[columnIndex]; + switch (dataType) { + case BOOLEAN: + ((boolean[]) column)[rowIndex] = field.getBoolV(); + break; + case INT32: + ((int[]) column)[rowIndex] = field.getIntV(); + break; + case INT64: + case TIMESTAMP: + ((long[]) column)[rowIndex] = field.getLongV(); + break; + case FLOAT: + ((float[]) column)[rowIndex] = field.getFloatV(); + break; + case DOUBLE: + ((double[]) column)[rowIndex] = field.getDoubleV(); + break; + case DATE: + if (!(column instanceof LocalDate[])) { + putValue(tablet, rowIndex, columnIndex, dataType, field.getObjectValue(dataType)); + return; + } + ((LocalDate[]) column)[rowIndex] = field.getDateV(); + break; + case TEXT: + case STRING: + case BLOB: + final Binary value = field.getBinaryV(); + ((Binary[]) column)[rowIndex] = value == null ? Binary.EMPTY_VALUE : value; + break; + default: + putValue(tablet, rowIndex, columnIndex, dataType, field.getObjectValue(dataType)); + return; + } + // A row discarded after applying mods may have marked this slot before it is reused. + unmarkNullValue(tablet, rowIndex, columnIndex); + } + public static void unmarkNullValue( final Tablet tablet, final int rowIndex, final int columnIndex) { final BitMap[] bitMaps = tablet.getBitMaps(); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/parser/query/TsFileInsertionEventQueryParserTabletIterator.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/parser/query/TsFileInsertionEventQueryParserTabletIterator.java index ee27eda4a5354..9df937841a9c1 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/parser/query/TsFileInsertionEventQueryParserTabletIterator.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tsfile/parser/query/TsFileInsertionEventQueryParserTabletIterator.java @@ -184,7 +184,6 @@ private Tablet buildNextTablet() throws IOException { final int fieldSize = fields.size(); for (int i = 0; i < fieldSize; i++) { final Field field = fields.get(i); - final String measurement = measurements.get(i); final TSDataType dataType = schemas.get(i).getType(); // Check if this value is deleted by mods if (field == null @@ -194,8 +193,7 @@ private Tablet buildNextTablet() throws IOException { } PipeTabletUtils.markNullValue(tablet, rowIndex, i); } else { - PipeTabletUtils.putValue( - tablet, rowIndex, i, dataType, field.getObjectValue(schemas.get(i).getType())); + PipeTabletUtils.putFieldValue(tablet, rowIndex, i, dataType, field); isNeedFillTime = true; } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/payload/evolvable/batch/PipeTabletEventPlainBatch.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/payload/evolvable/batch/PipeTabletEventPlainBatch.java index 82cacc75c439d..66baaed98bd1c 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/payload/evolvable/batch/PipeTabletEventPlainBatch.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/payload/evolvable/batch/PipeTabletEventPlainBatch.java @@ -32,12 +32,10 @@ import org.apache.tsfile.read.common.type.Type; import org.apache.tsfile.utils.BitMap; import org.apache.tsfile.utils.Pair; -import org.apache.tsfile.utils.PublicBAOS; import org.apache.tsfile.utils.RamUsageEstimator; import org.apache.tsfile.utils.ReadWriteIOUtils; import org.apache.tsfile.write.record.Tablet; -import java.io.DataOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.util.ArrayList; @@ -200,14 +198,7 @@ public PipeTransferTabletBatchReqV2 toTPipeTransferReq() throws IOException { } } for (final Pair tabletPair : batchTablets) { - try (final PublicBAOS byteArrayOutputStream = - new PublicBAOS(calculateTabletSerializedSize(tabletPair.getRight())); - final DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream)) { - tabletPair.getRight().serialize(outputStream); - ReadWriteIOUtils.write(true, outputStream); - tabletBuffers.add( - ByteBuffer.wrap(byteArrayOutputStream.getBuf(), 0, byteArrayOutputStream.size())); - } + tabletBuffers.add(serializeTabletWithAlignment(tabletPair.getRight(), true)); tabletDataBases.add(databaseName); } } @@ -268,13 +259,7 @@ private long buildTabletInsertionBuffer(final TabletInsertionEvent event) throws pipeRawTabletInsertionEvent.getTableModelDatabaseName()); } else { final Tablet tablet = pipeRawTabletInsertionEvent.convertToTablet(); - try (final PublicBAOS byteArrayOutputStream = - new PublicBAOS(calculateTabletSerializedSize(tablet)); - final DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream)) { - tablet.serialize(outputStream); - ReadWriteIOUtils.write(pipeRawTabletInsertionEvent.isAligned(), outputStream); - buffer = ByteBuffer.wrap(byteArrayOutputStream.getBuf(), 0, byteArrayOutputStream.size()); - } + buffer = serializeTabletWithAlignment(tablet, pipeRawTabletInsertionEvent.isAligned()); final String databaseName = pipeRawTabletInsertionEvent.getTreeModelDatabaseName(); estimateSize = RamUsageEstimator.sizeOf(databaseName) + buffer.limit(); increaseTotalBufferSizeAndUpdateMemoryBlock(estimateSize); @@ -307,8 +292,14 @@ private static long calculateTabletSizeInBytes(final Tablet tablet) { return PipeMemoryWeightUtil.calculateTabletSizeInBytes(tablet) + 4; } - private static int calculateTabletSerializedSize(final Tablet tablet) { - return tablet.serializedSize() + Byte.BYTES; + private static ByteBuffer serializeTabletWithAlignment( + final Tablet tablet, final boolean isAligned) { + final ByteBuffer buffer = + ByteBuffer.allocate(Math.addExact(tablet.serializedSize(), Byte.BYTES)); + tablet.serialize(buffer); + ReadWriteIOUtils.write(isAligned, buffer); + buffer.flip(); + return buffer; } static boolean mayAppendTablet(final Tablet target, final Tablet source) { diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/event/common/tablet/PipeTabletUtilsTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/event/common/tablet/PipeTabletUtilsTest.java index 9ef48fe52ec4b..7bfa1be60649d 100644 --- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/event/common/tablet/PipeTabletUtilsTest.java +++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/event/common/tablet/PipeTabletUtilsTest.java @@ -20,13 +20,19 @@ package org.apache.iotdb.db.pipe.event.common.tablet; import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.read.common.Field; +import org.apache.tsfile.read.common.type.Type; +import org.apache.tsfile.utils.Binary; +import org.apache.tsfile.utils.DateUtils; import org.apache.tsfile.write.record.Tablet; import org.apache.tsfile.write.schema.IMeasurementSchema; import org.apache.tsfile.write.schema.MeasurementSchema; import org.junit.Assert; import org.junit.Test; +import java.time.LocalDate; import java.util.Arrays; +import java.util.Collections; import java.util.List; public class PipeTabletUtilsTest { @@ -49,4 +55,66 @@ public void testPutValueUnmarksReusedNullRow() { Assert.assertFalse(tablet.isNull(0, 0)); Assert.assertTrue(tablet.isNull(0, 1)); } + + @Test + public void testPutFieldValueMatchesObjectConversion() { + final TSDataType[] types = { + TSDataType.BOOLEAN, + TSDataType.INT32, + TSDataType.INT64, + TSDataType.TIMESTAMP, + TSDataType.FLOAT, + TSDataType.DOUBLE, + TSDataType.DATE, + TSDataType.TEXT, + TSDataType.STRING, + TSDataType.BLOB, + TSDataType.OBJECT + }; + final Object[] values = { + true, + 123456789, + 9876543210L, + Long.MIN_VALUE, + -0.0f, + Double.longBitsToDouble(0x7ff0000000000001L), + DateUtils.parseDateExpressionToInt(LocalDate.of(2024, 2, 29)), + new Binary(new byte[] {1, 2, 3}), + new Binary(new byte[] {4, 5}), + new Binary(new byte[0]), + new Binary(new byte[16]) + }; + for (int i = 0; i < types.length; i++) { + final List schemas = + Collections.singletonList(new MeasurementSchema("s1", types[i])); + final Tablet expected = new Tablet("root.sg.d1", schemas, 1); + final Tablet actual = new Tablet("root.sg.d1", schemas, 1); + final Field field = Type.fromTsDataType(types[i]).getField(values[i]); + PipeTabletUtils.markNullValue(actual, 0, 0); + + PipeTabletUtils.putValue(expected, 0, 0, types[i], field.getObjectValue(types[i])); + PipeTabletUtils.putFieldValue(actual, 0, 0, types[i], field); + + Assert.assertFalse(actual.isNull(0, 0)); + Assert.assertEquals(expected.getValue(0, 0), actual.getValue(0, 0)); + } + } + + @Test + public void testPutFieldValuePreservesNullFieldDefaults() { + for (final TSDataType type : + Arrays.asList(TSDataType.INT32, TSDataType.DATE, TSDataType.STRING, TSDataType.BLOB)) { + final List schemas = + Collections.singletonList(new MeasurementSchema("s1", type)); + final Tablet expected = new Tablet("root.sg.d1", schemas, 1); + final Tablet actual = new Tablet("root.sg.d1", schemas, 1); + PipeTabletUtils.markNullValue(actual, 0, 0); + + PipeTabletUtils.putValue(expected, 0, 0, type, null); + PipeTabletUtils.putFieldValue(actual, 0, 0, type, new Field(null)); + + Assert.assertFalse(actual.isNull(0, 0)); + Assert.assertEquals(expected.getValue(0, 0), actual.getValue(0, 0)); + } + } } diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/event/common/tsfile/parser/query/TsFileInsertionEventQueryParserTabletIteratorTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/event/common/tsfile/parser/query/TsFileInsertionEventQueryParserTabletIteratorTest.java new file mode 100644 index 0000000000000..22151ecf75d3d --- /dev/null +++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/event/common/tsfile/parser/query/TsFileInsertionEventQueryParserTabletIteratorTest.java @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iotdb.db.pipe.event.common.tsfile.parser.query; + +import org.apache.iotdb.commons.path.MeasurementPath; +import org.apache.iotdb.commons.path.PatternTreeMap; +import org.apache.iotdb.db.pipe.event.common.tablet.PipeTabletUtils.TabletStringInternPool; +import org.apache.iotdb.db.pipe.event.common.tsfile.parser.TsFileInsertionEventParserMemoryBlock; +import org.apache.iotdb.db.storageengine.dataregion.modification.ModEntry; +import org.apache.iotdb.db.storageengine.dataregion.modification.TreeDeletionEntry; +import org.apache.iotdb.db.utils.datastructure.PatternTreeMapFactory; + +import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.file.metadata.IDeviceID; +import org.apache.tsfile.read.TsFileReader; +import org.apache.tsfile.read.common.Field; +import org.apache.tsfile.read.common.RowRecord; +import org.apache.tsfile.read.expression.QueryExpression; +import org.apache.tsfile.read.query.dataset.QueryDataSet; +import org.apache.tsfile.utils.Binary; +import org.apache.tsfile.write.record.Tablet; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class TsFileInsertionEventQueryParserTabletIteratorTest { + + @Test + public void testDeletedRowSlotIsReusedWithCorrectNulls() throws Exception { + final RowRecord deleted = row(0, 10L, new Binary(new byte[] {1})); + final RowRecord sparse = row(1, 11L, null); + final RowRecord dense = row(2, 12L, new Binary(new byte[] {2, 3})); + final List rows = Arrays.asList(deleted, sparse, dense); + final AtomicInteger cursor = new AtomicInteger(); + final QueryDataSet dataSet = mock(QueryDataSet.class); + when(dataSet.hasNext()).thenAnswer(invocation -> cursor.get() < rows.size()); + when(dataSet.next()).thenAnswer(invocation -> rows.get(cursor.getAndIncrement())); + final TsFileReader reader = mock(TsFileReader.class); + when(reader.query(any(QueryExpression.class))).thenReturn(dataSet); + final TsFileInsertionEventParserMemoryBlock memory = + mock(TsFileInsertionEventParserMemoryBlock.class); + when(memory.getMemoryUsageInBytes()).thenReturn(Long.MAX_VALUE); + final PatternTreeMap modifications = + PatternTreeMapFactory.getModsPatternTreeMap(); + for (final TreeDeletionEntry deletion : + Arrays.asList( + new TreeDeletionEntry(new MeasurementPath("root.sg.d.s1"), 0, 0), + new TreeDeletionEntry(new MeasurementPath("root.sg.d.s2"), 0, 0))) { + modifications.append(deletion.keyOfPatternTree(), deletion); + } + + final TsFileInsertionEventQueryParserTabletIterator iterator = + new TsFileInsertionEventQueryParserTabletIterator( + reader, + Map.of("root.sg.d.s1", TSDataType.INT64, "root.sg.d.s2", TSDataType.STRING), + IDeviceID.Factory.DEFAULT_FACTORY.create("root.sg.d"), + Arrays.asList("s2", "s1"), + null, + memory, + modifications, + new TabletStringInternPool()); + + final Tablet tablet = iterator.next(); + Assert.assertEquals(2, tablet.getRowSize()); + Assert.assertEquals(1, tablet.getTimestamp(0)); + Assert.assertEquals(11L, tablet.getValue(0, 0)); + Assert.assertFalse(tablet.isNull(0, 0)); + Assert.assertTrue(tablet.isNull(0, 1)); + Assert.assertEquals(2, tablet.getTimestamp(1)); + Assert.assertEquals(12L, tablet.getValue(1, 0)); + Assert.assertEquals(dense.getFields().get(1).getBinaryV(), tablet.getValue(1, 1)); + Assert.assertFalse(tablet.isNull(1, 1)); + Assert.assertFalse(iterator.hasNext()); + } + + private static RowRecord row(final long time, final long value, final Binary binary) { + final RowRecord row = new RowRecord(time); + final Field number = new Field(TSDataType.INT64); + number.setLongV(value); + row.addField(number); + if (binary == null) { + row.addField(null); + } else { + final Field text = new Field(TSDataType.STRING); + text.setBinaryV(binary); + row.addField(text); + } + return row; + } +} diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/sink/payload/evolvable/batch/PipeTabletEventPlainBatchSerializationTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/sink/payload/evolvable/batch/PipeTabletEventPlainBatchSerializationTest.java new file mode 100644 index 0000000000000..a3d893161472d --- /dev/null +++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/sink/payload/evolvable/batch/PipeTabletEventPlainBatchSerializationTest.java @@ -0,0 +1,153 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iotdb.db.pipe.sink.payload.evolvable.batch; + +import org.apache.iotdb.db.pipe.event.common.tablet.PipeRawTabletInsertionEvent; +import org.apache.iotdb.db.pipe.sink.payload.evolvable.request.PipeTransferTabletBatchReqV2; + +import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.utils.Binary; +import org.apache.tsfile.utils.ReadWriteIOUtils; +import org.apache.tsfile.write.record.Tablet; +import org.apache.tsfile.write.schema.IMeasurementSchema; +import org.apache.tsfile.write.schema.MeasurementSchema; +import org.junit.Assert; +import org.junit.Test; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.nio.ByteBuffer; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class PipeTabletEventPlainBatchSerializationTest { + + @Test + public void testTreeBatchMatchesStreamWireFormat() throws Exception { + final Tablet aligned = tablet("root.test.aligned"); + final Tablet nonAligned = tablet("root.test.non_aligned"); + try (final PipeTabletEventPlainBatch batch = + new PipeTabletEventPlainBatch(1000, 1024 * 1024, null)) { + batch.constructBatch(event(aligned, false, true)); + batch.constructBatch(event(nonAligned, false, false)); + final ByteBuffer expected = + PipeTransferTabletBatchReqV2.toTPipeTransferReq( + Collections.emptyList(), + Arrays.asList(streamBytes(aligned, true), streamBytes(nonAligned, false)), + Collections.emptyList(), + Arrays.asList("root.test", "root.test")) + .body; + Assert.assertEquals(expected, batch.toTPipeTransferReq().body); + } + } + + @Test + public void testMergedTableBatchMatchesStreamWireFormat() throws Exception { + final Tablet first = tablet("table1"); + final Tablet second = tablet("table1"); + final Tablet expectedTablet = tablet("table1"); + Assert.assertTrue(expectedTablet.append(second)); + try (final PipeTabletEventPlainBatch batch = + new PipeTabletEventPlainBatch(1000, 1024 * 1024, null)) { + batch.constructBatch(event(first, true, true)); + batch.constructBatch(event(second, true, true)); + final ByteBuffer expected = + PipeTransferTabletBatchReqV2.toTPipeTransferReq( + Collections.emptyList(), + Collections.singletonList(streamBytes(expectedTablet, true)), + Collections.emptyList(), + Collections.singletonList("test")) + .body; + Assert.assertEquals(expected, batch.toTPipeTransferReq().body); + Assert.assertEquals(3, first.getRowSize()); + Assert.assertEquals(3, second.getRowSize()); + } + } + + private static PipeRawTabletInsertionEvent event( + final Tablet tablet, final boolean tableModel, final boolean aligned) { + final PipeRawTabletInsertionEvent event = mock(PipeRawTabletInsertionEvent.class); + when(event.convertToTablet()).thenReturn(tablet); + when(event.isTableModelEvent()).thenReturn(tableModel); + when(event.isAligned()).thenReturn(aligned); + when(event.getTreeModelDatabaseName()).thenReturn("root.test"); + when(event.getTableModelDatabaseName()).thenReturn("test"); + return event; + } + + private static ByteBuffer streamBytes(final Tablet tablet, final boolean aligned) + throws Exception { + final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + try (final DataOutputStream stream = new DataOutputStream(bytes)) { + tablet.serialize(stream); + ReadWriteIOUtils.write(aligned, stream); + } + return ByteBuffer.wrap(bytes.toByteArray()); + } + + private static Tablet tablet(final String name) { + final TSDataType[] types = { + TSDataType.BOOLEAN, + TSDataType.INT32, + TSDataType.INT64, + TSDataType.TIMESTAMP, + TSDataType.FLOAT, + TSDataType.DOUBLE, + TSDataType.DATE, + TSDataType.TEXT, + TSDataType.STRING, + TSDataType.BLOB, + TSDataType.OBJECT + }; + final Object[] values = { + true, + Integer.MIN_VALUE, + Long.MAX_VALUE, + -1L, + Float.intBitsToFloat(0x7f800001), + Double.longBitsToDouble(0x7ff0000000000001L), + LocalDate.of(2024, 2, 29), + new Binary(new byte[] {0, 1, -1}), + new Binary(new byte[] {2, 3}), + Binary.EMPTY_VALUE, + new Binary(new byte[] {4, 5}) + }; + final List schemas = new ArrayList<>(); + for (int column = 0; column < types.length; column++) { + schemas.add(new MeasurementSchema("s" + column, types[column])); + } + final Tablet tablet = new Tablet(name, schemas, 5); + for (int row = 0; row < 3; row++) { + tablet.addTimestamp(row, row); + for (int column = 0; column < types.length; column++) { + tablet.addValue("s" + column, row, row == 1 && column % 2 == 0 ? null : values[column]); + } + } + tablet.addValue(2, 4, -0.0f); + tablet.addValue(2, 5, -0.0d); + return tablet; + } +} diff --git a/pom.xml b/pom.xml index abd01e78010fc..ce545c989735e 100644 --- a/pom.xml +++ b/pom.xml @@ -143,7 +143,7 @@ 0.25.0 1.9 1.5.6-3 - 2.5.1-261023-SNAPSHOT + 2.5.1-SNAPSHOT en