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

rong pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/dev/1.3 by this push:
     new c2626c04d9a [To dev/1.3] Pipe: Fix the null pointer and unreasonable 
default Empty LocalDate caused by TabletInsertionDataContainer (related to 
#13990) (related to #14014) (#14025)
c2626c04d9a is described below

commit c2626c04d9a58900401628b8fbefd77d45eb5972
Author: Zhenyu Luo <[email protected]>
AuthorDate: Fri Nov 8 17:23:15 2024 +0800

    [To dev/1.3] Pipe: Fix the null pointer and unreasonable default Empty 
LocalDate caused by TabletInsertionDataContainer (related to #13990) (related 
to #14014) (#14025)
---
 .../tablet/TabletInsertionDataContainer.java       | 71 +++++++++++++++++++---
 1 file changed, 63 insertions(+), 8 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tablet/TabletInsertionDataContainer.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tablet/TabletInsertionDataContainer.java
index 747962fdd03..ae3925ac95f 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tablet/TabletInsertionDataContainer.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tablet/TabletInsertionDataContainer.java
@@ -59,6 +59,8 @@ public class TabletInsertionDataContainer {
 
   private static final Logger LOGGER = 
LoggerFactory.getLogger(TabletInsertionDataContainer.class);
 
+  private static final LocalDate EMPTY_LOCALDATE = LocalDate.of(1000, 1, 1);
+
   private final PipeTaskMeta pipeTaskMeta; // used to report progress
   private final EnrichedEvent
       sourceEvent; // used to report progress and filter value columns by time 
range
@@ -174,8 +176,12 @@ public class TabletInsertionDataContainer {
         this.valueColumnTypes[filteredColumnIndex] = originValueColumnTypes[i];
         final BitMap bitMap = new BitMap(this.timestampColumn.length);
         if (Objects.isNull(originValueColumns[i]) || 
Objects.isNull(originValueColumnTypes[i])) {
-          this.valueColumns[filteredColumnIndex] = null;
-          bitMap.markAll();
+          fillNullValue(
+              originValueColumnTypes[i],
+              this.valueColumns,
+              bitMap,
+              filteredColumnIndex,
+              rowIndexList.size());
         } else {
           this.valueColumns[filteredColumnIndex] =
               filterValueColumnsByRowIndexList(
@@ -257,8 +263,12 @@ public class TabletInsertionDataContainer {
         this.valueColumnTypes[filteredColumnIndex] = originValueColumnTypes[i];
         final BitMap bitMap = new BitMap(this.timestampColumn.length);
         if (Objects.isNull(originValueColumns[i]) || 
Objects.isNull(originValueColumnTypes[i])) {
-          this.valueColumns[filteredColumnIndex] = null;
-          bitMap.markAll();
+          fillNullValue(
+              originValueColumnTypes[i],
+              this.valueColumns,
+              bitMap,
+              filteredColumnIndex,
+              rowIndexList.size());
         } else {
           this.valueColumns[filteredColumnIndex] =
               filterValueColumnsByRowIndexList(
@@ -348,8 +358,12 @@ public class TabletInsertionDataContainer {
         this.valueColumnTypes[filteredColumnIndex] = originValueColumnTypes[i];
         final BitMap bitMap = new BitMap(this.timestampColumn.length);
         if (Objects.isNull(originValueColumns[i]) || 
Objects.isNull(originValueColumnTypes[i])) {
-          this.valueColumns[filteredColumnIndex] = null;
-          bitMap.markAll();
+          fillNullValue(
+              originValueColumnTypes[i],
+              this.valueColumns,
+              bitMap,
+              filteredColumnIndex,
+              rowIndexList.size());
         } else {
           this.valueColumns[filteredColumnIndex] =
               filterValueColumnsByRowIndexList(
@@ -479,7 +493,7 @@ public class TabletInsertionDataContainer {
 
             for (int i = 0; i < rowIndexList.size(); ++i) {
               if (originNullValueColumnBitmap.isMarked(rowIndexList.get(i))) {
-                valueColumns[i] = LocalDate.MIN;
+                valueColumns[i] = EMPTY_LOCALDATE;
                 nullValueColumnBitmap.mark(i);
               } else {
                 valueColumns[i] = dateValueColumns[rowIndexList.get(i)];
@@ -493,7 +507,7 @@ public class TabletInsertionDataContainer {
                     : (int[]) originValueColumn;
             for (int i = 0; i < rowIndexList.size(); ++i) {
               if (originNullValueColumnBitmap.isMarked(rowIndexList.get(i))) {
-                valueColumns[i] = LocalDate.MIN;
+                valueColumns[i] = EMPTY_LOCALDATE;
                 nullValueColumnBitmap.mark(i);
               } else {
                 valueColumns[i] =
@@ -599,6 +613,47 @@ public class TabletInsertionDataContainer {
     }
   }
 
+  private void fillNullValue(
+      final TSDataType type,
+      final Object[] valueColumns,
+      final BitMap nullValueColumnBitmap,
+      final int columnIndex,
+      final int rowSize) {
+    nullValueColumnBitmap.markAll();
+    if (Objects.isNull(type)) {
+      return;
+    }
+    switch (type) {
+      case TIMESTAMP:
+      case INT64:
+        valueColumns[columnIndex] = new long[rowSize];
+        break;
+      case INT32:
+        valueColumns[columnIndex] = new int[rowSize];
+        break;
+      case DOUBLE:
+        valueColumns[columnIndex] = new double[rowSize];
+        break;
+      case FLOAT:
+        valueColumns[columnIndex] = new float[rowSize];
+        break;
+      case BOOLEAN:
+        valueColumns[columnIndex] = new boolean[rowSize];
+        break;
+      case DATE:
+        valueColumns[columnIndex] = new LocalDate[rowSize];
+        break;
+      case TEXT:
+      case BLOB:
+      case STRING:
+        valueColumns[columnIndex] = new Binary[rowSize];
+        break;
+      default:
+        throw new UnSupportedDataTypeException(
+            String.format("Data type %s is not supported.", type));
+    }
+  }
+
   ////////////////////////////  process  ////////////////////////////
 
   public List<TabletInsertionEvent> processRowByRow(final BiConsumer<Row, 
RowCollector> consumer) {

Reply via email to