Search in sources :

Example 6 with LocalOrderProperty

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

the class SortMergeExchangePOperator method computeDeliveredProperties.

@Override
public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) throws AlgebricksException {
    AbstractLogicalOperator inp1 = (AbstractLogicalOperator) op.getInputs().get(0).getValue();
    IPhysicalPropertiesVector pv1 = inp1.getDeliveredPhysicalProperties();
    if (pv1 == null) {
        inp1.computeDeliveredPhysicalProperties(context);
        pv1 = inp1.getDeliveredPhysicalProperties();
    }
    List<OrderColumn> orderColumns = new ArrayList<OrderColumn>();
    List<ILocalStructuralProperty> localProps = new ArrayList<ILocalStructuralProperty>(sortColumns.length);
    for (ILocalStructuralProperty prop : pv1.getLocalProperties()) {
        if (prop.getPropertyType() == PropertyType.LOCAL_ORDER_PROPERTY) {
            LocalOrderProperty lop = (LocalOrderProperty) prop;
            for (OrderColumn oc : lop.getOrderColumns()) {
                if (oc.equals(sortColumns[orderColumns.size()])) {
                    orderColumns.add(oc);
                    if (orderColumns.size() == sortColumns.length) {
                        break;
                    }
                } else {
                    break;
                }
            }
        } else {
            continue;
        }
    }
    if (orderColumns.size() > 0) {
        localProps.add(new LocalOrderProperty(orderColumns));
    }
    this.deliveredProperties = new StructuralPropertiesVector(IPartitioningProperty.UNPARTITIONED, localProps);
}
Also used : StructuralPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector) AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) OrderColumn(org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn) LocalOrderProperty(org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty) ArrayList(java.util.ArrayList) IPhysicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector) ILocalStructuralProperty(org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty)

Example 7 with LocalOrderProperty

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

the class PreSortedDistinctByPOperator method getRequiredPropertiesForChildren.

@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
    StructuralPropertiesVector[] pv = new StructuralPropertiesVector[1];
    List<ILocalStructuralProperty> localProps = new ArrayList<ILocalStructuralProperty>();
    List<OrderColumn> orderColumns = new ArrayList<OrderColumn>();
    for (LogicalVariable column : columnList) {
        orderColumns.add(new OrderColumn(column, OrderKind.ASC));
    }
    localProps.add(new LocalOrderProperty(orderColumns));
    IPartitioningProperty pp = null;
    AbstractLogicalOperator aop = (AbstractLogicalOperator) op;
    if (aop.getExecutionMode() == ExecutionMode.PARTITIONED) {
        pp = new UnorderedPartitionedProperty(new ListSet<LogicalVariable>(columnList), context.getComputationNodeDomain());
    }
    pv[0] = new StructuralPropertiesVector(pp, localProps);
    return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION);
}
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) AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) OrderColumn(org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn) ArrayList(java.util.ArrayList) IPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty) 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 8 with LocalOrderProperty

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

the class SortGroupByPOperator method computeDeliveredProperties.

@Override
public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) {
    List<ILocalStructuralProperty> propsLocal = new LinkedList<ILocalStructuralProperty>();
    GroupByOperator gOp = (GroupByOperator) op;
    Set<LogicalVariable> columnSet = new ListSet<LogicalVariable>();
    List<OrderColumn> ocs = new ArrayList<OrderColumn>();
    if (!columnSet.isEmpty()) {
        propsLocal.add(new LocalGroupingProperty(columnSet));
    }
    for (OrderColumn oc : orderColumns) {
        ocs.add(oc);
    }
    propsLocal.add(new LocalOrderProperty(ocs));
    for (ILogicalPlan p : gOp.getNestedPlans()) {
        for (Mutable<ILogicalOperator> r : p.getRoots()) {
            ILogicalOperator rOp = r.getValue();
            propsLocal.addAll(rOp.getDeliveredPhysicalProperties().getLocalProperties());
        }
    }
    ILogicalOperator op2 = op.getInputs().get(0).getValue();
    IPhysicalPropertiesVector childProp = op2.getDeliveredPhysicalProperties();
    deliveredProperties = new StructuralPropertiesVector(childProp.getPartitioningProperty(), propsLocal);
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) StructuralPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector) GroupByOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator) OrderColumn(org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn) LocalGroupingProperty(org.apache.hyracks.algebricks.core.algebra.properties.LocalGroupingProperty) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) ArrayList(java.util.ArrayList) IPhysicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector) LinkedList(java.util.LinkedList) ListSet(org.apache.hyracks.algebricks.common.utils.ListSet) LocalOrderProperty(org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty) ILogicalPlan(org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan) ILocalStructuralProperty(org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty)

Example 9 with LocalOrderProperty

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

the class SortMergeExchangePOperator method getRequiredPropertiesForChildren.

@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
    List<ILocalStructuralProperty> localProps = new ArrayList<ILocalStructuralProperty>(sortColumns.length);
    localProps.add(new LocalOrderProperty(Arrays.asList(sortColumns)));
    StructuralPropertiesVector[] r = new StructuralPropertiesVector[] { new StructuralPropertiesVector(null, localProps) };
    return new PhysicalRequirements(r, IPartitioningRequirementsCoordinator.NO_COORDINATION);
}
Also used : StructuralPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector) LocalOrderProperty(org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty) ArrayList(java.util.ArrayList) ILocalStructuralProperty(org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty) PhysicalRequirements(org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements)

Example 10 with LocalOrderProperty

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

the class EnforceStructuralPropertiesRule method addLocalEnforcers.

private void addLocalEnforcers(AbstractLogicalOperator op, int i, List<ILocalStructuralProperty> localProperties, boolean nestedPlan, IOptimizationContext context) throws AlgebricksException {
    if (AlgebricksConfig.DEBUG) {
        AlgebricksConfig.ALGEBRICKS_LOGGER.fine(">>>> Adding local enforcers for local props = " + localProperties + "\n");
    }
    if (localProperties == null || localProperties.isEmpty()) {
        return;
    }
    Mutable<ILogicalOperator> topOp = new MutableObject<>();
    topOp.setValue(op.getInputs().get(i).getValue());
    LinkedList<LocalOrderProperty> oList = new LinkedList<>();
    for (ILocalStructuralProperty prop : localProperties) {
        switch(prop.getPropertyType()) {
            case LOCAL_ORDER_PROPERTY:
                {
                    oList.add((LocalOrderProperty) prop);
                    break;
                }
            case LOCAL_GROUPING_PROPERTY:
                {
                    LocalGroupingProperty g = (LocalGroupingProperty) prop;
                    Collection<LogicalVariable> vars = (g.getPreferredOrderEnforcer() != null) ? g.getPreferredOrderEnforcer() : g.getColumnSet();
                    List<OrderColumn> orderColumns = new ArrayList<>();
                    for (LogicalVariable v : vars) {
                        OrderColumn oc = new OrderColumn(v, OrderKind.ASC);
                        orderColumns.add(oc);
                    }
                    LocalOrderProperty lop = new LocalOrderProperty(orderColumns);
                    oList.add(lop);
                    break;
                }
            default:
                {
                    throw new IllegalStateException();
                }
        }
    }
    if (!oList.isEmpty()) {
        topOp = enforceOrderProperties(oList, topOp, nestedPlan, context);
    }
    op.getInputs().set(i, topOp);
    OperatorPropertiesUtil.computeSchemaAndPropertiesRecIfNull((AbstractLogicalOperator) topOp.getValue(), context);
    OperatorManipulationUtil.setOperatorMode(op);
    printOp((AbstractLogicalOperator) topOp.getValue());
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) LocalGroupingProperty(org.apache.hyracks.algebricks.core.algebra.properties.LocalGroupingProperty) OrderColumn(org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn) LinkedList(java.util.LinkedList) LocalOrderProperty(org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty) Collection(java.util.Collection) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) ILocalStructuralProperty(org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty) MutableObject(org.apache.commons.lang3.mutable.MutableObject)

Aggregations

LocalOrderProperty (org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty)19 ArrayList (java.util.ArrayList)18 OrderColumn (org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn)17 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)15 ILocalStructuralProperty (org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty)15 StructuralPropertiesVector (org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector)12 PhysicalRequirements (org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements)8 LinkedList (java.util.LinkedList)5 ListSet (org.apache.hyracks.algebricks.common.utils.ListSet)5 IPartitioningProperty (org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty)5 Mutable (org.apache.commons.lang3.mutable.Mutable)4 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)4 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)4 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)4 IPhysicalPropertiesVector (org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector)4 LocalGroupingProperty (org.apache.hyracks.algebricks.core.algebra.properties.LocalGroupingProperty)4 UnorderedPartitionedProperty (org.apache.hyracks.algebricks.core.algebra.properties.UnorderedPartitionedProperty)4 HashMap (java.util.HashMap)3 MutableObject (org.apache.commons.lang3.mutable.MutableObject)3 AbstractLogicalOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator)3