Search in sources :

Example 11 with IPhysicalPropertiesVector

use of org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector in project asterixdb by apache.

the class SubplanPOperator method computeDeliveredProperties.

@Override
public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) {
    AbstractLogicalOperator op2 = (AbstractLogicalOperator) op.getInputs().get(0).getValue();
    IPhysicalPropertiesVector childsProperties = op2.getPhysicalOperator().getDeliveredProperties();
    List<ILocalStructuralProperty> propsLocal = new ArrayList<>();
    if (childsProperties.getLocalProperties() != null) {
        propsLocal.addAll(childsProperties.getLocalProperties());
    }
    // ... get local properties for newly created variables...
    SubplanOperator subplan = (SubplanOperator) op;
    for (ILogicalPlan plan : subplan.getNestedPlans()) {
        for (Mutable<ILogicalOperator> r : plan.getRoots()) {
            AbstractLogicalOperator rOp = (AbstractLogicalOperator) r.getValue();
            propsLocal.addAll(rOp.getPhysicalOperator().getDeliveredProperties().getLocalProperties());
        }
    }
    deliveredProperties = new StructuralPropertiesVector(childsProperties.getPartitioningProperty(), propsLocal);
}
Also used : StructuralPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector) SubplanOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.SubplanOperator) AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) ArrayList(java.util.ArrayList) ILogicalPlan(org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan) IPhysicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector) ILocalStructuralProperty(org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty)

Example 12 with IPhysicalPropertiesVector

use of org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector in project asterixdb by apache.

the class WriteResultPOperator method getRequiredPropertiesForChildren.

@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
    List<LogicalVariable> scanVariables = new ArrayList<LogicalVariable>();
    scanVariables.addAll(keys);
    scanVariables.add(new LogicalVariable(-1));
    IPhysicalPropertiesVector r = dataSource.getPropertiesProvider().computePropertiesVector(scanVariables);
    IPhysicalPropertiesVector[] requirements = new IPhysicalPropertiesVector[1];
    requirements[0] = r;
    return new PhysicalRequirements(requirements, IPartitioningRequirementsCoordinator.NO_COORDINATION);
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) ArrayList(java.util.ArrayList) IPhysicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector) PhysicalRequirements(org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements)

Example 13 with IPhysicalPropertiesVector

use of org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector 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 14 with IPhysicalPropertiesVector

use of org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector 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)

Example 15 with IPhysicalPropertiesVector

use of org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector 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)

Aggregations

IPhysicalPropertiesVector (org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector)22 ArrayList (java.util.ArrayList)14 StructuralPropertiesVector (org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector)13 AbstractLogicalOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator)12 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)11 ILocalStructuralProperty (org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty)11 IPartitioningProperty (org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty)8 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)6 PhysicalRequirements (org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements)6 ListSet (org.apache.hyracks.algebricks.common.utils.ListSet)4 ILogicalPlan (org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan)4 GroupByOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator)4 LocalOrderProperty (org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty)4 LinkedList (java.util.LinkedList)3 LocalGroupingProperty (org.apache.hyracks.algebricks.core.algebra.properties.LocalGroupingProperty)3 OrderColumn (org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn)3 HashMap (java.util.HashMap)1 Mutable (org.apache.commons.lang3.mutable.Mutable)1 AlgebricksPartitionConstraint (org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint)1 NotImplementedException (org.apache.hyracks.algebricks.common.exceptions.NotImplementedException)1