This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch OptQuery
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/OptQuery by this push:
new e229e5a50d3 more opt
e229e5a50d3 is described below
commit e229e5a50d3426229306a08e1928b82130c303f6
Author: JackieTien97 <[email protected]>
AuthorDate: Mon Mar 17 20:43:27 2025 +0800
more opt
---
.../fragment/FragmentInstanceContext.java | 36 ++++++++++++++++------
1 file changed, 26 insertions(+), 10 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceContext.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceContext.java
index 561eb432c6a..0eaa622d4b5 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceContext.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceContext.java
@@ -22,6 +22,7 @@ package org.apache.iotdb.db.queryengine.execution.fragment;
import org.apache.iotdb.common.rpc.thrift.TSStatus;
import org.apache.iotdb.commons.exception.IoTDBException;
import org.apache.iotdb.commons.exception.IoTDBRuntimeException;
+import org.apache.iotdb.commons.path.AlignedFullPath;
import org.apache.iotdb.commons.path.IFullPath;
import org.apache.iotdb.commons.utils.TestOnly;
import org.apache.iotdb.db.exception.query.QueryProcessException;
@@ -450,24 +451,39 @@ public class FragmentInstanceContext extends QueryContext
{
public void initQueryDataSource(List<IFullPath> sourcePaths) throws
QueryProcessException {
long startTime = System.nanoTime();
- if (sourcePaths == null) {
+ if (sourcePaths == null || sourcePaths.isEmpty()) {
return;
}
- dataRegion.readLock();
- try {
- List<IFullPath> pathList = new ArrayList<>();
+
+ IDeviceID singleDeviceId = null;
+ if (sourcePaths.size() == 1) {
+ singleDeviceId = sourcePaths.get(0).getDeviceId();
+ } else {
Set<IDeviceID> selectedDeviceIdSet = new HashSet<>();
- for (IFullPath path : sourcePaths) {
- pathList.add(path);
- selectedDeviceIdSet.add(path.getDeviceId());
+ for (IFullPath sourcePath : sourcePaths) {
+ if (sourcePath instanceof AlignedFullPath) {
+ singleDeviceId = null;
+ break;
+ } else {
+ singleDeviceId = sourcePath.getDeviceId();
+ selectedDeviceIdSet.add(singleDeviceId);
+ if (selectedDeviceIdSet.size() > 1) {
+ singleDeviceId = null;
+ break;
+ }
+ }
}
+ }
+
+ dataRegion.readLock();
+ try {
this.sharedQueryDataSource =
dataRegion.query(
- pathList,
+ sourcePaths,
// when all the selected series are under the same device, the
QueryDataSource will be
// filtered according to timeIndex
- selectedDeviceIdSet.size() == 1 ?
selectedDeviceIdSet.iterator().next() : null,
+ singleDeviceId,
this,
// time filter may be stateful, so we need to copy it
globalTimeFilter != null ? globalTimeFilter.copy() : null,
@@ -479,7 +495,7 @@ public class FragmentInstanceContext extends QueryContext {
closedFilePaths = new HashSet<>();
unClosedFilePaths = new HashSet<>();
addUsedFilesForQuery((QueryDataSource) sharedQueryDataSource);
- ((QueryDataSource)
sharedQueryDataSource).setSingleDevice(selectedDeviceIdSet.size() == 1);
+ ((QueryDataSource)
sharedQueryDataSource).setSingleDevice(singleDeviceId != null);
}
} finally {
setInitQueryDataSourceCost(System.nanoTime() - startTime);