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 2020/06/04 09:17:15 UTC

[incubator-iotdb] branch remove_while created (now aeeb388)

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

qiaojialin pushed a change to branch remove_while
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.


      at aeeb388  use lock instead while

This branch includes the following new commits:

     new aeeb388  use lock instead while

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.



[incubator-iotdb] 01/01: use lock instead while

Posted by qi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch remove_while
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit aeeb38818bf7b46df7ea33f3eecb1defa972c72b
Author: qiaojialin <64...@qq.com>
AuthorDate: Thu Jun 4 17:16:57 2020 +0800

    use lock instead while
---
 .../db/engine/storagegroup/StorageGroupProcessor.java  |  4 ++--
 .../java/org/apache/iotdb/db/metadata/MManager.java    | 18 ++++++------------
 .../org/apache/iotdb/db/qp/executor/PlanExecutor.java  |  4 ++--
 3 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
index 18bd93c..8042e05 100755
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
@@ -768,7 +768,7 @@ public class StorageGroupProcessor {
       String[] measurementList = plan.getMeasurements();
       for (int i = 0; i < measurementList.length; i++) {
         // Update cached last value with high priority
-        ((LeafMNode) MManager.getChild(node, measurementList[i]))
+        ((LeafMNode) manager.getChild(node, measurementList[i]))
             .updateCachedLast(plan.composeLastTimeValuePair(i), true, latestFlushedTime);
       }
     } catch (MetadataException e) {
@@ -823,7 +823,7 @@ public class StorageGroupProcessor {
           continue;
         }
         // Update cached last value with high priority
-        ((LeafMNode) MManager.getChild(node, measurementList[i]))
+        ((LeafMNode) manager.getChild(node, measurementList[i]))
             .updateCachedLast(plan.composeTimeValuePair(i), true, latestFlushedTime);
       }
     } catch (MetadataException e) {
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
index c754c76..6a02e7b 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
@@ -930,19 +930,13 @@ public class MManager {
         path, config.isAutoCreateSchemaEnabled(), config.getDefaultStorageGroupLevel());
   }
 
-  public static MNode getChild(MNode parent, String child) {
-    MNode childNode = parent.getChild(child);
-    int tempCount = 0;
-    while (childNode == null) {
-      tempCount ++;
-      if (tempCount % 10000 == 0) {
-        throw new RuntimeException(
-            String
-                .format("can not get child [%s] from parent [%s]", child, parent.getName()));
-      }
-      childNode = parent.getChild(child);
+  public MNode getChild(MNode parent, String child) {
+    lock.readLock().lock();
+    try {
+      return parent.getChild(child);
+    } finally {
+      lock.readLock().unlock();
     }
-    return childNode;
   }
 
   /**
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
index 48697ee..14f78a9 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
@@ -886,7 +886,7 @@ public class PlanExecutor implements IPlanExecutor {
             Path path = new Path(deviceId, measurement);
             internalCreateTimeseries(path.toString(), dataType);
           }
-          LeafMNode measurementNode = (LeafMNode) MManager.getChild(node, measurement);
+          LeafMNode measurementNode = (LeafMNode) mManager.getChild(node, measurement);
 
           schemas[i] = measurementNode.getSchema();
           // reset measurement to common name instead of alias
@@ -1032,7 +1032,7 @@ public class PlanExecutor implements IPlanExecutor {
           internalCreateTimeseries(path.getFullPath(), dataType);
 
         }
-        LeafMNode measurementNode = (LeafMNode) MManager.getChild(node, measurement);
+        LeafMNode measurementNode = (LeafMNode) mManager.getChild(node, measurement);
 
         // check data type
         if (measurementNode.getSchema().getType() != insertTabletPlan.getDataTypes()[i]) {