This is an automated email from the ASF dual-hosted git repository.
jackietien 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 e0074edf420 [IOTDB-6310] Optimize for query resource init
e0074edf420 is described below
commit e0074edf4209624642615719e2237d36917daa06
Author: Jackie Tien <[email protected]>
AuthorDate: Wed Mar 13 14:28:21 2024 +0800
[IOTDB-6310] Optimize for query resource init
---
.../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) {