You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/07/19 12:06:25 UTC

[GitHub] [iotdb] zyk990424 commented on a change in pull request #3589: [IOTDB-1498] MNode Abstraction and Structure Improvement

zyk990424 commented on a change in pull request #3589:
URL: https://github.com/apache/iotdb/pull/3589#discussion_r672238184



##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
##########
@@ -313,23 +279,52 @@ private int applyMlog(MLogReader mLogReader) {
     return idx;
   }
 
+  private void checkMTreeModified() {
+    if (logWriter == null || logFile == null) {
+      // the logWriter is not initialized now, we skip the check once.
+      return;
+    }
+    if (System.currentTimeMillis() - logFile.lastModified() < mtreeSnapshotThresholdTime) {
+      if (logger.isDebugEnabled()) {
+        logger.debug(
+            "MTree snapshot need not be created. Time from last modification: {} ms.",
+            System.currentTimeMillis() - logFile.lastModified());
+      }
+    } else if (logWriter.getLogNum() < mtreeSnapshotInterval) {
+      if (logger.isDebugEnabled()) {
+        logger.debug(
+            "MTree snapshot need not be created. New mlog line number: {}.", logWriter.getLogNum());
+      }
+    } else {
+      logger.info(
+          "New mlog line number: {}, time from last modification: {} ms",
+          logWriter.getLogNum(),
+          System.currentTimeMillis() - logFile.lastModified());
+      createMTreeSnapshot();
+    }
+  }
+
+  public void createMTreeSnapshot() {
+    try {
+      mtree.createSnapshot();
+      logWriter.clear();
+    } catch (IOException e) {
+      logger.warn("Failed to create MTree snapshot", e);
+    }
+  }
+
   /** function for clearing MTree */
   public void clear() {
     try {
-      templateMap.clear();
-      this.mtree = new MTree();
+      this.mtree.clear();

Review comment:
       Thanks for reminding.




-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org