JackieTien97 commented on code in PR #11290:
URL: https://github.com/apache/iotdb/pull/11290#discussion_r1361748574
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/AggrWindowIterator.java:
##########
@@ -36,6 +34,10 @@ public class AggrWindowIterator implements
ITimeRangeIterator {
private final long endTime;
private final long interval;
private final long slidingStep;
+ private final long fixedIntervalInMonth;
+ private final long fixedSlidingStepInMonth;
Review Comment:
does these two duplicated with the previous `interval` and `slidingStep`.
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/DateTimeUtils.java:
##########
@@ -733,6 +741,7 @@ public static TimeUnit toTimeUnit(String t) {
* @return nextStartTime
*/
public static long calcIntervalByMonth(long startTime, long numMonths) {
+ numMonths = numMonths / MS_TO_MONTH;
Review Comment:
why we need this line? numMonths shouldn't divide `MS_TO_MONTH` again.
##########
iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/GroupByMonthFilter.java:
##########
@@ -255,32 +325,47 @@ private long getTimePointPosition(long time) {
private void getNthTimeInterval(long n) {
// get start time of time interval
if (isSlidingStepByMonth) {
- calendar.setTimeInMillis(initialStartTime);
- calendar.add(Calendar.MONTH, (int) (slidingStepsInMo * n));
+ if (fixedSlidingStepOther == 0) {
+ this.startTime = calcIntervalByMonth(initialStartTime,
slidingStepsInMo * n);
+ } else {
+ this.startTime = timeArray[(int) n];
+ }
} else {
- calendar.setTimeInMillis(initialStartTime + slidingStep * n);
+ this.startTime = initialStartTime + slidingStep * n;
}
- this.startTime = calendar.getTimeInMillis();
// get interval and sliding step
if (isIntervalByMonth) {
- if (isSlidingStepByMonth) {
- calendar.setTimeInMillis(initialStartTime);
- calendar.add(Calendar.MONTH, (int) (slidingStepsInMo * n) +
intervalInMo);
- } else {
- calendar.add(Calendar.MONTH, intervalInMo);
- }
- this.interval = calendar.getTimeInMillis() - startTime;
+ this.interval =
+ calcIntervalByMonthWithFixedOther(startTime, intervalInMo,
fixedIntervalOther)
+ - startTime;
}
if (isSlidingStepByMonth) {
- calendar.setTimeInMillis(initialStartTime);
- calendar.add(Calendar.MONTH, (int) (slidingStepsInMo * (n + 1)));
- this.slidingStep = calendar.getTimeInMillis() - startTime;
+ this.slidingStep =
+ calcIntervalByMonthWithFixedOther(startTime, slidingStepsInMo,
fixedSlidingStepOther)
+ - startTime;
}
}
@Override
public FilterSerializeId getSerializeId() {
return FilterSerializeId.GROUP_BY_MONTH;
}
+
+ private long calcIntervalByMonth(long startTime, long numMonths) {
+ calendar.setTimeInMillis(startTime);
+ boolean isLastDayOfMonth =
+ calendar.get(Calendar.DAY_OF_MONTH) ==
calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
+ calendar.add(Calendar.MONTH, (int) (numMonths));
+ if (isLastDayOfMonth) {
+ calendar.set(Calendar.DAY_OF_MONTH,
calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+ }
+ return calendar.getTimeInMillis();
+ }
+
+ private long calcIntervalByMonthWithFixedOther(
+ long startTime, long fixedMonths, long fixedOther) {
+ long nextStartTime = calcIntervalByMonth(startTime, fixedMonths);
+ return nextStartTime + fixedOther;
+ }
Review Comment:
why not directly use the method in `DateTimeUtils`
##########
iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/GroupByMonthFilter.java:
##########
@@ -38,6 +38,12 @@ public class GroupByMonthFilter extends GroupByFilter {
private int slidingStepsInMo;
private int intervalInMo;
+
+ private long fixedIntervalOther;
+ private long fixedSlidingStepOther;
+ private long[] timeArray;
+ private int arraySize;
Review Comment:
we should judge it dynamicly.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]