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 0c35003d41e Reset global time filter for each device in table view scan
0c35003d41e is described below
commit 0c35003d41e9f8d34bdb4bcec377f11e46a9820d
Author: shuwenwei <[email protected]>
AuthorDate: Tue Jun 17 20:23:25 2025 +0800
Reset global time filter for each device in table view scan
---
.../recent/IoTDBTableViewWithTreeTTLQueryIT.java | 38 ++++++++++++++++++++--
.../execution/operator/source/SeriesScanUtil.java | 6 ++--
.../planner/plan/parameter/SeriesScanOptions.java | 24 +++++++++-----
3 files changed, 55 insertions(+), 13 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewWithTreeTTLQueryIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewWithTreeTTLQueryIT.java
index 10ae276b40f..fec42cd10a1 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewWithTreeTTLQueryIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewWithTreeTTLQueryIT.java
@@ -46,6 +46,10 @@ public class IoTDBTableViewWithTreeTTLQueryIT {
protected static final String DATABASE_NAME = "test";
protected static String[] createTreeDataSqls = {
+ "CREATE ALIGNED TIMESERIES root.db.battery.b0(voltage INT32, current
FLOAT)",
+ "INSERT INTO root.db.battery.b0(time, voltage, current) aligned values ("
+ + (System.currentTimeMillis() - 100000)
+ + ", 1, 1)",
"CREATE ALIGNED TIMESERIES root.db.battery.b1(voltage INT32, current
FLOAT)",
"INSERT INTO root.db.battery.b1(time, voltage, current) aligned values (1,
1, 1)",
"INSERT INTO root.db.battery.b1(time, voltage, current) aligned values (2,
1, 1)",
@@ -63,8 +67,38 @@ public class IoTDBTableViewWithTreeTTLQueryIT {
"INSERT INTO root.db.battery.b2(time, voltage, current) values ("
+ System.currentTimeMillis()
+ ", 1, 1)",
+ "CREATE ALIGNED TIMESERIES root.db.battery.b3(voltage INT32, current
FLOAT)",
+ "INSERT INTO root.db.battery.b3(time, voltage, current) aligned values ("
+ + (System.currentTimeMillis() - 100000)
+ + ", 1, 1)",
+ "CREATE ALIGNED TIMESERIES root.db.battery.b4(voltage INT32, current
FLOAT)",
+ "INSERT INTO root.db.battery.b4(time, voltage, current) aligned values ("
+ + (System.currentTimeMillis() - 100000)
+ + ", 1, 1)",
+ "CREATE ALIGNED TIMESERIES root.db.battery.b5(voltage INT32, current
FLOAT)",
+ "INSERT INTO root.db.battery.b5(time, voltage, current) aligned values ("
+ + (System.currentTimeMillis() - 100000)
+ + ", 1, 1)",
+ "CREATE ALIGNED TIMESERIES root.db.battery.b6(voltage INT32, current
FLOAT)",
+ "INSERT INTO root.db.battery.b6(time, voltage, current) aligned values ("
+ + (System.currentTimeMillis() - 100000)
+ + ", 1, 1)",
+ "CREATE ALIGNED TIMESERIES root.db.battery.b7(voltage INT32, current
FLOAT)",
+ "INSERT INTO root.db.battery.b7(time, voltage, current) aligned values ("
+ + (System.currentTimeMillis() - 100000)
+ + ", 1, 1)",
+ "CREATE ALIGNED TIMESERIES root.db.battery.b8(voltage INT32, current
FLOAT)",
+ "INSERT INTO root.db.battery.b8(time, voltage, current) aligned values ("
+ + (System.currentTimeMillis() - 100000)
+ + ", 1, 1)",
+ "CREATE ALIGNED TIMESERIES root.db.battery.b9(voltage INT32, current
FLOAT)",
+ "INSERT INTO root.db.battery.b9(time, voltage, current) aligned values ("
+ + (System.currentTimeMillis() - 100000)
+ + ", 1, 1)",
"flush",
- "set ttl to root.db.battery.** 100000"
+ "set ttl to root.db.battery.** 200000",
+ "set ttl to root.db.battery.b0 50000",
+ "set ttl to root.db.battery.b6 50000",
};
protected static String[] createTableSqls = {
@@ -106,7 +140,7 @@ public class IoTDBTableViewWithTreeTTLQueryIT {
count++;
}
sessionDataSet.close();
- Assert.assertEquals(2, count);
+ Assert.assertEquals(8, count);
}
}
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/SeriesScanUtil.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/SeriesScanUtil.java
index 3de6fc253b6..b9b500ad83e 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/SeriesScanUtil.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/SeriesScanUtil.java
@@ -188,17 +188,17 @@ public class SeriesScanUtil implements Accountable {
if (context.isIgnoreAllNullRows() ||
scanOptions.isTableViewForTreeModel()) {
if (deviceID != EMPTY_DEVICE_ID) {
long ttl = DataNodeTTLCache.getInstance().getTTLForTree(deviceID);
- scanOptions.setTTL(ttl);
+ scanOptions.setTTLForTreeDevice(ttl);
}
} else {
- if (scanOptions.timeFilterNeedUpdatedByTll()) {
+ if (scanOptions.timeFilterNeedUpdatedByTtl()) {
String databaseName = dataSource.getDatabaseName();
long ttl =
databaseName == null
? Long.MAX_VALUE
: DataNodeTTLCache.getInstance()
.getTTLForTable(databaseName, deviceID.getTableName());
- scanOptions.setTTL(ttl);
+ scanOptions.setTTLForTableDevice(ttl);
}
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/parameter/SeriesScanOptions.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/parameter/SeriesScanOptions.java
index dc74df6d2f5..7fc4d3f81fc 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/parameter/SeriesScanOptions.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/parameter/SeriesScanOptions.java
@@ -37,8 +37,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class SeriesScanOptions {
private Filter globalTimeFilter;
+ private final Filter originalTimeFilter;
- private final AtomicBoolean timeFilterUpdatedByTll = new
AtomicBoolean(false);
+ private final AtomicBoolean timeFilterUpdatedByTtl = new
AtomicBoolean(false);
private final Filter pushDownFilter;
@@ -61,6 +62,7 @@ public class SeriesScanOptions {
boolean pushLimitToEachDevice,
boolean isTableViewForTreeModel) {
this.globalTimeFilter = globalTimeFilter;
+ this.originalTimeFilter = globalTimeFilter;
this.pushDownFilter = pushDownFilter;
this.pushDownLimit = pushDownLimit;
this.pushDownOffset = pushDownOffset;
@@ -116,18 +118,24 @@ public class SeriesScanOptions {
}
}
- public boolean timeFilterNeedUpdatedByTll() {
- return !timeFilterUpdatedByTll.get();
+ public boolean timeFilterNeedUpdatedByTtl() {
+ return !timeFilterUpdatedByTtl.get();
}
- public void setTTL(long dataTTL) {
- if (timeFilterUpdatedByTll.compareAndSet(false, true)) {
- // ttlForTableView should be set before calling setTTL
- this.globalTimeFilter =
- updateFilterUsingTTL(globalTimeFilter, Math.min(ttlForTableView,
dataTTL));
+ public void setTTLForTableDevice(long dataTTL) {
+ // Devices in the table model share a same table ttl, so it only needs to
be set once
+ if (timeFilterUpdatedByTtl.compareAndSet(false, true)) {
+ this.globalTimeFilter = updateFilterUsingTTL(globalTimeFilter, dataTTL);
}
}
+ public void setTTLForTreeDevice(long dataTTL) {
+ // ttlForTableView should be set before calling setTTL.
+ // Different devices have different ttl, so we regenerate the
globalTimeFilter each time
+ this.globalTimeFilter =
+ updateFilterUsingTTL(originalTimeFilter, Math.min(ttlForTableView,
dataTTL));
+ }
+
public void setTTLForTableView(long ttlForTableView) {
this.ttlForTableView = ttlForTableView;
}