Search in sources :

Example 21 with IPartitioningProperty

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);
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) StructuralPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector) HashMap(java.util.HashMap) OrderColumn(org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn) ArrayList(java.util.ArrayList) IPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty) LocalOrderProperty(org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty) IntersectOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator) ILocalStructuralProperty(org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty)

Example 22 with IPartitioningProperty

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);
}
Also used : StructuralPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector) AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) NotImplementedException(org.apache.hyracks.algebricks.common.exceptions.NotImplementedException) IPhysicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector) IPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty)

Example 23 with IPartitioningProperty

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);
}
Also used : StructuralPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector) GroupByOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) ArrayList(java.util.ArrayList) IPhysicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector) ILocalStructuralProperty(org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty) IPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty)

Example 24 with IPartitioningProperty

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);
        }
    }
}
Also used : AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) IPhysicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector) IPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty)

Example 25 with IPartitioningProperty

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;
}
Also used : AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) ArrayList(java.util.ArrayList) IPhysicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector) IPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty)

Aggregations

IPartitioningProperty (org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty)25 StructuralPropertiesVector (org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector)20 ArrayList (java.util.ArrayList)13 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)12 AbstractLogicalOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator)12 ILocalStructuralProperty (org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty)10 UnorderedPartitionedProperty (org.apache.hyracks.algebricks.core.algebra.properties.UnorderedPartitionedProperty)9 IPhysicalPropertiesVector (org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector)8 PhysicalRequirements (org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements)7 OrderColumn (org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn)6 ListSet (org.apache.hyracks.algebricks.common.utils.ListSet)5 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)5 LocalOrderProperty (org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty)5 RandomPartitioningProperty (org.apache.hyracks.algebricks.core.algebra.properties.RandomPartitioningProperty)4 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 Mutable (org.apache.commons.lang3.mutable.Mutable)2 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)2 NotImplementedException (org.apache.hyracks.algebricks.common.exceptions.NotImplementedException)2