use of org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty in project asterixdb by apache.
the class IntersectPOperator method computeDeliveredProperties.
@Override
public void computeDeliveredProperties(ILogicalOperator iop, IOptimizationContext context) throws AlgebricksException {
IntersectOperator op = (IntersectOperator) iop;
IPartitioningProperty pp = op.getInputs().get(0).getValue().getDeliveredPhysicalProperties().getPartitioningProperty();
HashMap<LogicalVariable, LogicalVariable> varMaps = new HashMap<>(op.getOutputVars().size());
for (int i = 0; i < op.getOutputVars().size(); i++) {
varMaps.put(op.getInputVariables(0).get(i), op.getOutputVars().get(i));
}
pp.substituteColumnVars(varMaps);
List<ILocalStructuralProperty> propsLocal = new ArrayList<>();
List<OrderColumn> orderColumns = new ArrayList<>();
for (LogicalVariable var : op.getOutputVars()) {
orderColumns.add(new OrderColumn(var, OrderOperator.IOrder.OrderKind.ASC));
}
propsLocal.add(new LocalOrderProperty(orderColumns));
deliveredProperties = new StructuralPropertiesVector(pp, propsLocal);
}
use of org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty in project asterixdb by apache.
the class NestedLoopJoinPOperator method computeDeliveredProperties.
@Override
public void computeDeliveredProperties(ILogicalOperator iop, IOptimizationContext context) {
if (partitioningType != JoinPartitioningType.BROADCAST) {
throw new NotImplementedException(partitioningType + " nested loop joins are not implemented.");
}
IPartitioningProperty pp;
AbstractLogicalOperator op = (AbstractLogicalOperator) iop;
if (op.getExecutionMode() == AbstractLogicalOperator.ExecutionMode.PARTITIONED) {
AbstractLogicalOperator op2 = (AbstractLogicalOperator) op.getInputs().get(1).getValue();
IPhysicalPropertiesVector pv1 = op2.getPhysicalOperator().getDeliveredProperties();
if (pv1 == null) {
pp = null;
} else {
pp = pv1.getPartitioningProperty();
}
} else {
pp = IPartitioningProperty.UNPARTITIONED;
}
// Nested loop join cannot maintain the local structure property for the probe side
// because of the I/O optimization for the build branch.
this.deliveredProperties = new StructuralPropertiesVector(pp, null);
}
use of org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty in project asterixdb by apache.
the class AbstractPreclusteredGroupByPOperator method computeDeliveredProperties.
// Obs: We don't propagate properties corresponding to decors, since they
// are func. dep. on the group-by variables.
@Override
public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) {
List<ILocalStructuralProperty> propsLocal = new ArrayList<>();
GroupByOperator gby = (GroupByOperator) op;
ILogicalOperator op2 = gby.getInputs().get(0).getValue();
IPhysicalPropertiesVector childProp = op2.getDeliveredPhysicalProperties();
IPartitioningProperty pp = childProp.getPartitioningProperty();
List<ILocalStructuralProperty> childLocals = childProp.getLocalProperties();
if (childLocals == null) {
deliveredProperties = new StructuralPropertiesVector(pp, propsLocal);
return;
}
for (ILocalStructuralProperty lsp : childLocals) {
ILocalStructuralProperty propagatedLsp = getPropagatedProperty(lsp, gby);
if (propagatedLsp != null) {
propsLocal.add(propagatedLsp);
}
}
deliveredProperties = new StructuralPropertiesVector(pp, propsLocal);
}
use of org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty in project asterixdb by apache.
the class EnforceStructuralPropertiesRule method addEnforcers.
private void addEnforcers(AbstractLogicalOperator op, int childIndex, IPhysicalPropertiesVector diffPropertiesVector, IPhysicalPropertiesVector required, IPhysicalPropertiesVector deliveredByChild, INodeDomain domain, boolean nestedPlan, IOptimizationContext context) throws AlgebricksException {
IPartitioningProperty pp = diffPropertiesVector.getPartitioningProperty();
if (pp == null || pp.getPartitioningType() == PartitioningType.UNPARTITIONED) {
addLocalEnforcers(op, childIndex, diffPropertiesVector.getLocalProperties(), nestedPlan, context);
IPhysicalPropertiesVector deliveredByNewChild = ((AbstractLogicalOperator) op.getInputs().get(0).getValue()).getDeliveredPhysicalProperties();
if (!nestedPlan) {
addPartitioningEnforcers(op, childIndex, pp, required, deliveredByNewChild, domain, context);
}
} else {
if (!nestedPlan) {
addPartitioningEnforcers(op, childIndex, pp, required, deliveredByChild, pp.getNodeDomain(), context);
}
AbstractLogicalOperator newChild = (AbstractLogicalOperator) op.getInputs().get(childIndex).getValue();
IPhysicalPropertiesVector newDiff = newPropertiesDiff(newChild, required, true, context);
AlgebricksConfig.ALGEBRICKS_LOGGER.finest(">>>> New properties diff: " + newDiff + "\n");
if (newDiff != null) {
addLocalEnforcers(op, childIndex, newDiff.getLocalProperties(), nestedPlan, context);
}
}
}
use of org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty in project asterixdb by apache.
the class EnforceStructuralPropertiesRule method getStartChildIndex.
// 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, IOptimizationContext context) throws AlgebricksException {
IPhysicalPropertiesVector[] reqdProperties = null;
if (pr != null) {
reqdProperties = pr.getRequiredProperties();
}
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();
// 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;
}
}
return partitioningCompatibleChild;
}
Aggregations