This is an automated email from the ASF dual-hosted git repository.

caogaofei pushed a commit to branch fix_last_cache
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit b753c0fdd1641896104d31206ba7741433132539
Author: Beyyes <[email protected]>
AuthorDate: Tue Apr 8 17:47:59 2025 +0800

    Fix the usage of method initOrInvalidateLastCache of class 
TableDeviceSchemaCache
---
 .../source/relational/LastQueryAggTableScanOperator.java      |  2 --
 .../db/queryengine/plan/planner/TableOperatorGenerator.java   | 11 +++++++++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/LastQueryAggTableScanOperator.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/LastQueryAggTableScanOperator.java
index dd1dac4e652..63b2d196590 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/LastQueryAggTableScanOperator.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/LastQueryAggTableScanOperator.java
@@ -352,8 +352,6 @@ public class LastQueryAggTableScanOperator extends 
AbstractAggTableScanOperator
       TimeValuePair[] updateTimeValuePairArray =
           updateTimeValuePairList.toArray(new TimeValuePair[0]);
       currentDeviceEntry = deviceEntries.get(currentDeviceIndex);
-      TABLE_DEVICE_SCHEMA_CACHE.initOrInvalidateLastCache(
-          dbName, currentDeviceEntry.getDeviceID(), updateMeasurementArray, 
false);
       TABLE_DEVICE_SCHEMA_CACHE.updateLastCacheIfExists(
           dbName,
           currentDeviceEntry.getDeviceID(),
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TableOperatorGenerator.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TableOperatorGenerator.java
index 572e79a3adf..cf47359c40f 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TableOperatorGenerator.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TableOperatorGenerator.java
@@ -2335,14 +2335,21 @@ public class TableOperatorGenerator extends 
PlanVisitor<Operator, LocalExecution
       }
 
       if (!allHitCache) {
+        DeviceEntry deviceEntry = node.getDeviceEntries().get(i);
         AlignedFullPath alignedPath =
             constructAlignedPath(
-                node.getDeviceEntries().get(i),
+                deviceEntry,
                 parameter.getMeasurementColumnNames(),
                 parameter.getMeasurementSchemas(),
                 parameter.getAllSensors());
         ((DataDriverContext) context.getDriverContext()).addPath(alignedPath);
-        unCachedDeviceEntries.add(node.getDeviceEntries().get(i));
+        unCachedDeviceEntries.add(deviceEntry);
+        TableDeviceSchemaCache.getInstance()
+            .initOrInvalidateLastCache(
+                node.getQualifiedObjectName().getDatabaseName(),
+                deviceEntry.getDeviceID(),
+                parameter.getMeasurementColumnNames().toArray(new String[0]),
+                false);
       } else {
         hitCachesIndexes.add(i);
         hitCachedResults.add(lastByResult.get());

Reply via email to