This is an automated email from the ASF dual-hosted git repository. hui pushed a commit to branch lmh/refactorFilter in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit e45c175d2aa860db009d37ebb370a6ea41bbf2fb Author: Minghui Liu <[email protected]> AuthorDate: Mon Nov 20 22:43:55 2023 +0800 add copy() --- .../plan/planner/OperatorTreeGenerator.java | 5 ++++- .../iotdb/tsfile/read/filter/basic/Filter.java | 4 ++++ .../tsfile/read/filter/basic/IStatefulFilter.java | 25 ++++++++++++++++++++++ .../read/filter/operator/GroupByMonthFilter.java | 10 ++++++++- 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/OperatorTreeGenerator.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/OperatorTreeGenerator.java index 5ad861231a0..75a43acd77e 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/OperatorTreeGenerator.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/OperatorTreeGenerator.java @@ -501,7 +501,9 @@ public class OperatorTreeGenerator extends PlanVisitor<Operator, LocalExecutionP SeriesScanOptions.Builder scanOptionsBuilder = new SeriesScanOptions.Builder(); Filter globalTimeFilter = context.getGlobalTimeFilter(); - scanOptionsBuilder.withGlobalTimeFilter(globalTimeFilter); + if(globalTimeFilter != null) { + scanOptionsBuilder.withGlobalTimeFilter(globalTimeFilter.copy()); + } Filter pushDownFilter = null; Expression pushDownPredicate = node.getPushDownPredicate(); @@ -511,6 +513,7 @@ public class OperatorTreeGenerator extends PlanVisitor<Operator, LocalExecutionP PredicateUtils.convertPredicateToFilter(pushDownPredicate, context.getTypeProvider()); } scanOptionsBuilder.withPushDownFilter(pushDownFilter); + return scanOptionsBuilder; } diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/basic/Filter.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/basic/Filter.java index 657ab1f30fc..7f2d6882f9f 100755 --- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/basic/Filter.java +++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/basic/Filter.java @@ -68,4 +68,8 @@ public interface Filter { List<TimeRange> getTimeRanges(); Filter reverse(); + + default Filter copy() { + return this; + } } diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/basic/IStatefulFilter.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/basic/IStatefulFilter.java new file mode 100644 index 00000000000..24bfdc5c7ab --- /dev/null +++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/basic/IStatefulFilter.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iotdb.tsfile.read.filter.basic; + +public interface IStatefulFilter extends Filter { + + Filter copy(); +} diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/operator/GroupByMonthFilter.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/operator/GroupByMonthFilter.java index b42f70fe39f..3871664e66b 100644 --- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/operator/GroupByMonthFilter.java +++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/operator/GroupByMonthFilter.java @@ -19,6 +19,8 @@ package org.apache.iotdb.tsfile.read.filter.operator; +import org.apache.iotdb.tsfile.read.filter.basic.Filter; +import org.apache.iotdb.tsfile.read.filter.basic.IStatefulFilter; import org.apache.iotdb.tsfile.utils.TimeDuration; import java.util.Arrays; @@ -34,7 +36,7 @@ import static org.apache.iotdb.tsfile.utils.TimeDuration.getConsecutiveTimesInte * GroupByMonthFilter is used to handle natural month slidingStep and interval by generating * dynamically. Attention: it's only supported to access in ascending order now. */ -public class GroupByMonthFilter extends GroupByFilter { +public class GroupByMonthFilter extends GroupByFilter implements IStatefulFilter { private final Calendar calendar = Calendar.getInstance(); private final TimeDuration originalSlidingStep; @@ -211,4 +213,10 @@ public class GroupByMonthFilter extends GroupByFilter { result = 31 * result + Arrays.hashCode(startTimes); return result; } + + @Override + public Filter copy() { + return new GroupByMonthFilter( + originalInterval, originalSlidingStep, originalStartTime, originalEndTime, timeZone, currPrecision); + } }
