Search in sources :

Example 16 with IPartitioningProperty

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

the class IsomorphismOperatorVisitor method visitExchangeOperator.

@Override
public Boolean visitExchangeOperator(ExchangeOperator op, ILogicalOperator arg) throws AlgebricksException {
    AbstractLogicalOperator aop = (AbstractLogicalOperator) arg;
    if (aop.getOperatorTag() != LogicalOperatorTag.EXCHANGE) {
        return Boolean.FALSE;
    }
    // require the same partition property
    if (!(op.getPhysicalOperator().getOperatorTag() == aop.getPhysicalOperator().getOperatorTag())) {
        return Boolean.FALSE;
    }
    variableMapping.clear();
    IsomorphismUtilities.mapVariablesTopDown(op, arg, variableMapping);
    IPhysicalPropertiesVector properties = op.getPhysicalOperator().getDeliveredProperties();
    IPhysicalPropertiesVector propertiesArg = aop.getPhysicalOperator().getDeliveredProperties();
    if (properties == null && propertiesArg == null) {
        return Boolean.TRUE;
    }
    if (properties == null || propertiesArg == null) {
        return Boolean.FALSE;
    }
    IPartitioningProperty partProp = properties.getPartitioningProperty();
    IPartitioningProperty partPropArg = propertiesArg.getPartitioningProperty();
    if (!partProp.getPartitioningType().equals(partPropArg.getPartitioningType())) {
        return Boolean.FALSE;
    }
    List<LogicalVariable> columns = new ArrayList<LogicalVariable>();
    partProp.getColumns(columns);
    List<LogicalVariable> columnsArg = new ArrayList<LogicalVariable>();
    partPropArg.getColumns(columnsArg);
    if (columns.size() != columnsArg.size()) {
        return Boolean.FALSE;
    }
    if (columns.size() == 0) {
        return Boolean.TRUE;
    }
    for (int i = 0; i < columnsArg.size(); i++) {
        LogicalVariable rightVar = columnsArg.get(i);
        LogicalVariable leftVar = variableMapping.get(rightVar);
        if (leftVar != null) {
            columnsArg.set(i, leftVar);
        }
    }
    return VariableUtilities.varListEqualUnordered(columns, columnsArg);
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) ArrayList(java.util.ArrayList) IPhysicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector) IPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty)

Example 17 with IPartitioningProperty

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

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

the class DataSourcePartitioningProvider method computePropertiesVector.

@Override
public IPhysicalPropertiesVector computePropertiesVector(List<LogicalVariable> scanVariables) {
    IPhysicalPropertiesVector propsVector;
    IPartitioningProperty pp;
    List<ILocalStructuralProperty> propsLocal = new ArrayList<>();
    switch(ds.getDatasourceType()) {
        case DataSource.Type.LOADABLE:
        case DataSource.Type.EXTERNAL_DATASET:
            pp = new RandomPartitioningProperty(domain);
            ds.computeLocalStructuralProperties(propsLocal, scanVariables);
            break;
        case DataSource.Type.FEED:
            pp = getFeedPartitioningProperty(ds, domain, scanVariables);
            break;
        case DataSource.Type.INTERNAL_DATASET:
            Set<LogicalVariable> pvars = new ListSet<>();
            pp = getInternalDatasetPartitioningProperty(ds, domain, scanVariables, pvars);
            propsLocal.add(new LocalOrderProperty(getOrderColumns(pvars)));
            break;
        default:
            throw new IllegalArgumentException();
    }
    propsVector = new StructuralPropertiesVector(pp, propsLocal);
    return propsVector;
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) StructuralPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector) ListSet(org.apache.hyracks.algebricks.common.utils.ListSet) LocalOrderProperty(org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty) ArrayList(java.util.ArrayList) IPhysicalPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector) RandomPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.RandomPartitioningProperty) ILocalStructuralProperty(org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty) IPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty)

Example 19 with IPartitioningProperty

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

Example 20 with IPartitioningProperty

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

the class HashPartitionExchangePOperator method computeDeliveredProperties.

@Override
public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) {
    IPartitioningProperty p = new UnorderedPartitionedProperty(new ListSet<LogicalVariable>(hashFields), domain);
    this.deliveredProperties = new StructuralPropertiesVector(p, null);
}
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) 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