Search in sources :

Example 31 with StructuralPropertiesVector

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

the class UnionAllPOperator method getRequiredPropertiesForChildren.

@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
    StructuralPropertiesVector pv0 = OperatorPropertiesUtil.checkUnpartitionedAndGetPropertiesVector(op, new StructuralPropertiesVector(new RandomPartitioningProperty(context.getComputationNodeDomain()), null));
    StructuralPropertiesVector pv1 = OperatorPropertiesUtil.checkUnpartitionedAndGetPropertiesVector(op, new StructuralPropertiesVector(new RandomPartitioningProperty(context.getComputationNodeDomain()), null));
    return new PhysicalRequirements(new StructuralPropertiesVector[] { pv0, pv1 }, IPartitioningRequirementsCoordinator.NO_COORDINATION);
}
Also used : StructuralPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector) RandomPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.RandomPartitioningProperty) PhysicalRequirements(org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements)

Example 32 with StructuralPropertiesVector

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

the class UnionAllPOperator method computeDeliveredProperties.

@Override
public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) {
    AbstractLogicalOperator op2 = (AbstractLogicalOperator) op.getInputs().get(0).getValue();
    IPartitioningProperty pp = op2.getDeliveredPhysicalProperties().getPartitioningProperty();
    this.deliveredProperties = new StructuralPropertiesVector(pp, new ArrayList<>(0));
}
Also used : StructuralPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector) AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) ArrayList(java.util.ArrayList) IPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty)

Example 33 with StructuralPropertiesVector

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

the class EnforceStructuralPropertiesRule method rewritePre.

@Override
public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException {
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    // wait for the physical operators to be set first
    if (op.getPhysicalOperator() == null) {
        return false;
    }
    if (context.checkIfInDontApplySet(this, op)) {
        return false;
    }
    List<FunctionalDependency> fds = context.getFDList(op);
    if (fds != null && !fds.isEmpty()) {
        return false;
    }
    // These are actually logical constraints, so they could be pre-computed
    // somewhere else, too.
    physicalOptimizationConfig = context.getPhysicalOptimizationConfig();
    AlgebricksConfig.ALGEBRICKS_LOGGER.fine(">>>> Optimizing operator " + op.getPhysicalOperator() + ".\n");
    PhysicalOptimizationsUtil.computeFDsAndEquivalenceClasses(op, context);
    StructuralPropertiesVector pvector = new StructuralPropertiesVector(new RandomPartitioningProperty(context.getComputationNodeDomain()), new LinkedList<ILocalStructuralProperty>());
    boolean changed = physOptimizeOp(opRef, pvector, false, context);
    op.computeDeliveredPhysicalProperties(context);
    AlgebricksConfig.ALGEBRICKS_LOGGER.finest(">>>> Structural properties for " + op.getPhysicalOperator() + ": " + op.getDeliveredPhysicalProperties() + "\n");
    context.addToDontApplySet(this, opRef.getValue());
    return changed;
}
Also used : StructuralPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector) AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) FunctionalDependency(org.apache.hyracks.algebricks.core.algebra.properties.FunctionalDependency) RandomPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.RandomPartitioningProperty) ILocalStructuralProperty(org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty)

Example 34 with StructuralPropertiesVector

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

the class BTreeSearchPOperator method getRequiredPropertiesForChildren.

@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
    if (requiresBroadcast) {
        // For primary indexes optimizing an equality condition we can reduce the broadcast requirement to hash partitioning.
        if (isPrimaryIndex && isEqCondition) {
            // If this is a composite primary index, then all of the keys should be provided.
            Index searchIndex = ((DataSourceIndex) idx).getIndex();
            int numberOfKeyFields = searchIndex.getKeyFieldNames().size();
            if (numberOfKeyFields < 2 || (lowKeyVarList.size() == numberOfKeyFields && highKeyVarList.size() == numberOfKeyFields)) {
                StructuralPropertiesVector[] pv = new StructuralPropertiesVector[1];
                ListSet<LogicalVariable> searchKeyVars = new ListSet<>();
                searchKeyVars.addAll(lowKeyVarList);
                searchKeyVars.addAll(highKeyVarList);
                // Also, add a local sorting property to enforce a sort before the primary-index operator.
                List<ILocalStructuralProperty> propsLocal = new ArrayList<>();
                List<OrderColumn> orderColumns = new ArrayList<>();
                for (LogicalVariable orderVar : searchKeyVars) {
                    orderColumns.add(new OrderColumn(orderVar, OrderKind.ASC));
                }
                propsLocal.add(new LocalOrderProperty(orderColumns));
                pv[0] = new StructuralPropertiesVector(new UnorderedPartitionedProperty(searchKeyVars, domain), propsLocal);
                return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION);
            }
        }
        StructuralPropertiesVector[] pv = new StructuralPropertiesVector[1];
        pv[0] = new StructuralPropertiesVector(new BroadcastPartitioningProperty(domain), null);
        return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION);
    } else {
        return super.getRequiredPropertiesForChildren(op, reqdByParent, context);
    }
}
Also used : StructuralPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector) LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) UnorderedPartitionedProperty(org.apache.hyracks.algebricks.core.algebra.properties.UnorderedPartitionedProperty) BroadcastPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.BroadcastPartitioningProperty) OrderColumn(org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn) DataSourceIndex(org.apache.asterix.metadata.declared.DataSourceIndex) IDataSourceIndex(org.apache.hyracks.algebricks.core.algebra.metadata.IDataSourceIndex) ArrayList(java.util.ArrayList) DataSourceIndex(org.apache.asterix.metadata.declared.DataSourceIndex) Index(org.apache.asterix.metadata.entities.Index) IDataSourceIndex(org.apache.hyracks.algebricks.core.algebra.metadata.IDataSourceIndex) AlgebricksPartitionConstraint(org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint) PhysicalRequirements(org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements) ListSet(org.apache.hyracks.algebricks.common.utils.ListSet) LocalOrderProperty(org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty) ILocalStructuralProperty(org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty)

Example 35 with StructuralPropertiesVector

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

StructuralPropertiesVector (org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector)45 ArrayList (java.util.ArrayList)22 ILocalStructuralProperty (org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty)22 PhysicalRequirements (org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements)21 IPartitioningProperty (org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty)20 AbstractLogicalOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator)19 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)18 IPhysicalPropertiesVector (org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector)13 LocalOrderProperty (org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty)12 OrderColumn (org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn)12 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)11 UnorderedPartitionedProperty (org.apache.hyracks.algebricks.core.algebra.properties.UnorderedPartitionedProperty)9 ListSet (org.apache.hyracks.algebricks.common.utils.ListSet)7 BroadcastPartitioningProperty (org.apache.hyracks.algebricks.core.algebra.properties.BroadcastPartitioningProperty)7 LinkedList (java.util.LinkedList)6 RandomPartitioningProperty (org.apache.hyracks.algebricks.core.algebra.properties.RandomPartitioningProperty)6 ILogicalPlan (org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan)5 GroupByOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator)5 HashMap (java.util.HashMap)3 NotImplementedException (org.apache.hyracks.algebricks.common.exceptions.NotImplementedException)3