neuyilan commented on a change in pull request #2454:
URL: https://github.com/apache/iotdb/pull/2454#discussion_r557008867
##########
File path:
cluster/src/main/java/org/apache/iotdb/cluster/query/ClusterPlanRouter.java
##########
@@ -155,6 +158,78 @@ private PartitionGroup routePlan(ShowChildPathsPlan plan) {
return Collections.singletonMap(plan, partitionGroup);
}
+ /**
+ * @param plan InsertMultiTabletPlan
+ * @return key is InsertMultiTabletPlan, value is the partition group the
plan belongs to, all
+ * InsertTabletPlans in InsertMultiTabletPlan belongs to one same storage
group.
+ */
+ private Map<PhysicalPlan, PartitionGroup>
splitAndRoutePlan(InsertMultiTabletPlan plan)
+ throws MetadataException {
+ /*
+ * the key of pgSgPathPlanMap is the partition group; the value is one map,
+ * the key of the map is storage group, the value is the
InsertMultiTabletPlan,
+ * all InsertTabletPlans in InsertMultiTabletPlan belongs to one same
storage group.
+ */
+ Map<PartitionGroup, Map<PartialPath, InsertMultiTabletPlan>>
pgSgPathPlanMap = 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()) {
+ //1. handle the value returned by call
splitAndRoutePlan(InsertTabletPlan)
+ InsertTabletPlan tmpPlan = (InsertTabletPlan) entry.getKey();
+ PartitionGroup tmpPg = entry.getValue();
+ //1.1 the sg that the plan(actually calculated based on device)
belongs to
+ PartialPath tmpSgPath =
IoTDB.metaManager.getStorageGroupPath(tmpPlan.getDeviceId());
+ Map<PartialPath, InsertMultiTabletPlan> sgPathPlanMap =
pgSgPathPlanMap.get(tmpPg);
+ if (sgPathPlanMap == null) {
+ // 2.1 construct the InsertMultiTabletPlan
+ List<InsertTabletPlan> insertTabletPlanList = new ArrayList<>();
+ List<Integer> parentInsetTablePlanIndexList = new ArrayList<>();
+ insertTabletPlanList.add(tmpPlan);
+ parentInsetTablePlanIndexList.add(i);
+ InsertMultiTabletPlan insertMultiTabletPlan = new
InsertMultiTabletPlan(
+ insertTabletPlanList, parentInsetTablePlanIndexList);
+
+ // 2.2 construct the sgPathPlanMap
+ sgPathPlanMap = new HashMap<>();
+ sgPathPlanMap.put(tmpSgPath, insertMultiTabletPlan);
+
+ // 2.3 put the sgPathPlanMap to the pgSgPathPlanMap
+ pgSgPathPlanMap.put(tmpPg, sgPathPlanMap);
+ } else {
+ InsertMultiTabletPlan insertMultiTabletPlan =
sgPathPlanMap.get(tmpSgPath);
+ if (insertMultiTabletPlan == null) {
+ List<InsertTabletPlan> insertTabletPlanList = new ArrayList<>();
+ List<Integer> parentInsetTablePlanIndexList = new ArrayList<>();
+ insertTabletPlanList.add(tmpPlan);
+ parentInsetTablePlanIndexList.add(i);
+ insertMultiTabletPlan = new InsertMultiTabletPlan(
+ insertTabletPlanList, parentInsetTablePlanIndexList);
+
+ // 2.4 put the sgPathPlanMap to the pgSgPathPlanMap
+ sgPathPlanMap.put(tmpSgPath, insertMultiTabletPlan);
+ pgSgPathPlanMap.put(tmpPg, sgPathPlanMap);
Review comment:
Thanks, have removed
----------------------------------------------------------------
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]