You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2021/08/13 10:03:46 UTC

[iotdb] branch rel/0.12 updated: [To rel/0.12] Fix compaction lost ChunkGroupMetadata (#3737)

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

qiaojialin pushed a commit to branch rel/0.12
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/0.12 by this push:
     new 2fac702  [To rel/0.12] Fix compaction lost ChunkGroupMetadata (#3737)
2fac702 is described below

commit 2fac70273560bf58d405c61f0ef4fccffcf78479
Author: liuxuxin <37...@users.noreply.github.com>
AuthorDate: Fri Aug 13 18:03:22 2021 +0800

    [To rel/0.12] Fix compaction lost ChunkGroupMetadata (#3737)
---
 .../compaction/utils/CompactionLogAnalyzer.java      | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/compaction/utils/CompactionLogAnalyzer.java b/server/src/main/java/org/apache/iotdb/db/engine/compaction/utils/CompactionLogAnalyzer.java
index 51662b2..6bf36f6 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/compaction/utils/CompactionLogAnalyzer.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/compaction/utils/CompactionLogAnalyzer.java
@@ -39,8 +39,8 @@ public class CompactionLogAnalyzer {
   public static final String STR_DEVICE_OFFSET_SEPARATOR = " ";
 
   private File logFile;
-  private Set<String> deviceSet = new HashSet<>();
-  private long offset = 0;
+  private List<String> deviceList = new ArrayList<>();
+  private List<Long> offsets = new ArrayList<>();
   private List<String> sourceFiles = new ArrayList<>();
   private String targetFile = null;
   private boolean isSeq = false;
@@ -78,8 +78,8 @@ public class CompactionLogAnalyzer {
             break;
           default:
             int separatorIndex = currLine.lastIndexOf(STR_DEVICE_OFFSET_SEPARATOR);
-            deviceSet.add(currLine.substring(0, separatorIndex));
-            offset = Long.parseLong(currLine.substring(separatorIndex + 1));
+            deviceList.add(currLine.substring(0, separatorIndex));
+            offsets.add(Long.parseLong(currLine.substring(separatorIndex + 1)));
             break;
         }
       }
@@ -87,11 +87,19 @@ public class CompactionLogAnalyzer {
   }
 
   public Set<String> getDeviceSet() {
-    return deviceSet;
+    if (offsets.size() < 2) {
+      return new HashSet<>();
+    } else {
+      return new HashSet<>(deviceList.subList(0, deviceList.size() - 1));
+    }
   }
 
   public long getOffset() {
-    return offset;
+    if (offsets.size() > 2) {
+      return offsets.get(offsets.size() - 2);
+    } else {
+      return 0;
+    }
   }
 
   public List<String> getSourceFiles() {