You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ta...@apache.org on 2025/02/24 11:42:19 UTC

(iotdb) branch tt created (now bc676536aaa)

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

tanxinyu pushed a change to branch tt
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at bc676536aaa optimize autoCleanPartitionTable

This branch includes the following new commits:

     new bc676536aaa optimize autoCleanPartitionTable

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(iotdb) 01/01: optimize autoCleanPartitionTable

Posted by ta...@apache.org.
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 <ta...@apache.org>
AuthorDate: Mon Feb 24 19:36:11 2025 +0800

    optimize autoCleanPartitionTable
    
    Signed-off-by: OneSizeFitQuorum <ta...@apache.org>
---
 .../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);
   }