diff --git a/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java b/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java index 8fd0a179063c7..87563aa9ac6d5 100644 --- a/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java +++ b/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java @@ -88,7 +88,7 @@ public abstract class AbstractCli { static final int CODE_ERROR = 1; static final String ISO8601_ARGS = "disableISO8601"; - static final List AGGREGRATE_TIME_LIST = new ArrayList<>(); + static final List AGGREGATE_TIME_LIST = new ArrayList<>(); static final String RPC_COMPRESS_ARGS = "c"; private static final String RPC_COMPRESS_NAME = "rpcCompressed"; static final String TIMEOUT_ARGS = "timeout"; diff --git a/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/Cli.java b/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/Cli.java index b34cfe249c4a6..dce105207c3fc 100644 --- a/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/Cli.java +++ b/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/Cli.java @@ -185,7 +185,7 @@ private static void executeSql(CliContext ctx) throws TException { connection.setQueryTimeout(queryTimeout); properties = connection.getServerProperties(); timestampPrecision = properties.getTimestampPrecision(); - AGGREGRATE_TIME_LIST.addAll(properties.getSupportedTimeAggregationOperations()); + AGGREGATE_TIME_LIST.addAll(properties.getSupportedTimeAggregationOperations()); processCommand(ctx, execute, connection); ctx.exit(lastProcessStatus); } catch (SQLException e) { @@ -200,7 +200,7 @@ private static void receiveCommands(CliContext ctx) throws TException { DriverManager.getConnection(Config.IOTDB_URL_PREFIX + host + ":" + port + "/", info)) { connection.setQueryTimeout(queryTimeout); properties = connection.getServerProperties(); - AGGREGRATE_TIME_LIST.addAll(properties.getSupportedTimeAggregationOperations()); + AGGREGATE_TIME_LIST.addAll(properties.getSupportedTimeAggregationOperations()); timestampPrecision = properties.getTimestampPrecision(); echoStarting(ctx); diff --git a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 index efe661e05430c..c7ef6cae032fe 100644 --- a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 +++ b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 @@ -973,6 +973,7 @@ number timeRange : LS_BRACKET startTime=timeValue COMMA endTime=timeValue RR_BRACKET | LR_BRACKET startTime=timeValue COMMA endTime=timeValue RS_BRACKET + | LS_BRACKET startTime=timeValue COMMA endTime=timeValue RS_BRACKET ; // ---- Having Clause diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/AggrWindowIterator.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/AggrWindowIterator.java index e9847f814cff4..c0b7eea9a142e 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/AggrWindowIterator.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/AggrWindowIterator.java @@ -42,6 +42,7 @@ public class AggrWindowIterator implements ITimeRangeIterator { private final boolean isAscending; private final boolean leftCRightO; + private final boolean rightClosed; private TimeRange curTimeRange; private boolean hasCachedTimeRange; @@ -58,6 +59,7 @@ public AggrWindowIterator( TimeDuration slidingStep, boolean isAscending, boolean leftCRightO, + boolean rightClosed, ZoneId zoneId) { this.startTime = startTime; this.endTime = endTime; @@ -65,6 +67,7 @@ public AggrWindowIterator( this.slidingStep = slidingStep; this.isAscending = isAscending; this.leftCRightO = leftCRightO; + this.rightClosed = rightClosed; this.timeRangeCount = 0; this.zoneId = zoneId; } @@ -157,7 +160,7 @@ public boolean hasNextTimeRange() { } else { retStartTime = curStartTime + slidingStep.nonMonthDuration; } - // This is an open interval , [0-100) + // This is an open interval, [0-100) if (retStartTime >= endTime) { return false; } @@ -197,6 +200,21 @@ public TimeRange nextTimeRange() { return null; } + @Override + public TimeRange getFinalTimeRange(TimeRange timeRange, boolean leftCRightO) { + // For rightClosed intervals ending at endTime, preserve the right boundary + if (rightClosed && timeRange.getMax() == endTime) { + // Still need to adjust left boundary if leftCRightO is false + return leftCRightO + ? timeRange // [start, end] - no adjustment needed + : new TimeRange(timeRange.getMin() + 1, timeRange.getMax()); // (start, end] + } + // Standard adjustment for non-end windows + return leftCRightO + ? new TimeRange(timeRange.getMin(), timeRange.getMax() - 1) + : new TimeRange(timeRange.getMin() + 1, timeRange.getMax()); + } + @Override public boolean isAscending() { return isAscending; diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/PreAggrWindowIterator.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/PreAggrWindowIterator.java index df07e15d032ef..46fc2fc26b710 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/PreAggrWindowIterator.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/PreAggrWindowIterator.java @@ -36,6 +36,7 @@ public class PreAggrWindowIterator implements ITimeRangeIterator { private final boolean isAscending; private final boolean leftCRightO; + private final boolean rightClosed; private long curInterval; private long curSlidingStep; @@ -51,13 +52,15 @@ public PreAggrWindowIterator( long interval, long slidingStep, boolean isAscending, - boolean leftCRightO) { + boolean leftCRightO, + boolean rightClosed) { this.startTime = startTime; this.endTime = endTime; this.interval = interval; this.slidingStep = slidingStep; this.isAscending = isAscending; this.leftCRightO = leftCRightO; + this.rightClosed = rightClosed; initIntervalAndStep(); } @@ -132,6 +135,21 @@ public TimeRange nextTimeRange() { return null; } + @Override + public TimeRange getFinalTimeRange(TimeRange timeRange, boolean leftCRightO) { + // For rightClosed intervals ending at endTime, preserve the right boundary + if (rightClosed && timeRange.getMax() == endTime) { + // Still need to adjust left boundary if leftCRightO is false + return leftCRightO + ? timeRange // [start, end] - no adjustment needed + : new TimeRange(timeRange.getMin() + 1, timeRange.getMax()); // (start, end] + } + // Standard adjustment for non-end windows + return leftCRightO + ? new TimeRange(timeRange.getMin(), timeRange.getMax() - 1) + : new TimeRange(timeRange.getMin() + 1, timeRange.getMax()); + } + private void initIntervalAndStep() { if (slidingStep >= interval) { curInterval = interval; diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/PreAggrWindowWithNaturalMonthIterator.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/PreAggrWindowWithNaturalMonthIterator.java index a4a0aa6261143..43ad7b5953948 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/PreAggrWindowWithNaturalMonthIterator.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/PreAggrWindowWithNaturalMonthIterator.java @@ -32,6 +32,7 @@ public class PreAggrWindowWithNaturalMonthIterator implements ITimeRangeIterator private final boolean isAscending; private final boolean leftCRightO; + private final boolean rightClosed; private final TimeSelector timeBoundaryHeap; private final AggrWindowIterator aggrWindowIterator; @@ -49,12 +50,21 @@ public PreAggrWindowWithNaturalMonthIterator( TimeDuration slidingStep, boolean isAscending, boolean leftCRightO, + boolean rightClosed, ZoneId zoneId) { this.isAscending = isAscending; + this.rightClosed = rightClosed; this.timeBoundaryHeap = new TimeSelector(HEAP_MAX_SIZE, isAscending); this.aggrWindowIterator = new AggrWindowIterator( - startTime, endTime, interval, slidingStep, isAscending, leftCRightO, zoneId); + startTime, + endTime, + interval, + slidingStep, + isAscending, + leftCRightO, + rightClosed, + zoneId); this.leftCRightO = leftCRightO; initHeap(); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/TimeRangeIteratorFactory.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/TimeRangeIteratorFactory.java index 7331971b4a6e4..b253cd149572f 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/TimeRangeIteratorFactory.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/TimeRangeIteratorFactory.java @@ -42,6 +42,7 @@ public static ITimeRangeIterator getTimeRangeIterator( TimeDuration slidingStep, boolean isAscending, boolean leftCRightO, + boolean rightClosed, boolean outputPartialTimeWindow, ZoneId zoneId) { if (outputPartialTimeWindow @@ -54,14 +55,22 @@ public static ITimeRangeIterator getTimeRangeIterator( interval.nonMonthDuration, slidingStep.nonMonthDuration, isAscending, - leftCRightO); + leftCRightO, + rightClosed); } else { return new PreAggrWindowWithNaturalMonthIterator( - startTime, endTime, interval, slidingStep, isAscending, leftCRightO, zoneId); + startTime, + endTime, + interval, + slidingStep, + isAscending, + leftCRightO, + rightClosed, + zoneId); } } else { return new AggrWindowIterator( - startTime, endTime, interval, slidingStep, isAscending, leftCRightO, zoneId); + startTime, endTime, interval, slidingStep, isAscending, leftCRightO, rightClosed, zoneId); } } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/AggregationUtil.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/AggregationUtil.java index 2df0be4c3394b..68681ed34fc74 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/AggregationUtil.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/AggregationUtil.java @@ -86,6 +86,7 @@ public static ITimeRangeIterator initTimeRangeIterator( groupByTimeParameter.getSlidingStep(), ascending, groupByTimeParameter.isLeftCRightO(), + groupByTimeParameter.isRightClosed(), outputPartialTimeWindow, zoneId); } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/expression/ExpressionFactory.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/expression/ExpressionFactory.java index b45a90c5b8026..652f460bd55c7 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/expression/ExpressionFactory.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/expression/ExpressionFactory.java @@ -219,9 +219,19 @@ public static BetweenExpression notBetween( public static GroupByTimeExpression groupByTime(GroupByTimeParameter parameter) { long startTime = parameter.isLeftCRightO() ? parameter.getStartTime() : parameter.getStartTime() + 1; - long endTime = parameter.isLeftCRightO() ? parameter.getEndTime() : parameter.getEndTime() + 1; + long endTime = + parameter.isRightClosed() + ? (parameter.getEndTime() == Long.MAX_VALUE + ? Long.MAX_VALUE + : parameter.getEndTime() + 1) + : (parameter.isLeftCRightO() ? parameter.getEndTime() : parameter.getEndTime() + 1); return new GroupByTimeExpression( - startTime, endTime, parameter.getInterval(), parameter.getSlidingStep()); + startTime, + endTime, + parameter.getInterval(), + parameter.getSlidingStep(), + parameter.isLeftCRightO(), + parameter.isRightClosed()); } public static GroupByTimeExpression groupByTime( diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/expression/other/GroupByTimeExpression.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/expression/other/GroupByTimeExpression.java index 4ee3c174bc4b5..c334acbe10c2d 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/expression/other/GroupByTimeExpression.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/expression/other/GroupByTimeExpression.java @@ -55,12 +55,30 @@ public class GroupByTimeExpression extends Expression { // sliding step private final TimeDuration slidingStep; + // if it is left close and right open interval + private final boolean leftCRightO; + + // if the right boundary is closed (inclusive) + private final boolean rightClosed; + public GroupByTimeExpression( long startTime, long endTime, TimeDuration interval, TimeDuration slidingStep) { + this(startTime, endTime, interval, slidingStep, true, false); + } + + public GroupByTimeExpression( + long startTime, + long endTime, + TimeDuration interval, + TimeDuration slidingStep, + boolean leftCRightO, + boolean rightClosed) { this.startTime = startTime; this.endTime = endTime; this.interval = interval; this.slidingStep = slidingStep; + this.leftCRightO = leftCRightO; + this.rightClosed = rightClosed; } public GroupByTimeExpression(ByteBuffer byteBuffer) { @@ -68,6 +86,8 @@ public GroupByTimeExpression(ByteBuffer byteBuffer) { this.endTime = ReadWriteIOUtils.readLong(byteBuffer); this.interval = TimeDuration.deserialize(byteBuffer); this.slidingStep = TimeDuration.deserialize(byteBuffer); + this.leftCRightO = ReadWriteIOUtils.readBool(byteBuffer); + this.rightClosed = ReadWriteIOUtils.readBool(byteBuffer); } public long getStartTime() { @@ -86,6 +106,14 @@ public TimeDuration getSlidingStep() { return slidingStep; } + public boolean isLeftCRightO() { + return leftCRightO; + } + + public boolean isRightClosed() { + return rightClosed; + } + @Override public ExpressionType getExpressionType() { return ExpressionType.GROUP_BY_TIME; @@ -147,6 +175,8 @@ protected void serialize(ByteBuffer byteBuffer) { ReadWriteIOUtils.write(endTime, byteBuffer); interval.serialize(byteBuffer); slidingStep.serialize(byteBuffer); + ReadWriteIOUtils.write(leftCRightO, byteBuffer); + ReadWriteIOUtils.write(rightClosed, byteBuffer); } @Override @@ -155,6 +185,8 @@ protected void serialize(DataOutputStream stream) throws IOException { ReadWriteIOUtils.write(endTime, stream); interval.serialize(stream); slidingStep.serialize(stream); + ReadWriteIOUtils.write(leftCRightO, stream); + ReadWriteIOUtils.write(rightClosed, stream); } @Override diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java index 70325257b085e..f1c4ac9337039 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java @@ -1864,6 +1864,7 @@ private GroupByTimeComponent parseGroupByTimeClause( if (ctx.timeRange() != null) { parseTimeRangeForGroupByTime(ctx.timeRange(), groupByTimeComponent); groupByTimeComponent.setLeftCRightO(ctx.timeRange().LS_BRACKET() != null); + groupByTimeComponent.setRightClosed(ctx.timeRange().RS_BRACKET() != null); } // Parse time interval diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/parameter/GroupByTimeParameter.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/parameter/GroupByTimeParameter.java index 9de54f85c0a16..fabd5f5057629 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/parameter/GroupByTimeParameter.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/parameter/GroupByTimeParameter.java @@ -51,6 +51,9 @@ public class GroupByTimeParameter { // if it is left close and right open interval private boolean leftCRightO; + // if the right boundary is closed (inclusive) + private boolean rightClosed; + public GroupByTimeParameter() {} public GroupByTimeParameter( @@ -59,11 +62,22 @@ public GroupByTimeParameter( TimeDuration interval, TimeDuration slidingStep, boolean leftCRightO) { + this(startTime, endTime, interval, slidingStep, leftCRightO, false); + } + + public GroupByTimeParameter( + long startTime, + long endTime, + TimeDuration interval, + TimeDuration slidingStep, + boolean leftCRightO, + boolean rightClosed) { this.startTime = startTime; this.endTime = endTime; this.interval = interval; this.slidingStep = slidingStep; this.leftCRightO = leftCRightO; + this.rightClosed = rightClosed; } public GroupByTimeParameter(GroupByTimeComponent groupByTimeComponent) { @@ -72,6 +86,7 @@ public GroupByTimeParameter(GroupByTimeComponent groupByTimeComponent) { this.interval = groupByTimeComponent.getInterval(); this.slidingStep = groupByTimeComponent.getSlidingStep(); this.leftCRightO = groupByTimeComponent.isLeftCRightO(); + this.rightClosed = groupByTimeComponent.isRightClosed(); } public long getStartTime() { @@ -114,6 +129,14 @@ public void setLeftCRightO(boolean leftCRightO) { this.leftCRightO = leftCRightO; } + public boolean isRightClosed() { + return rightClosed; + } + + public void setRightClosed(boolean rightClosed) { + this.rightClosed = rightClosed; + } + public boolean hasOverlap() { return interval.getTotalDuration(TimestampPrecisionUtils.currPrecision) > slidingStep.getTotalDuration(TimestampPrecisionUtils.currPrecision); @@ -125,6 +148,7 @@ public void serialize(ByteBuffer buffer) { interval.serialize(buffer); slidingStep.serialize(buffer); ReadWriteIOUtils.write(leftCRightO, buffer); + ReadWriteIOUtils.write(rightClosed, buffer); } public void serialize(DataOutputStream stream) throws IOException { @@ -133,6 +157,7 @@ public void serialize(DataOutputStream stream) throws IOException { interval.serialize(stream); slidingStep.serialize(stream); ReadWriteIOUtils.write(leftCRightO, stream); + ReadWriteIOUtils.write(rightClosed, stream); } public static GroupByTimeParameter deserialize(ByteBuffer buffer) { @@ -142,6 +167,7 @@ public static GroupByTimeParameter deserialize(ByteBuffer buffer) { groupByTimeParameter.setInterval(TimeDuration.deserialize(buffer)); groupByTimeParameter.setSlidingStep(TimeDuration.deserialize(buffer)); groupByTimeParameter.setLeftCRightO(ReadWriteIOUtils.readBool(buffer)); + groupByTimeParameter.setRightClosed(ReadWriteIOUtils.readBool(buffer)); return groupByTimeParameter; } @@ -155,11 +181,12 @@ public boolean equals(Object obj) { && this.endTime == other.endTime && this.interval.equals(other.interval) && this.slidingStep.equals(other.slidingStep) - && this.leftCRightO == other.leftCRightO; + && this.leftCRightO == other.leftCRightO + && this.rightClosed == other.rightClosed; } @Override public int hashCode() { - return Objects.hash(startTime, endTime, interval, slidingStep, leftCRightO); + return Objects.hash(startTime, endTime, interval, slidingStep, leftCRightO, rightClosed); } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/component/GroupByTimeComponent.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/component/GroupByTimeComponent.java index 1c11575905a07..54ba52c4bb324 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/component/GroupByTimeComponent.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/component/GroupByTimeComponent.java @@ -43,6 +43,9 @@ public class GroupByTimeComponent extends StatementNode { // if it is left close and right open interval private boolean leftCRightO = true; + // if the right boundary is closed (inclusive) + private boolean rightClosed = false; + public GroupByTimeComponent() { // do nothing } @@ -55,6 +58,14 @@ public void setLeftCRightO(boolean leftCRightO) { this.leftCRightO = leftCRightO; } + public boolean isRightClosed() { + return rightClosed; + } + + public void setRightClosed(boolean rightClosed) { + this.rightClosed = rightClosed; + } + public TimeDuration getInterval() { return interval; } @@ -104,23 +115,11 @@ public String toSQLString() { sqlBuilder.append("GROUP BY TIME").append(' '); sqlBuilder.append('('); if (startTime != 0 || endTime != 0) { - if (isLeftCRightO()) { - sqlBuilder - .append('[') - .append(startTime) - .append(',') - .append(' ') - .append(endTime) - .append(')'); - } else { - sqlBuilder - .append('(') - .append(startTime) - .append(',') - .append(' ') - .append(endTime) - .append(']'); - } + // Determine left bracket + sqlBuilder.append(isLeftCRightO() ? '[' : '('); + sqlBuilder.append(startTime).append(',').append(' ').append(endTime); + // Determine right bracket + sqlBuilder.append(isRightClosed() ? ']' : ')'); sqlBuilder.append(',').append(' '); } sqlBuilder.append(originalInterval); diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/aggregation/TimeRangeIteratorTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/aggregation/TimeRangeIteratorTest.java index 86d8ef8ad34b2..e4c0c5e092374 100644 --- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/aggregation/TimeRangeIteratorTest.java +++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/aggregation/TimeRangeIteratorTest.java @@ -55,13 +55,29 @@ public void testNotSplitTimeRange() { ITimeRangeIterator timeRangeIterator = TimeRangeIteratorFactory.getTimeRangeIterator( - startTime, endTime, interval, slidingStep, true, true, false, ZoneId.systemDefault()); + startTime, + endTime, + interval, + slidingStep, + true, + true, + false, + false, + ZoneId.systemDefault()); checkRes(timeRangeIterator, res); ITimeRangeIterator descTimeRangeIterator = TimeRangeIteratorFactory.getTimeRangeIterator( - startTime, endTime, interval, slidingStep, false, true, false, ZoneId.systemDefault()); + startTime, + endTime, + interval, + slidingStep, + false, + true, + false, + false, + ZoneId.systemDefault()); checkRes(descTimeRangeIterator, res); } @@ -170,51 +186,147 @@ public void testSplitTimeRange() { TimeDuration interval = new TimeDuration(0, 4); checkRes( TimeRangeIteratorFactory.getTimeRangeIterator( - 0, 32, interval, new TimeDuration(0, 1), true, true, true, ZoneId.systemDefault()), + 0, + 32, + interval, + new TimeDuration(0, 1), + true, + true, + false, + true, + ZoneId.systemDefault()), res4_1); checkRes( TimeRangeIteratorFactory.getTimeRangeIterator( - 0, 32, interval, new TimeDuration(0, 2), true, true, true, ZoneId.systemDefault()), + 0, + 32, + interval, + new TimeDuration(0, 2), + true, + true, + false, + true, + ZoneId.systemDefault()), res4_2); checkRes( TimeRangeIteratorFactory.getTimeRangeIterator( - 0, 32, interval, new TimeDuration(0, 3), true, true, true, ZoneId.systemDefault()), + 0, + 32, + interval, + new TimeDuration(0, 3), + true, + true, + false, + true, + ZoneId.systemDefault()), res4_3); checkRes( TimeRangeIteratorFactory.getTimeRangeIterator( - 0, 32, interval, new TimeDuration(0, 4), true, true, true, ZoneId.systemDefault()), + 0, + 32, + interval, + new TimeDuration(0, 4), + true, + true, + false, + true, + ZoneId.systemDefault()), res4_4); checkRes( TimeRangeIteratorFactory.getTimeRangeIterator( - 0, 32, interval, new TimeDuration(0, 5), true, true, true, ZoneId.systemDefault()), + 0, + 32, + interval, + new TimeDuration(0, 5), + true, + true, + false, + true, + ZoneId.systemDefault()), res4_5); checkRes( TimeRangeIteratorFactory.getTimeRangeIterator( - 0, 32, interval, new TimeDuration(0, 6), true, true, true, ZoneId.systemDefault()), + 0, + 32, + interval, + new TimeDuration(0, 6), + true, + true, + false, + true, + ZoneId.systemDefault()), res4_6); checkRes( TimeRangeIteratorFactory.getTimeRangeIterator( - 0, 32, interval, new TimeDuration(0, 1), false, true, true, ZoneId.systemDefault()), + 0, + 32, + interval, + new TimeDuration(0, 1), + false, + true, + false, + true, + ZoneId.systemDefault()), res4_1); checkRes( TimeRangeIteratorFactory.getTimeRangeIterator( - 0, 32, interval, new TimeDuration(0, 2), false, true, true, ZoneId.systemDefault()), + 0, + 32, + interval, + new TimeDuration(0, 2), + false, + true, + false, + true, + ZoneId.systemDefault()), res4_2); checkRes( TimeRangeIteratorFactory.getTimeRangeIterator( - 0, 32, interval, new TimeDuration(0, 3), false, true, true, ZoneId.systemDefault()), + 0, + 32, + interval, + new TimeDuration(0, 3), + false, + true, + false, + true, + ZoneId.systemDefault()), res4_3); checkRes( TimeRangeIteratorFactory.getTimeRangeIterator( - 0, 32, interval, new TimeDuration(0, 4), false, true, true, ZoneId.systemDefault()), + 0, + 32, + interval, + new TimeDuration(0, 4), + false, + true, + false, + true, + ZoneId.systemDefault()), res4_4); checkRes( TimeRangeIteratorFactory.getTimeRangeIterator( - 0, 32, interval, new TimeDuration(0, 5), false, true, true, ZoneId.systemDefault()), + 0, + 32, + interval, + new TimeDuration(0, 5), + false, + true, + false, + true, + ZoneId.systemDefault()), res4_5); checkRes( TimeRangeIteratorFactory.getTimeRangeIterator( - 0, 32, interval, new TimeDuration(0, 6), false, true, true, ZoneId.systemDefault()), + 0, + 32, + interval, + new TimeDuration(0, 6), + false, + true, + false, + true, + ZoneId.systemDefault()), res4_6); } @@ -284,6 +396,7 @@ public void testNaturalMonthTimeRange() { true, true, false, + false, ZoneId.systemDefault()), res1); checkRes( @@ -294,6 +407,7 @@ public void testNaturalMonthTimeRange() { new TimeDuration(1, 0), true, true, + false, true, ZoneId.systemDefault()), res1); @@ -306,6 +420,7 @@ public void testNaturalMonthTimeRange() { true, true, false, + false, ZoneId.systemDefault()), res2); checkRes( @@ -316,6 +431,7 @@ public void testNaturalMonthTimeRange() { new TimeDuration(1, 0), true, true, + false, true, ZoneId.systemDefault()), res2); @@ -328,6 +444,7 @@ public void testNaturalMonthTimeRange() { true, true, false, + false, ZoneId.systemDefault()), res3); checkRes( @@ -338,6 +455,7 @@ public void testNaturalMonthTimeRange() { new TimeDuration(0, 10 * MS_TO_DAY), true, true, + false, true, ZoneId.systemDefault()), res4); @@ -379,6 +497,7 @@ public void testMixedUnit() { new TimeDuration(1, MS_TO_DAY), true, true, + false, true, ZoneId.systemDefault()), res); @@ -430,6 +549,7 @@ public void testMixedUnit() { new TimeDuration(1, MS_TO_DAY), true, true, + false, true, ZoneId.systemDefault()), res);