neuyilan commented on a change in pull request #2454:
URL: https://github.com/apache/iotdb/pull/2454#discussion_r554983918



##########
File path: 
cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterPlanRouter.java
##########
@@ -155,6 +158,40 @@ private PartitionGroup routePlan(ShowChildPathsPlan plan) {
     return Collections.singletonMap(plan, partitionGroup);
   }
 
+  private Map<PhysicalPlan, PartitionGroup> 
splitAndRoutePlan(InsertMultiTabletPlan plan)
+      throws MetadataException {
+    Map<PartitionGroup, InsertMultiTabletPlan> pgInsertMultiTabletPlanMap = 
new HashMap<>();
+    for (int i = 0; i < plan.getInsertTabletPlanList().size(); i++) {
+      InsertTabletPlan insertTabletPlan = 
plan.getInsertTabletPlanList().get(i);
+      Map<PhysicalPlan, PartitionGroup> tmpResult = 
splitAndRoutePlan(insertTabletPlan);
+      for (Map.Entry<PhysicalPlan, PartitionGroup> entry : 
tmpResult.entrySet()) {
+        InsertTabletPlan tmpPlan = (InsertTabletPlan) entry.getKey();
+        PartitionGroup tmpPg = entry.getValue();
+
+        InsertMultiTabletPlan pgPlan = pgInsertMultiTabletPlanMap.get(tmpPg);
+        if (pgPlan == null) {
+          List<InsertTabletPlan> insertTabletPlanList = new ArrayList<>();
+          List<Integer> parentInsetTablePlanIndexList = new ArrayList<>();
+          insertTabletPlanList.add(tmpPlan);
+          parentInsetTablePlanIndexList.add(i);
+          InsertMultiTabletPlan insertMultiTabletPlan = new 
InsertMultiTabletPlan(
+              insertTabletPlanList, parentInsetTablePlanIndexList);
+          pgInsertMultiTabletPlanMap.put(tmpPg, insertMultiTabletPlan);
+        } else {
+          pgPlan.addInsertTabletPlan(tmpPlan, i);
+          pgInsertMultiTabletPlanMap.put(tmpPg, pgPlan);

Review comment:
       it's unnecessary, I'll remove it
    




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to