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 2022/05/06 02:14:02 UTC

[iotdb] 01/02: push down limit to rawdatasetwithValueFilter

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

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

commit a2ef166d9d9ca04a69e0c418e0c3e021ac187451
Author: Alima777 <wx...@gmail.com>
AuthorDate: Sat Apr 23 16:59:45 2022 +0800

    push down limit to rawdatasetwithValueFilter
---
 .../iotdb/db/query/dataset/RawQueryDataSetWithValueFilter.java       | 5 +++--
 server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java  | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/query/dataset/RawQueryDataSetWithValueFilter.java b/server/src/main/java/org/apache/iotdb/db/query/dataset/RawQueryDataSetWithValueFilter.java
index 3e71d2a512..754edb7827 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/dataset/RawQueryDataSetWithValueFilter.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/dataset/RawQueryDataSetWithValueFilter.java
@@ -87,10 +87,11 @@ public class RawQueryDataSetWithValueFilter extends QueryDataSet implements UDFI
    */
   private boolean cacheRowRecords() throws IOException {
     int cachedTimeCnt = 0;
-    long[] cachedTimeArray = new long[fetchSize];
+    int timeArraySize = rowLimit > 0 ? Math.min(fetchSize, rowLimit + rowOffset) : fetchSize;
+    long[] cachedTimeArray = new long[timeArraySize];
     // TODO: LIMIT constraint
     // 1. fill time array from time Generator
-    while (timeGenerator.hasNext() && cachedTimeCnt < fetchSize) {
+    while (timeGenerator.hasNext() && cachedTimeCnt < timeArraySize) {
       cachedTimeArray[cachedTimeCnt++] = timeGenerator.next();
     }
     if (cachedTimeCnt == 0) {
diff --git a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
index 92bc3c5df6..7614b48fbb 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
@@ -249,7 +249,6 @@ public class TSServiceImpl implements TSIService.Iface {
 
     @Override
     public TSExecuteStatementResp call() throws Exception {
-      queryCount.incrementAndGet();
       AUDIT_LOGGER.debug(
           "Session {} execute Query: {}", sessionManager.getCurrSessionId(), statement);
       long startTime = System.currentTimeMillis();
@@ -804,6 +803,7 @@ public class TSServiceImpl implements TSIService.Iface {
       PhysicalPlan physicalPlan =
           processor.rawDataQueryReqToPhysicalPlan(req, sessionManager.getZoneId(req.sessionId));
       if (physicalPlan.isQuery()) {
+        queryCount.incrementAndGet();
         Future<TSExecuteStatementResp> resp =
             QueryTaskManager.getInstance()
                 .submit(
@@ -833,6 +833,7 @@ public class TSServiceImpl implements TSIService.Iface {
 
   private TSExecuteStatementResp submitQueryTask(
       PhysicalPlan physicalPlan, TSExecuteStatementReq req) throws Exception {
+    queryCount.incrementAndGet();
     QueryTask queryTask =
         new QueryTask(
             physicalPlan,