This is an automated email from the ASF dual-hosted git repository. tanxinyu pushed a commit to branch tt in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit bc676536aaa5ca0722962ba74bcc050c29fa7733 Author: Potato <[email protected]> AuthorDate: Mon Feb 24 19:36:11 2025 +0800 optimize autoCleanPartitionTable Signed-off-by: OneSizeFitQuorum <[email protected]> --- .../commons/partition/SeriesPartitionTable.java | 30 ++++++++++++++-------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/partition/SeriesPartitionTable.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/partition/SeriesPartitionTable.java index 450dc7db92a..9b349bdff6d 100644 --- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/partition/SeriesPartitionTable.java +++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/partition/SeriesPartitionTable.java @@ -36,8 +36,10 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Objects; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; @@ -249,15 +251,17 @@ public class SeriesPartitionTable { public List<TTimePartitionSlot> autoCleanPartitionTable( long TTL, TTimePartitionSlot currentTimeSlot) { List<TTimePartitionSlot> removedTimePartitions = new ArrayList<>(); - seriesPartitionMap.forEach( - (timePartitionSlot, consensusGroupIds) -> { - if (timePartitionSlot.getStartTime() + TTL < currentTimeSlot.getStartTime()) { - removedTimePartitions.add(timePartitionSlot); - } - }); - seriesPartitionMap - .entrySet() - .removeIf(entry -> entry.getKey().getStartTime() + TTL < currentTimeSlot.getStartTime()); + Iterator<Entry<TTimePartitionSlot, List<TConsensusGroupId>>> iterator = + seriesPartitionMap.entrySet().iterator(); + + while (iterator.hasNext()) { + Map.Entry<TTimePartitionSlot, List<TConsensusGroupId>> entry = iterator.next(); + TTimePartitionSlot timePartitionSlot = entry.getKey(); + if (timePartitionSlot.getStartTime() + TTL < currentTimeSlot.getStartTime()) { + removedTimePartitions.add(timePartitionSlot); + iterator.remove(); + } + } return removedTimePartitions; } @@ -309,8 +313,12 @@ public class SeriesPartitionTable { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } SeriesPartitionTable that = (SeriesPartitionTable) o; return seriesPartitionMap.equals(that.seriesPartitionMap); }
