You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/05/15 09:37:59 UTC

[GitHub] [iotdb] WilliamSong112 commented on a change in pull request #3175: [ISSUE-2742] A lighter InsertPlan for single data point insertion

WilliamSong112 commented on a change in pull request #3175:
URL: https://github.com/apache/iotdb/pull/3175#discussion_r632922742



##########
File path: server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java
##########
@@ -366,6 +415,87 @@ private void checkMemCostAndAddToTspInfo(InsertTabletPlan insertTabletPlan, int
     updateMemoryInfo(memTableIncrement, chunkMetadataIncrement, textDataIncrement);
   }
 
+  private void checkMemCostAndAddToTspInfo(InsertSinglePointPlan insertSinglePointPlan)
+      throws WriteProcessException {
+    // memory of increased PrimitiveArray and TEXT values, e.g., add a long[128], add 128*8
+    long memTableIncrement = 0L;
+    long textDataIncrement = 0L;
+    long chunkMetadataIncrement = 0L;
+    String deviceId = insertSinglePointPlan.getDeviceId().getFullPath();
+
+    if (workMemTable.checkIfChunkDoesNotExist(deviceId, insertSinglePointPlan.getMeasurement())) {
+      // ChunkMetadataIncrement
+      MeasurementMNode mnode = insertSinglePointPlan.getMeasurementMNode();
+      IMeasurementSchema schema = insertSinglePointPlan.getMeasurementMNode().getSchema();
+      if (schema.getType() == TSDataType.VECTOR) {
+        chunkMetadataIncrement +=
+            schema.getValueTSDataTypeList().size()
+                * ChunkMetadata.calculateRamSize(
+                    schema.getValueMeasurementIdList().get(0),
+                    schema.getValueTSDataTypeList().get(0));
+        memTableIncrement += TVList.vectorTvListArrayMemSize(schema.getValueTSDataTypeList());
+      } else {
+        chunkMetadataIncrement +=
+            ChunkMetadata.calculateRamSize(
+                insertSinglePointPlan.getMeasurement(), insertSinglePointPlan.getDataType());
+        memTableIncrement += TVList.tvListArrayMemSize(insertSinglePointPlan.getDataType());
+      }
+    } else {
+      // here currentChunkPointNum >= 1
+      int currentChunkPointNum =
+          workMemTable.getCurrentChunkPointNum(deviceId, insertSinglePointPlan.getMeasurement());
+      memTableIncrement +=
+          (currentChunkPointNum % PrimitiveArrayManager.ARRAY_SIZE) == 0
+              ? TVList.tvListArrayMemSize(insertSinglePointPlan.getDataType())
+              : 0;
+    }
+    // TEXT data mem size
+    if (insertSinglePointPlan.getDataType() == TSDataType.TEXT) {
+      textDataIncrement += MemUtils.getBinarySize((Binary) insertSinglePointPlan.getValue());
+    }
+    updateMemoryInfo(memTableIncrement, chunkMetadataIncrement, textDataIncrement);
+  }
+
+  private void checkMemcheckMemCostAndAddToTspInfoCostAndAddToTspInfo(
+      InsertTabletPlan insertTabletPlan, int start, int end) throws WriteProcessException {

Review comment:
       Thank you for your reply,This function is independent of insert single point。I've removed it




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org