haimeiguo commented on a change in pull request #2571:
URL: https://github.com/apache/iotdb/pull/2571#discussion_r566652068



##########
File path: server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
##########
@@ -668,6 +666,23 @@ private TSExecuteStatementResp 
internalExecuteQueryStatement(String statement, l
     }
   }
 
+  /*
+  calculate fetch size for group by time plan
+   */
+  private int getFetchSizeForGroupByTimePlan(GroupByTimePlan groupByTimePlan) {
+    int rows =  (int) ((groupByTimePlan.getEndTime() - 
groupByTimePlan.getStartTime()) / groupByTimePlan
+        .getInterval());
+    // edge case for group by months when starttime is in February
+    // ie. time range = [2020-02-02, 2020-03-02), interval = 1mo, rows will 
get 0
+    if (rows == 0 && groupByTimePlan.isIntervalByMonth()) {
+      Calendar calendar = Calendar.getInstance();
+      calendar.setTimeInMillis(groupByTimePlan.getStartTime());
+      calendar.add(Calendar.MONTH, (int) (groupByTimePlan.getInterval() / 
MS_TO_MONTH));
+      rows = calendar.getTimeInMillis() <= groupByTimePlan.getEndTime() ? 1 : 
0;
+    }

Review comment:
       rounding down issue is mentioned on 
https://github.com/apache/iotdb/issues/2600




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to