You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2023/03/22 12:25:35 UTC

[iotdb] branch IOTDB-5715 created (now 794ac4c83c)

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

jackietien pushed a change to branch IOTDB-5715
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 794ac4c83c [IOTDB-5715] Improve the performance of query order by time desc

This branch includes the following new commits:

     new 794ac4c83c [IOTDB-5715] Improve the performance of query order by time desc

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: [IOTDB-5715] Improve the performance of query order by time desc

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

jackietien pushed a commit to branch IOTDB-5715
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 794ac4c83cd800730b82e689dc2e1b681c85c420
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Wed Mar 22 20:17:43 2023 +0800

    [IOTDB-5715] Improve the performance of query order by time desc
---
 .../execution/operator/process/join/RowBasedTimeJoinOperator.java   | 6 +++++-
 .../execution/operator/process/join/merge/AscTimeComparator.java    | 5 +++++
 .../execution/operator/process/join/merge/DescTimeComparator.java   | 5 +++++
 .../mpp/execution/operator/process/join/merge/TimeComparator.java   | 3 +++
 4 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/RowBasedTimeJoinOperator.java b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/RowBasedTimeJoinOperator.java
index 0cc36c5e51..cba7ce8263 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/RowBasedTimeJoinOperator.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/RowBasedTimeJoinOperator.java
@@ -33,6 +33,8 @@ import org.apache.iotdb.tsfile.read.common.block.TsBlockBuilder;
 import org.apache.iotdb.tsfile.read.common.block.column.TimeColumnBuilder;
 
 import com.google.common.util.concurrent.ListenableFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -42,6 +44,8 @@ import static com.google.common.util.concurrent.Futures.successfulAsList;
 
 public class RowBasedTimeJoinOperator extends AbstractConsumeAllOperator {
 
+  private static final Logger LOGGER = LoggerFactory.getLogger(RowBasedTimeJoinOperator.class);
+
   /** start index for each input TsBlocks and size of it is equal to inputTsBlocks */
   private final int[] inputIndex;
 
@@ -177,7 +181,7 @@ public class RowBasedTimeJoinOperator extends AbstractConsumeAllOperator {
         }
       }
       tsBlockBuilder.declarePosition();
-    } while (currentTime < currentEndTime && !timeSelector.isEmpty());
+    } while (comparator.canContinue(currentTime, currentEndTime) && !timeSelector.isEmpty());
 
     resultTsBlock = tsBlockBuilder.build();
     return checkTsBlockSizeAndGetResult();
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/merge/AscTimeComparator.java b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/merge/AscTimeComparator.java
index 96d9f86f59..e458b4aff3 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/merge/AscTimeComparator.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/merge/AscTimeComparator.java
@@ -30,4 +30,9 @@ public class AscTimeComparator implements TimeComparator {
   public long getCurrentEndTime(long time1, long time2) {
     return Math.min(time1, time2);
   }
+
+  @Override
+  public boolean canContinue(long time, long endTime) {
+    return time < endTime;
+  }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/merge/DescTimeComparator.java b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/merge/DescTimeComparator.java
index 67c0112dab..e13661823d 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/merge/DescTimeComparator.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/merge/DescTimeComparator.java
@@ -30,4 +30,9 @@ public class DescTimeComparator implements TimeComparator {
   public long getCurrentEndTime(long time1, long time2) {
     return Math.max(time1, time2);
   }
+
+  @Override
+  public boolean canContinue(long time, long endTime) {
+    return time > endTime;
+  }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/merge/TimeComparator.java b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/merge/TimeComparator.java
index 47eff4fe08..846af9810d 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/merge/TimeComparator.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/join/merge/TimeComparator.java
@@ -25,4 +25,7 @@ public interface TimeComparator {
 
   /** @return min(time1, time2) if order by time asc, max(time1, time2) if order by desc */
   long getCurrentEndTime(long time1, long time2);
+
+  /** @return time < endTime if order by time asc, time > endTime if order by desc */
+  boolean canContinue(long time, long endTime);
 }