You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xi...@apache.org on 2021/03/14 04:49:35 UTC

[iotdb] branch clusterQueryOpt updated: optimize agg result 2

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

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


The following commit(s) were added to refs/heads/clusterQueryOpt by this push:
     new 1c18ddf  optimize agg result 2
1c18ddf is described below

commit 1c18ddfe6dd1458ab40c5be62f5c412fff78c33d
Author: Alima777 <wx...@gmail.com>
AuthorDate: Sun Mar 14 12:49:01 2021 +0800

    optimize agg result 2
---
 .../iotdb/db/query/aggregation/impl/FirstValueAggrResult.java    | 9 +++++----
 .../iotdb/db/query/aggregation/impl/LastValueDescAggrResult.java | 8 +++++---
 .../iotdb/db/query/aggregation/impl/MaxTimeDescAggrResult.java   | 6 ++++--
 .../iotdb/db/query/aggregation/impl/MinTimeAggrResult.java       | 6 ++++--
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/FirstValueAggrResult.java b/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/FirstValueAggrResult.java
index 3aacbf9..6703c7e 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/FirstValueAggrResult.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/FirstValueAggrResult.java
@@ -94,11 +94,12 @@ public class FirstValueAggrResult extends AggregateResult {
     if (hasFinalResult()) {
       return;
     }
-
-    Object[] values = dataReader.getValuesInTimestamps(timestamps, length);
     for (int i = 0; i < length; i++) {
-      if (values[i] != null) {
-        setValue(values[i]);
+      long[] oneTimestamp = new long[1];
+      oneTimestamp[0] = timestamps[i];
+      Object[] values = dataReader.getValuesInTimestamps(oneTimestamp, 1);
+      if (values[0] != null) {
+        setValue(values[0]);
         timestamp = timestamps[i];
         break;
       }
diff --git a/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/LastValueDescAggrResult.java b/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/LastValueDescAggrResult.java
index 8cdeaed..d236eab 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/LastValueDescAggrResult.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/LastValueDescAggrResult.java
@@ -68,11 +68,13 @@ public class LastValueDescAggrResult extends LastValueAggrResult {
     if (hasFinalResult()) {
       return;
     }
-    Object[] values = dataReader.getValuesInTimestamps(timestamps, length);
     for (int i = 0; i < length; i++) {
-      if (values[i] != null) {
+      long[] oneTimestamp = new long[1];
+      oneTimestamp[0] = timestamps[i];
+      Object[] values = dataReader.getValuesInTimestamps(oneTimestamp, 1);
+      if (values[0] != null) {
         timestamp = timestamps[i];
-        setValue(values[i]);
+        setValue(values[0]);
         return;
       }
     }
diff --git a/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/MaxTimeDescAggrResult.java b/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/MaxTimeDescAggrResult.java
index 82d6c4e..a5c4e47 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/MaxTimeDescAggrResult.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/MaxTimeDescAggrResult.java
@@ -52,9 +52,11 @@ public class MaxTimeDescAggrResult extends MaxTimeAggrResult {
     if (hasFinalResult()) {
       return;
     }
-    Object[] values = dataReader.getValuesInTimestamps(timestamps, length);
     for (int i = 0; i < length; i++) {
-      if (values[i] != null) {
+      long[] oneTimestamp = new long[1];
+      oneTimestamp[0] = timestamps[i];
+      Object[] values = dataReader.getValuesInTimestamps(oneTimestamp, 1);
+      if (values[0] != null) {
         updateMaxTimeResult(timestamps[i]);
         return;
       }
diff --git a/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/MinTimeAggrResult.java b/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/MinTimeAggrResult.java
index bd96043..3864c08 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/MinTimeAggrResult.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/aggregation/impl/MinTimeAggrResult.java
@@ -74,9 +74,11 @@ public class MinTimeAggrResult extends AggregateResult {
     if (hasFinalResult()) {
       return;
     }
-    Object[] values = dataReader.getValuesInTimestamps(timestamps, length);
     for (int i = 0; i < length; i++) {
-      if (values[i] != null) {
+      long[] oneTimestamp = new long[1];
+      oneTimestamp[0] = timestamps[i];
+      Object[] values = dataReader.getValuesInTimestamps(oneTimestamp, 1);
+      if (values[0] != null) {
         setLongValue(timestamps[i]);
         return;
       }