You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2026/07/21 02:29:37 UTC
(iotdb) branch master updated: Compatibility changes for internal settle compaction API (#18230)
This is an automated email from the ASF dual-hosted git repository.
JackieTien97 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 91476b0df7e Compatibility changes for internal settle compaction API (#18230)
91476b0df7e is described below
commit 91476b0df7e9581c5eb2228811196c34ae9dbbc2
Author: shuwenwei <55...@users.noreply.github.com>
AuthorDate: Tue Jul 21 10:29:32 2026 +0800
Compatibility changes for internal settle compaction API (#18230)
---
.../selector/impl/SettleSelectorImpl.java | 43 +++++++++++++++++-----
1 file changed, 34 insertions(+), 9 deletions(-)
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/selector/impl/SettleSelectorImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/selector/impl/SettleSelectorImpl.java
index cef6084d1ae..b08c032d483 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/selector/impl/SettleSelectorImpl.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/selector/impl/SettleSelectorImpl.java
@@ -71,6 +71,7 @@ public class SettleSelectorImpl implements ISettleSelector {
private final TsFileManager tsFileManager;
private boolean isSeq;
private final CompactionScheduleContext context;
+ private final boolean ttlAuditEnabled;
public SettleSelectorImpl(
boolean heavySelect,
@@ -85,19 +86,28 @@ public class SettleSelectorImpl implements ISettleSelector {
this.timePartition = timePartition;
this.tsFileManager = tsFileManager;
this.context = context;
+ // this will be enabled in other branches
+ this.ttlAuditEnabled = false;
}
static class FileDirtyInfo {
DirtyStatus status;
long dirtyDataSize = 0;
+ Set<String> ttlTables = Collections.emptySet();
public FileDirtyInfo(DirtyStatus status) {
this.status = status;
}
- public FileDirtyInfo(DirtyStatus status, long dirtyDataSize) {
+ public FileDirtyInfo(DirtyStatus status, Set<String> ttlTables) {
+ this.status = status;
+ this.ttlTables = ttlTables;
+ }
+
+ public FileDirtyInfo(DirtyStatus status, long dirtyDataSize, Set<String> ttlTables) {
this.status = status;
this.dirtyDataSize = dirtyDataSize;
+ this.ttlTables = ttlTables;
}
}
@@ -106,15 +116,19 @@ public class SettleSelectorImpl implements ISettleSelector {
List<TsFileResource> fullyDirtyResources = new ArrayList<>();
List<TsFileResource> partiallyDirtyResources = new ArrayList<>();
long totalPartiallyDirtyFileSize = 0;
+ final Set<String> ttlTables = new HashSet<>();
- public void addFullyDirtyResource(TsFileResource resource) {
+ public void addFullyDirtyResource(TsFileResource resource, Set<String> fileTTLTables) {
fullyDirtyResources.add(resource);
+ ttlTables.addAll(fileTTLTables);
}
- public boolean addPartiallyDirtyResource(TsFileResource resource, long dirtyDataSize) {
+ public boolean addPartiallyDirtyResource(
+ TsFileResource resource, long dirtyDataSize, Set<String> fileTTLTables) {
partiallyDirtyResources.add(resource);
totalPartiallyDirtyFileSize += resource.getTsFileSize();
totalPartiallyDirtyFileSize -= dirtyDataSize;
+ ttlTables.addAll(fileTTLTables);
return checkHasReachedThreshold();
}
@@ -126,6 +140,10 @@ public class SettleSelectorImpl implements ISettleSelector {
return partiallyDirtyResources;
}
+ public Set<String> getTTLTables() {
+ return ttlTables;
+ }
+
public boolean checkHasReachedThreshold() {
return partiallyDirtyResources.size() >= config.getInnerCompactionCandidateFileNum()
|| totalPartiallyDirtyFileSize >= config.getTargetCompactionFileSize();
@@ -165,11 +183,12 @@ public class SettleSelectorImpl implements ISettleSelector {
switch (fileDirtyInfo.status) {
case FULLY_DIRTY:
- settleTaskResource.addFullyDirtyResource(resource);
+ settleTaskResource.addFullyDirtyResource(resource, fileDirtyInfo.ttlTables);
break;
case PARTIALLY_DIRTY:
shouldStop =
- settleTaskResource.addPartiallyDirtyResource(resource, fileDirtyInfo.dirtyDataSize);
+ settleTaskResource.addPartiallyDirtyResource(
+ resource, fileDirtyInfo.dirtyDataSize, fileDirtyInfo.ttlTables);
break;
case NOT_SATISFIED:
shouldStop = !settleTaskResource.getPartiallyDirtyResources().isEmpty();
@@ -231,6 +250,7 @@ public class SettleSelectorImpl implements ISettleSelector {
timeIndex = CompactionUtils.buildDeviceTimeIndex(resource);
}
Set<IDeviceID> deletedDevices = new HashSet<>();
+ Set<String> ttlTables = new HashSet<>();
boolean hasExpiredTooLong = false;
long currentTime = CommonDateTimeUtils.currentTime();
@@ -240,12 +260,17 @@ public class SettleSelectorImpl implements ISettleSelector {
long ttl;
String tableName = device.getTableName();
+ boolean hasSetTTL;
if (tableName.startsWith("root.")) {
ttl = DataNodeTTLCache.getInstance().getTTLForTree(device);
+ hasSetTTL = ttl != Long.MAX_VALUE;
} else {
ttl = DataNodeTTLCache.getInstance().getTTLForTable(storageGroupName, tableName);
+ hasSetTTL = ttl != Long.MAX_VALUE;
+ if (hasSetTTL && ttlAuditEnabled) {
+ ttlTables.add(tableName);
+ }
}
- boolean hasSetTTL = ttl != Long.MAX_VALUE;
long endTime = timeIndex.getEndTime(device).get();
boolean isDeleted =
@@ -256,7 +281,7 @@ public class SettleSelectorImpl implements ISettleSelector {
if (!isDeleted) {
// For devices with TTL set, all data must expire in order to meet the conditions for
// being selected.
- return new FileDirtyInfo(DirtyStatus.NOT_SATISFIED);
+ return new FileDirtyInfo(DirtyStatus.NOT_SATISFIED, ttlTables);
}
if (currentTime > endTime) {
@@ -281,13 +306,13 @@ public class SettleSelectorImpl implements ISettleSelector {
((double) deletedDevices.size()) / ((ArrayDeviceTimeIndex) timeIndex).getDevices().size();
if (deletedDeviceRatio == 1d) {
// the whole file is completely dirty
- return new FileDirtyInfo(DirtyStatus.FULLY_DIRTY);
+ return new FileDirtyInfo(DirtyStatus.FULLY_DIRTY, ttlTables);
}
hasExpiredTooLong = config.getMaxExpiredTime() != Long.MAX_VALUE && hasExpiredTooLong;
if (hasExpiredTooLong || deletedDeviceRatio >= config.getExpiredDataRatio()) {
// evaluate dirty data size in the tsfile
return new FileDirtyInfo(
- PARTIALLY_DIRTY, (long) (deletedDeviceRatio * resource.getTsFileSize()));
+ PARTIALLY_DIRTY, (long) (deletedDeviceRatio * resource.getTsFileSize()), ttlTables);
}
return new FileDirtyInfo(DirtyStatus.NOT_SATISFIED);
}