You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2024/03/12 12:28:00 UTC
(iotdb) 01/01: ty/optForPartitionFilter
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch ty/FilterPartition
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit c454d36e9f34a6f2b2833748ce577dd151aa4bbc
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Tue Mar 12 20:27:44 2024 +0800
ty/optForPartitionFilter
---
.../apache/iotdb/db/storageengine/dataregion/DataRegion.java | 4 ++--
.../db/storageengine/dataregion/tsfile/TsFileManager.java | 10 +++++++---
.../org/apache/iotdb/commons/utils/TimePartitionUtils.java | 7 ++++++-
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java
index ce5ea50b50a..15864cc9d80 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java
@@ -1792,7 +1792,7 @@ public class DataRegion implements IDataRegionForQuery {
try {
List<TsFileResource> seqResources =
getFileResourceListForQuery(
- tsFileManager.getTsFileList(true, timePartitions),
+ tsFileManager.getTsFileList(true, timePartitions, globalTimeFilter),
pathList,
singleDeviceId,
context,
@@ -1800,7 +1800,7 @@ public class DataRegion implements IDataRegionForQuery {
true);
List<TsFileResource> unseqResources =
getFileResourceListForQuery(
- tsFileManager.getTsFileList(false, timePartitions),
+ tsFileManager.getTsFileList(false, timePartitions, globalTimeFilter),
pathList,
singleDeviceId,
context,
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/TsFileManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/TsFileManager.java
index b40093beb56..0c21234c9d6 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/TsFileManager.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/TsFileManager.java
@@ -21,6 +21,7 @@ package org.apache.iotdb.db.storageengine.dataregion.tsfile;
import org.apache.iotdb.commons.utils.TimePartitionUtils;
import org.apache.iotdb.db.storageengine.rescon.memory.TsFileResourceManager;
+import org.apache.iotdb.tsfile.read.filter.basic.Filter;
import java.io.IOException;
import java.util.ArrayList;
@@ -57,14 +58,15 @@ public class TsFileManager {
}
public List<TsFileResource> getTsFileList(boolean sequence) {
- return getTsFileList(sequence, null);
+ return getTsFileList(sequence, null, null);
}
/**
* @param sequence true for sequence, false for unsequence
* @param timePartitions null for all time partitions, empty for zero time partitions
*/
- public List<TsFileResource> getTsFileList(boolean sequence, List<Long> timePartitions) {
+ public List<TsFileResource> getTsFileList(
+ boolean sequence, List<Long> timePartitions, Filter timeFilter) {
// the iteration of ConcurrentSkipListMap is not concurrent secure
// so we must add read lock here
readLock();
@@ -73,7 +75,9 @@ public class TsFileManager {
Map<Long, TsFileResourceList> chosenMap = sequence ? sequenceFiles : unsequenceFiles;
if (timePartitions == null) {
for (Map.Entry<Long, TsFileResourceList> entry : chosenMap.entrySet()) {
- allResources.addAll(entry.getValue().getArrayList());
+ if (TimePartitionUtils.satisfyTimePartition(timeFilter, entry.getKey())) {
+ allResources.addAll(entry.getValue().getArrayList());
+ }
}
} else {
for (Long timePartitionId : timePartitions) {
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/TimePartitionUtils.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/TimePartitionUtils.java
index 630b60ce20a..6721e1b0398 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/TimePartitionUtils.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/TimePartitionUtils.java
@@ -70,7 +70,12 @@ public class TimePartitionUtils {
public static boolean satisfyPartitionStartTime(Filter timeFilter, long partitionStartTime) {
return timeFilter == null
|| timeFilter.satisfyStartEndTime(
- partitionStartTime, partitionStartTime + timePartitionInterval);
+ partitionStartTime, partitionStartTime + timePartitionInterval - 1);
+ }
+
+ public static boolean satisfyTimePartition(Filter timeFilter, long partitionId) {
+ long partitionStartTime = partitionId * timePartitionInterval;
+ return satisfyPartitionStartTime(timeFilter, partitionStartTime);
}
public static void setTimePartitionInterval(long timePartitionInterval) {