This is an automated email from the ASF dual-hosted git repository. haonan pushed a commit to branch opt_aligned_tvlist in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit cdac597412baef19e75c35100cd73dc716563c61 Author: HTHou <[email protected]> AuthorDate: Fri Aug 22 17:32:45 2025 +0800 deving --- .../dataregion/memtable/TsFileProcessor.java | 13 ++++++++----- .../iotdb/db/utils/datastructure/AlignedTVList.java | 15 +++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/TsFileProcessor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/TsFileProcessor.java index 35651499b91..c66a0f7091e 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/TsFileProcessor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/memtable/TsFileProcessor.java @@ -788,7 +788,7 @@ public class TsFileProcessor { + (alignedMemChunk.alignedListSize() % PrimitiveArrayManager.ARRAY_SIZE > 0 ? 1 : 0); - memTableIncrement += currentArrayNum * AlignedTVList.valueListArrayMemCost(dataTypes[i]); + memTableIncrement += currentArrayNum * AlignedTVList.emptyValueListArrayMemCost(); } } // this insertion will result in a new array @@ -875,7 +875,7 @@ public class TsFileProcessor { ? 1 : 0); memTableIncrement += - currentArrayNum * AlignedTVList.valueListArrayMemCost(dataTypes[i]); + currentArrayNum * AlignedTVList.emptyValueListArrayMemCost(); } } int addingPointNum = addingPointNumInfo.right; @@ -1066,6 +1066,7 @@ public class TsFileProcessor { AlignedWritableMemChunk alignedMemChunk = (AlignedWritableMemChunk) memChunk; int currentPointNum = alignedMemChunk.alignedListSize(); int newPointNum = currentPointNum + incomingPointNum; + List<TSDataType> insertingTypes = new ArrayList<>(); for (int i = 0; i < dataTypes.length; i++) { TSDataType dataType = dataTypes[i]; String measurement = measurementIds[i]; @@ -1076,12 +1077,13 @@ public class TsFileProcessor { || (columnCategories != null && columnCategories[i] != TsTableColumnCategory.FIELD)) { continue; } + insertingTypes.add(dataType); if (!alignedMemChunk.containsMeasurement(measurementIds[i])) { // add a new column in the TVList, the new column should be as long as existing ones memIncrements[0] += (currentPointNum / PrimitiveArrayManager.ARRAY_SIZE + 1) - * AlignedTVList.valueListArrayMemCost(dataType); + * AlignedTVList.emptyValueListArrayMemCost(); } } @@ -1096,8 +1098,9 @@ public class TsFileProcessor { if (acquireArray != 0) { // memory of extending the TVList - memIncrements[0] += - acquireArray * alignedMemChunk.getWorkingTVList().alignedTvListArrayMemCost(); + memIncrements[0] += acquireArray * alignedMemChunk.getWorkingTVList().alignedTvListArrayMemCost(insertingTypes); + } else { + } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java index a4d967d1f93..00c171f136e 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java @@ -975,7 +975,7 @@ public abstract class AlignedTVList extends TVList { * * @return AlignedTvListArrayMemSize */ - public long alignedTvListArrayMemCost() { + public long alignedTvListArrayMemCost(List<TSDataType> insertingTypes) { long size = 0; // value & bitmap array mem size for (int column = 0; column < dataTypes.size(); column++) { @@ -1003,19 +1003,14 @@ public abstract class AlignedTVList extends TVList { } /** - * Get the single column array mem cost by give type. + * Get the single empty column array mem cost. * - * @param type the type of the value column - * @return valueListArrayMemCost + * @return emptyValueListArrayMemCost */ - public static long valueListArrayMemCost(TSDataType type) { + public static long emptyValueListArrayMemCost() { long size = 0; - // value array mem size - size += (long) PrimitiveArrayManager.ARRAY_SIZE * (long) type.getDataTypeSize(); // bitmap array mem size - size += (long) PrimitiveArrayManager.ARRAY_SIZE / 8 + 1; - // array headers mem size - size += NUM_BYTES_ARRAY_HEADER; + size += PrimitiveArrayManager.ARRAY_SIZE / 8 + 1; // Object references size in ArrayList size += NUM_BYTES_OBJECT_REF; return size;
