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 2021/11/23 13:20:13 UTC
[iotdb] branch master updated: [IOTDB-2031] Fix incorrect result of descending query with value filter in cluster (#4431)
This is an automated email from the ASF dual-hosted git repository.
xiangweiwei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 14505c1 [IOTDB-2031] Fix incorrect result of descending query with value filter in cluster (#4431)
14505c1 is described below
commit 14505c175a8c1e98535757027f36210b07de213c
Author: BaiJian <er...@hotmail.com>
AuthorDate: Tue Nov 23 21:18:10 2021 +0800
[IOTDB-2031] Fix incorrect result of descending query with value filter in cluster (#4431)
---
.../iotdb/cluster/query/reader/ClusterReaderFactory.java | 7 ++++---
.../iotdb/db/query/reader/series/SeriesReaderByTimestamp.java | 5 ++---
.../java/org/apache/iotdb/tsfile/read/filter/TimeFilter.java | 11 +++++++++++
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/ClusterReaderFactory.java b/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/ClusterReaderFactory.java
index 21ab3a6..328e3bb 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/ClusterReaderFactory.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/query/reader/ClusterReaderFactory.java
@@ -1144,6 +1144,7 @@ public class ClusterReaderFactory {
// when a slot is in the status of PULLING or PULLING_WRITABLE, the read of it should merge
// result to guarantee integrity.
Map<PartitionGroup, Set<Integer>> holderSlotMap = dataGroupMember.getPreviousHolderSlotMap();
+ Filter timeFilter = TimeFilter.defaultTimeFilter(ascending);
try {
// If requiredSlots is not null, it means that this data group is the previous holder of
// required slots, which is no need to merge other resource,
@@ -1162,7 +1163,7 @@ public class ClusterReaderFactory {
path,
allSensors,
dataType,
- TimeFilter.gtEq(Long.MIN_VALUE),
+ timeFilter,
null,
context,
dataGroupMember,
@@ -1182,7 +1183,7 @@ public class ClusterReaderFactory {
entry.getKey(),
path,
allSensors,
- TimeFilter.gtEq(Long.MIN_VALUE),
+ timeFilter,
null,
context,
dataType,
@@ -1201,7 +1202,7 @@ public class ClusterReaderFactory {
path,
allSensors,
dataType,
- TimeFilter.gtEq(Long.MIN_VALUE),
+ timeFilter,
null,
context,
dataGroupMember.getHeader(),
diff --git a/server/src/main/java/org/apache/iotdb/db/query/reader/series/SeriesReaderByTimestamp.java b/server/src/main/java/org/apache/iotdb/db/query/reader/series/SeriesReaderByTimestamp.java
index bb154a2..4cb21c3 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/reader/series/SeriesReaderByTimestamp.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/reader/series/SeriesReaderByTimestamp.java
@@ -26,7 +26,7 @@ import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.file.metadata.statistics.Statistics;
import org.apache.iotdb.tsfile.read.common.BatchData;
import org.apache.iotdb.tsfile.read.filter.TimeFilter;
-import org.apache.iotdb.tsfile.read.filter.basic.UnaryFilter;
+import org.apache.iotdb.tsfile.read.filter.basic.Filter;
import java.io.IOException;
import java.util.Set;
@@ -45,8 +45,7 @@ public class SeriesReaderByTimestamp implements IReaderByTimestamp {
QueryDataSource dataSource,
TsFileFilter fileFilter,
boolean ascending) {
- UnaryFilter timeFilter =
- ascending ? TimeFilter.gtEq(Long.MIN_VALUE) : TimeFilter.ltEq(Long.MAX_VALUE);
+ Filter timeFilter = TimeFilter.defaultTimeFilter(ascending);
this.seriesReader =
seriesPath.createSeriesReader(
allSensors, dataType, context, dataSource, timeFilter, null, fileFilter, ascending);
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/TimeFilter.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/TimeFilter.java
index e409a14..3e1b7c0 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/TimeFilter.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/filter/TimeFilter.java
@@ -122,4 +122,15 @@ public class TimeFilter {
super(filter);
}
}
+
+ /**
+ * returns a default time filter by whether it's an ascending query.
+ *
+ * <p>If the data is read in descending order, we use the largest timestamp to set to the filter,
+ * so the filter should be TimeLtEq. If the data is read in ascending order, we use the smallest
+ * timestamp to set to the filter, so the filter should be TimeGtEq.
+ */
+ public static Filter defaultTimeFilter(boolean ascending) {
+ return ascending ? TimeFilter.gtEq(Long.MIN_VALUE) : TimeFilter.ltEq(Long.MAX_VALUE);
+ }
}