Skip to content

Commit b9fdccd

Browse files
committed
Merge branch 'backport-pipe-optimize-memory-17770' of https://github.com/Caideyipi/iotdb into backport-pipe-optimize-memory-17770
2 parents fd434de + fe41c79 commit b9fdccd

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/payload/evolvable/batch/PipeTabletEventTsFileBatch.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.iotdb.db.exception.DiskSpaceInsufficientException;
2525
import org.apache.iotdb.db.pipe.event.common.tablet.PipeInsertNodeTabletInsertionEvent;
2626
import org.apache.iotdb.db.pipe.event.common.tablet.PipeRawTabletInsertionEvent;
27+
import org.apache.iotdb.db.pipe.event.common.tablet.PipeTabletUtils;
2728
import org.apache.iotdb.db.pipe.resource.memory.PipeMemoryWeightUtil;
2829
import org.apache.iotdb.db.pipe.sink.util.PipeTabletEventSorter;
2930
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNodeId;
@@ -361,7 +362,7 @@ private Tablet tryBestToAggregateTablets(
361362
// Aggregate the current tablet's data
362363
aggregatedSchemas.addAll(tablet.getSchemas());
363364
aggregatedValues.addAll(Arrays.asList(tablet.values));
364-
aggregatedBitMaps.addAll(Arrays.asList(tablet.bitMaps));
365+
aggregatedBitMaps.addAll(Arrays.asList(PipeTabletUtils.copyBitMapsOrCreateEmpty(tablet)));
365366
// Remove the aggregated tablet
366367
tablets.pollFirst();
367368
} else {
@@ -563,7 +564,7 @@ private void writeTabletsIntoOneFile(
563564
.map(schema -> (MeasurementSchema) schema)
564565
.toArray(MeasurementSchema[]::new);
565566
Object[] values = Arrays.copyOf(tablet.values, tablet.values.length);
566-
BitMap[] bitMaps = Arrays.copyOf(tablet.bitMaps, tablet.bitMaps.length);
567+
BitMap[] bitMaps = PipeTabletUtils.copyBitMapsOrCreateEmpty(tablet);
567568

568569
// convert date value to int refer to
569570
// org.apache.iotdb.db.storageengine.dataregion.memtable.WritableMemChunk.writeNonAlignedTablet

iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/event/common/tablet/PipeTabletUtilsTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.apache.iotdb.db.pipe.event.common.tablet;
2121

2222
import org.apache.tsfile.enums.TSDataType;
23+
import org.apache.tsfile.utils.BitMap;
2324
import org.apache.tsfile.write.record.Tablet;
2425
import org.apache.tsfile.write.schema.MeasurementSchema;
2526
import org.junit.Assert;
@@ -48,4 +49,24 @@ public void testPutValueUnmarksReusedNullRow() {
4849
Assert.assertNull(tablet.bitMaps[0]);
4950
Assert.assertTrue(tablet.bitMaps[1].isMarked(0));
5051
}
52+
53+
@Test
54+
public void testCopyBitMapsOrCreateEmptyWithNullBitMaps() {
55+
final List<MeasurementSchema> schemas =
56+
Arrays.asList(
57+
new MeasurementSchema("s1", TSDataType.FLOAT),
58+
new MeasurementSchema("s2", TSDataType.FLOAT));
59+
final Tablet tablet = new Tablet("root.sg.d1", schemas, 2);
60+
tablet.addTimestamp(0, 1L);
61+
tablet.addValue("s1", 0, 1.0f);
62+
tablet.addValue("s2", 0, 2.0f);
63+
64+
Assert.assertNull(tablet.bitMaps);
65+
66+
final BitMap[] bitMaps = PipeTabletUtils.copyBitMapsOrCreateEmpty(tablet);
67+
68+
Assert.assertEquals(schemas.size(), bitMaps.length);
69+
Assert.assertNull(bitMaps[0]);
70+
Assert.assertNull(bitMaps[1]);
71+
}
5172
}

0 commit comments

Comments
 (0)