JackieTien97 commented on code in PR #12446:
URL: https://github.com/apache/iotdb/pull/12446#discussion_r1595167588
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/SourceRewriter.java:
##########
@@ -719,6 +751,43 @@ private List<PlanNode> processRawSeriesScan(
return Collections.singletonList(parent);
}
+ private List<PlanNode> splitRegionScanNodeByRegion(
+ RegionScanNode node, DistributionPlanContext context) {
+ List<PlanNode> planNodesForRegions = new ArrayList<>();
+ Map<TRegionReplicaSet, Set<PartialPath>> devicesInRegion = new HashMap<>();
+ List<PartialPath> devicesList = node.getDevicePaths();
+ boolean isAllDeviceOnlyInOneRegion = true;
+
+ for (PartialPath device : devicesList) {
+ List<TRegionReplicaSet> dataDistribution =
+ analysis.getPartitionInfoByDevice(device,
context.getPartitionTimeFilter());
+ isAllDeviceOnlyInOneRegion = isAllDeviceOnlyInOneRegion &&
dataDistribution.size() == 1;
+ for (TRegionReplicaSet dataRegion : dataDistribution) {
+ devicesInRegion.computeIfAbsent(dataRegion, k -> new
HashSet<>()).add(device);
+ }
+ }
+
+ context.setAllDeviceOnlyInOneRegion(isAllDeviceOnlyInOneRegion);
+
+ // If there is only one region, return directly
+ if (devicesInRegion.size() == 1) {
+ node.setRegionReplicaSet(devicesInRegion.keySet().iterator().next());
+ planNodesForRegions.add(node);
+ return planNodesForRegions;
+ }
+
+ for (Map.Entry<TRegionReplicaSet, Set<PartialPath>> entry :
devicesInRegion.entrySet()) {
+ RegionScanNode split = (RegionScanNode) node.clone();
+ split.setPlanNodeId(context.queryContext.getQueryId().genPlanNodeId());
+ split.setRegionReplicaSet(entry.getKey());
+ split.setDevicePaths(entry.getValue());
+ split.setOutputCount(isAllDeviceOnlyInOneRegion);
+ planNodesForRegions.add(split);
+ }
Review Comment:
getDevices may be duplicate.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]