>From Ali Alsuliman <[email protected]>:
Ali Alsuliman has uploaded this change for review. (
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17234 )
Change subject: WIP: minor clean-up and refactoring
......................................................................
WIP: minor clean-up and refactoring
Change-Id: Iae95e5da91a391bc52a2dd90929516967ec13c93
---
M
hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/EnforceStructuralPropertiesRule.java
1 file changed, 33 insertions(+), 26 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/34/17234/1
diff --git
a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/EnforceStructuralPropertiesRule.java
b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/EnforceStructuralPropertiesRule.java
index 3ae1218..0f707f4 100644
---
a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/EnforceStructuralPropertiesRule.java
+++
b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/EnforceStructuralPropertiesRule.java
@@ -213,7 +213,7 @@
boolean loggerTraceEnabled =
AlgebricksConfig.ALGEBRICKS_LOGGER.isTraceEnabled();
// The child index of the child operator to optimize first.
- int startChildIndex = getStartChildIndex(op, pr, nestedPlan);
+ int startChildIndex = getStartChildIndex(op, pr);
IPartitioningProperty firstDeliveredPartitioning = null;
// Enforce data properties in a top-down manner.
for (j = 0; j < op.getInputs().size(); j++) {
@@ -258,6 +258,9 @@
delivered = newChild.getDeliveredPhysicalProperties();
IPhysicalPropertiesVector newDiff =
newPropertiesDiff(newChild, rqd,
mayExpandPartitioningProperties, context);
+ if (newDiff != null) {
+ throw new IllegalStateException("Still not satisfied:
" + newDiff);
+ }
if (loggerTraceEnabled) {
AlgebricksConfig.ALGEBRICKS_LOGGER.trace(">>>> New
properties diff: " + newDiff + "\n");
}
@@ -328,36 +331,31 @@
// Gets the index of a child to start top-down data property enforcement.
// If there is a partitioning-compatible child with the operator in opRef,
// start from this child; otherwise, start from child zero.
- private int getStartChildIndex(AbstractLogicalOperator op,
PhysicalRequirements pr, boolean nestedPlan) {
- IPhysicalPropertiesVector[] reqdProperties = null;
- if (pr != null) {
- reqdProperties = pr.getRequiredProperties();
+ private static int getStartChildIndex(AbstractLogicalOperator op,
PhysicalRequirements pr) {
+ IPhysicalPropertiesVector[] requiredProps = pr == null ? null :
pr.getRequiredProperties();
+ int firstChild = 0;
+ if (requiredProps == null) {
+ return firstChild;
}
- List<IPartitioningProperty>
deliveredPartitioningPropertiesFromChildren = new ArrayList<>();
- for (Mutable<ILogicalOperator> childRef : op.getInputs()) {
- AbstractLogicalOperator child = (AbstractLogicalOperator)
childRef.getValue();
- deliveredPartitioningPropertiesFromChildren
-
.add(child.getDeliveredPhysicalProperties().getPartitioningProperty());
- }
- int partitioningCompatibleChild = 0;
- for (int i = 0; i < op.getInputs().size(); i++) {
- IPartitioningProperty deliveredPropertyFromChild =
deliveredPartitioningPropertiesFromChildren.get(i);
- if (reqdProperties == null || reqdProperties[i] == null
- || reqdProperties[i].getPartitioningProperty() == null ||
deliveredPropertyFromChild == null
- || reqdProperties[i].getPartitioningProperty()
- .getPartitioningType() !=
deliveredPartitioningPropertiesFromChildren.get(i)
- .getPartitioningType()) {
- continue;
- }
- IPartitioningProperty requiredPropertyForChild =
reqdProperties[i].getPartitioningProperty();
+ List<Mutable<ILogicalOperator>> inputs = op.getInputs();
+ for (int i = 0; i < inputs.size(); i++) {
// If child i's delivered partitioning property already satisfies
the required property, stop and return the child index.
- if
(PropertiesUtil.matchPartitioningProps(requiredPropertyForChild,
deliveredPropertyFromChild, true)) {
- partitioningCompatibleChild = i;
- break;
+ if (requiredProps[i] != null) {
+ IPhysicalPropertiesVector childProp =
inputs.get(i).getValue().getDeliveredPhysicalProperties();
+ IPartitioningProperty deliveredPartitioning =
childProp.getPartitioningProperty();
+ IPartitioningProperty requiredPartitioning =
requiredProps[i].getPartitioningProperty();
+ if (samePartitioningType(requiredPartitioning,
deliveredPartitioning)
+ &&
PropertiesUtil.matchPartitioningProps(requiredPartitioning,
deliveredPartitioning, true)) {
+ return i;
+ }
}
}
- return partitioningCompatibleChild;
+ return firstChild;
+ }
+
+ private static boolean samePartitioningType(IPartitioningProperty p1,
IPartitioningProperty p2) {
+ return p1 != null && p2 != null && p1.getPartitioningType() ==
p2.getPartitioningType();
}
private IPhysicalPropertiesVector
newPropertiesDiff(AbstractLogicalOperator newChild,
--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17234
To unsubscribe, or for help writing mail filters, visit
https://asterix-gerrit.ics.uci.edu/settings
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Change-Id: Iae95e5da91a391bc52a2dd90929516967ec13c93
Gerrit-Change-Number: 17234
Gerrit-PatchSet: 1
Gerrit-Owner: Ali Alsuliman <[email protected]>
Gerrit-MessageType: newchange