You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "MarcosZyk (via GitHub)" <gi...@apache.org> on 2024/02/22 06:36:12 UTC

Re: [PR] PBTree: Implement dual-buffer container for MNode management [iotdb]

MarcosZyk commented on code in PR #12048:
URL: https://github.com/apache/iotdb/pull/12048#discussion_r1498699673


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/memory/MemoryManager.java:
##########
@@ -322,6 +323,11 @@ public ICachedMNode next() {
     private void tryGetNext() {
       ICachedMNode node;
       CacheEntry cacheEntry;
+      if (!bufferedNodeIterator.hasNext() && status == 0) {
+        // 此时说明NewChildBuffer的flushingBuffer已经遍历完毕,需要遍历UpdateChildBuffer的flushingBuffer

Review Comment:
   Comments shall be in English.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/mnode/container/IMNodeChildBuffer.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.schemaengine.schemaregion.mtree.impl.pbtree.mnode.container;
+
+import org.apache.iotdb.commons.schema.node.utils.IMNodeContainer;
+import org.apache.iotdb.db.schemaengine.schemaregion.mtree.impl.pbtree.mnode.ICachedMNode;
+
+import java.util.Iterator;
+import java.util.Map;
+
+public interface IMNodeChildBuffer extends IMNodeContainer<ICachedMNode> {
+
+  Iterator<ICachedMNode> getMNodeChildBufferIterator();
+
+  Map<String, ICachedMNode> getFlushingBuffer();
+
+  Map<String, ICachedMNode> getReceivingBuffer();
+
+  void transferReceivingBufferToFlushingBuffer();
+
+  ICachedMNode removeFromFlushingBuffer(Object key);

Review Comment:
   Add javadoc to describe the use case of each method.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/mnode/container/CachedMNodeContainer.java:
##########
@@ -425,14 +416,10 @@ private boolean changeStatus() {
 
   private class BufferIterator implements Iterator<ICachedMNode> {

Review Comment:
   It seems this class can be removed since newChildBuffer.iterator can be used directly.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/memory/MemoryManager.java:
##########
@@ -338,8 +344,13 @@ private void tryGetNext() {
           cacheEntry = getCacheEntry(node);
 
           synchronized (cacheEntry) {
-            cacheEntry.setVolatile(false);
-            memoryStatistics.removeVolatileNode();
+            if (status == 1
+                && container.getUpdatedChildReceivingBuffer().containsKey(node.getName())) {
+              // 此时是处于updatebuffer当中,此时需要判断cacheEntry在updatebuffer的receivingbuffer当中是否有重复点,如果没有再设置为false
+            } else {
+              cacheEntry.setVolatile(false);
+              memoryStatistics.removeVolatileNode();
+            }
             container.moveMNodeToCache(node.getName());

Review Comment:
   These three operations belong to one case.



-- 
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