You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/08/19 13:09:24 UTC

[iotdb] branch fix_tablet_timepartition created (now d4fd26e9e5)

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

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


      at d4fd26e9e5 Fix insert tablet time partition

This branch includes the following new commits:

     new d4fd26e9e5 Fix insert tablet time partition

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: Fix insert tablet time partition

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d4fd26e9e5e4241d542b57da2acd0a453669289b
Author: HTHou <hh...@outlook.com>
AuthorDate: Fri Aug 19 21:09:07 2022 +0800

    Fix insert tablet time partition
---
 .../planner/plan/node/write/InsertTabletNode.java  | 46 ++++++++++------------
 1 file changed, 20 insertions(+), 26 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertTabletNode.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertTabletNode.java
index 1a660edc7b..e67096acef 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertTabletNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertTabletNode.java
@@ -236,25 +236,20 @@ public class InsertTabletNode extends InsertNode implements WALEntryValue {
       // generate a new times and values
       locs = entry.getValue();
       // Avoid using system arraycopy when there is no need to split
-      if (splitMap.size() == 1) {
+      if (splitMap.size() == 1 && locs.size() == 1) {
         setRange(locs);
         setDataRegionReplicaSet(entry.getKey());
         result.add(this);
         return result;
       }
-      int count = 0;
-      for (int i = 0; i < locs.size(); i += 2) {
-        int start = locs.get(i);
-        int end = locs.get(i + 1);
-        count += end - start;
-      }
-      long[] subTimes = new long[count];
-      int destLoc = 0;
-      Object[] values = initTabletValues(dataTypes.length, count, dataTypes);
-      BitMap[] bitMaps = this.bitMaps == null ? null : initBitmaps(dataTypes.length, count);
       for (int i = 0; i < locs.size(); i += 2) {
         int start = locs.get(i);
         int end = locs.get(i + 1);
+        int count = end - start;
+        long[] subTimes = new long[count];
+        int destLoc = 0;
+        Object[] values = initTabletValues(dataTypes.length, count, dataTypes);
+        BitMap[] bitMaps = this.bitMaps == null ? null : initBitmaps(dataTypes.length, count);
         System.arraycopy(times, start, subTimes, destLoc, end - start);
         for (int k = 0; k < values.length; k++) {
           System.arraycopy(columns[k], start, values[k], destLoc, end - start);
@@ -262,22 +257,21 @@ public class InsertTabletNode extends InsertNode implements WALEntryValue {
             BitMap.copyOfRange(this.bitMaps[k], start, bitMaps[k], destLoc, end - start);
           }
         }
-        destLoc += end - start;
+        InsertTabletNode subNode =
+            new InsertTabletNode(
+                getPlanNodeId(),
+                devicePath,
+                isAligned,
+                measurements,
+                dataTypes,
+                subTimes,
+                bitMaps,
+                values,
+                subTimes.length);
+        subNode.setRange(locs);
+        subNode.setDataRegionReplicaSet(entry.getKey());
+        result.add(subNode);
       }
-      InsertTabletNode subNode =
-          new InsertTabletNode(
-              getPlanNodeId(),
-              devicePath,
-              isAligned,
-              measurements,
-              dataTypes,
-              subTimes,
-              bitMaps,
-              values,
-              subTimes.length);
-      subNode.setRange(locs);
-      subNode.setDataRegionReplicaSet(entry.getKey());
-      result.add(subNode);
     }
     return result;
   }