jt2594838 commented on code in PR #12709:
URL: https://github.com/apache/iotdb/pull/12709#discussion_r1639464203
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/TTLInfo.java:
##########
@@ -118,12 +120,19 @@ public TSStatus unsetTTL(SetTTLPlan plan) {
return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
}
- public ShowTTLResp showAllTTL() {
+ public ShowTTLResp showTTL(ShowTTLPlan plan) {
ShowTTLResp resp = new ShowTTLResp();
- Map<String, Long> pathTTLMap;
+ Map<String, Long> pathTTLMap = new HashMap<>();
lock.readLock().lock();
try {
- pathTTLMap = ttlCache.getAllPathTTL();
+ PartialPath pathPattern = new PartialPath(plan.getPathPattern());
+ for (Map.Entry<String[], Long> entry : ttlCache.getAllTTLs().entrySet())
{
+ if (pathPattern.matchFullPath(new PartialPath(entry.getKey()))) {
+ pathTTLMap.put(
+ String.join(String.valueOf(IoTDBConstant.PATH_SEPARATOR),
entry.getKey()),
+ entry.getValue());
+ }
Review Comment:
Optional: provide `matchFullPath(String[])` in PartialPath.
##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/TTLInfo.java:
##########
@@ -190,7 +201,9 @@ public boolean equals(Object o) {
}
TTLInfo other = (TTLInfo) o;
return this.getTTLCount() == other.getTTLCount()
- &&
this.showAllTTL().getPathTTLMap().equals(other.showAllTTL().getPathTTLMap());
+ && this.showTTL(new ShowTTLPlan())
+ .getPathTTLMap()
+ .equals(other.showTTL(new ShowTTLPlan()).getPathTTLMap());
Review Comment:
Is it necessary to call showTTL() in equals()? It is pretty heavy.
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java:
##########
@@ -1294,8 +1295,11 @@ public SettableFuture<ConfigTaskResult>
showTTL(ShowTTLStatement showTTLStatemen
Map<String, Long> databaseToTTL = new TreeMap<>();
try (ConfigNodeClient client =
CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
- TShowTTLResp resp = client.showAllTTL();
- databaseToTTL.putAll(resp.getPathTTLMap());
+ for (PartialPath pathPattern : showTTLStatement.getPaths()) {
+ TShowTTLReq req = new
TShowTTLReq(Arrays.asList(pathPattern.getNodes()));
+ TShowTTLResp resp = client.showTTL(req);
+ databaseToTTL.putAll(resp.getPathTTLMap());
Review Comment:
No longer `database`.
Optional: send all paths in one RPC.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]