This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch aligned_insert_npe
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 75c7eae063e5cc3959bb678c757be144dd09db79
Author: HTHou <[email protected]>
AuthorDate: Tue Jan 4 18:16:24 2022 +0800

    Fix npe when insert wrong type data into aligned timeseries
---
 .../apache/iotdb/db/utils/datastructure/AlignedTVList.java | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git 
a/server/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java
 
b/server/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java
index 6f42171..c010d38 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java
@@ -857,14 +857,20 @@ public class AlignedTVList extends TVList {
    */
   public static long alignedTvListArrayMemCost(TSDataType[] types) {
     long size = 0;
+    // value array mem size
+    for (TSDataType type : types) {
+      if (type != null) {
+        size += (long) PrimitiveArrayManager.ARRAY_SIZE * (long) 
type.getDataTypeSize();
+      }
+    }
+    // size is 0 when all types are null
+    if (size == 0) {
+      return size;
+    }
     // time array mem size
     size += (long) PrimitiveArrayManager.ARRAY_SIZE * 8L;
     // index array mem size
     size += (long) PrimitiveArrayManager.ARRAY_SIZE * 4L;
-    // value array mem size
-    for (TSDataType type : types) {
-      size += (long) PrimitiveArrayManager.ARRAY_SIZE * (long) 
type.getDataTypeSize();
-    }
     // array headers mem size
     size += NUM_BYTES_ARRAY_HEADER * (2 + types.length);
     // Object references size in ArrayList

Reply via email to