Search in sources :

Example 6 with UnorderedPartitionedProperty

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

the class IntersectPOperator method getRequiredPropertiesForChildren.

@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator iop, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
    IntersectOperator intersectOp = (IntersectOperator) iop;
    StructuralPropertiesVector[] pv = new StructuralPropertiesVector[intersectOp.getNumInput()];
    for (int i = 0; i < intersectOp.getNumInput(); i++) {
        List<ILocalStructuralProperty> localProps = new ArrayList<>();
        List<OrderColumn> orderColumns = new ArrayList<>();
        for (LogicalVariable column : intersectOp.getInputVariables(i)) {
            orderColumns.add(new OrderColumn(column, OrderOperator.IOrder.OrderKind.ASC));
        }
        localProps.add(new LocalOrderProperty(orderColumns));
        IPartitioningProperty pp = null;
        if (intersectOp.getExecutionMode() == AbstractLogicalOperator.ExecutionMode.PARTITIONED) {
            Set<LogicalVariable> partitioningVariables = new HashSet<>(intersectOp.getInputVariables(i));
            pp = new UnorderedPartitionedProperty(partitioningVariables, null);
        }
        pv[i] = 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) 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) 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) HashSet(java.util.HashSet)

Example 7 with UnorderedPartitionedProperty

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

the class ExternalGroupByPOperator method getRequiredPropertiesForChildren.

@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
    AbstractLogicalOperator aop = (AbstractLogicalOperator) op;
    if (aop.getExecutionMode() == ExecutionMode.PARTITIONED) {
        StructuralPropertiesVector[] pv = new StructuralPropertiesVector[1];
        pv[0] = new StructuralPropertiesVector(new UnorderedPartitionedProperty(new ListSet<LogicalVariable>(columnSet), context.getComputationNodeDomain()), null);
        return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION);
    } else {
        return emptyUnaryRequirements();
    }
}
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) PhysicalRequirements(org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements)

Example 8 with UnorderedPartitionedProperty

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

the class HashPartitionMergeExchangePOperator method computeDeliveredProperties.

@Override
public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) {
    IPartitioningProperty p = new UnorderedPartitionedProperty(new ListSet<LogicalVariable>(partitionFields), domain);
    AbstractLogicalOperator op2 = (AbstractLogicalOperator) op.getInputs().get(0).getValue();
    List<ILocalStructuralProperty> op2Locals = op2.getDeliveredPhysicalProperties().getLocalProperties();
    List<ILocalStructuralProperty> locals = new ArrayList<ILocalStructuralProperty>();
    for (ILocalStructuralProperty prop : op2Locals) {
        if (prop.getPropertyType() == PropertyType.LOCAL_ORDER_PROPERTY) {
            locals.add(prop);
        } else {
            break;
        }
    }
    this.deliveredProperties = new StructuralPropertiesVector(p, locals);
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) StructuralPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector) UnorderedPartitionedProperty(org.apache.hyracks.algebricks.core.algebra.properties.UnorderedPartitionedProperty) AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) ArrayList(java.util.ArrayList) ILocalStructuralProperty(org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty) IPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty)

Example 9 with UnorderedPartitionedProperty

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

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

the class DataSourcePartitioningProvider method getInternalDatasetPartitioningProperty.

private static IPartitioningProperty getInternalDatasetPartitioningProperty(DataSource ds, INodeDomain domain, List<LogicalVariable> scanVariables, Set<LogicalVariable> pvars) {
    IPartitioningProperty pp;
    if (scanVariables.size() < 2) {
        pp = new RandomPartitioningProperty(domain);
    } else {
        pvars.addAll(ds.getPrimaryKeyVariables(scanVariables));
        pp = new UnorderedPartitionedProperty(pvars, domain);
    }
    return pp;
}
Also used : UnorderedPartitionedProperty(org.apache.hyracks.algebricks.core.algebra.properties.UnorderedPartitionedProperty) RandomPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.RandomPartitioningProperty) IPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty)

Aggregations

UnorderedPartitionedProperty (org.apache.hyracks.algebricks.core.algebra.properties.UnorderedPartitionedProperty)12 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)10 IPartitioningProperty (org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty)9 StructuralPropertiesVector (org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector)9 ArrayList (java.util.ArrayList)7 AbstractLogicalOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator)6 ILocalStructuralProperty (org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty)6 PhysicalRequirements (org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements)6 ListSet (org.apache.hyracks.algebricks.common.utils.ListSet)5 OrderColumn (org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn)5 LocalOrderProperty (org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty)4 RandomPartitioningProperty (org.apache.hyracks.algebricks.core.algebra.properties.RandomPartitioningProperty)4 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)2 NotImplementedException (org.apache.hyracks.algebricks.common.exceptions.NotImplementedException)2 IPhysicalOperator (org.apache.hyracks.algebricks.core.algebra.base.IPhysicalOperator)2 BroadcastPartitioningProperty (org.apache.hyracks.algebricks.core.algebra.properties.BroadcastPartitioningProperty)2