Search in sources :

Example 96 with AbstractLogicalOperator

use of org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator 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 97 with AbstractLogicalOperator

use of org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator in project asterixdb by apache.

the class IsomorphismOperatorVisitor method visitInsertDeleteUpsertOperator.

@Override
public Boolean visitInsertDeleteUpsertOperator(InsertDeleteUpsertOperator op, ILogicalOperator arg) throws AlgebricksException {
    AbstractLogicalOperator aop = (AbstractLogicalOperator) arg;
    if (aop.getOperatorTag() != LogicalOperatorTag.INSERT_DELETE_UPSERT) {
        return Boolean.FALSE;
    }
    InsertDeleteUpsertOperator insertOpArg = (InsertDeleteUpsertOperator) copyAndSubstituteVar(op, arg);
    boolean isomorphic = VariableUtilities.varListEqualUnordered(op.getSchema(), insertOpArg.getSchema());
    if (!op.getDataSource().equals(insertOpArg.getDataSource())) {
        isomorphic = false;
    }
    if (!op.getPayloadExpression().equals(insertOpArg.getPayloadExpression())) {
        isomorphic = false;
    }
    return isomorphic;
}
Also used : AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) IndexInsertDeleteUpsertOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.IndexInsertDeleteUpsertOperator) InsertDeleteUpsertOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.InsertDeleteUpsertOperator)

Example 98 with AbstractLogicalOperator

use of org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator in project asterixdb by apache.

the class IsomorphismOperatorVisitor method visitSplitOperator.

@Override
public Boolean visitSplitOperator(SplitOperator op, ILogicalOperator arg) throws AlgebricksException {
    AbstractLogicalOperator aop = (AbstractLogicalOperator) arg;
    if (aop.getOperatorTag() != LogicalOperatorTag.SPLIT) {
        return Boolean.FALSE;
    }
    SplitOperator sOpArg = (SplitOperator) copyAndSubstituteVar(op, arg);
    boolean isomorphic = op.getBranchingExpression().getValue().equals(sOpArg.getBranchingExpression().getValue());
    return isomorphic;
}
Also used : AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) SplitOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.SplitOperator)

Example 99 with AbstractLogicalOperator

use of org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator in project asterixdb by apache.

the class IsomorphismOperatorVisitor method visitDistributeResultOperator.

@Override
public Boolean visitDistributeResultOperator(DistributeResultOperator op, ILogicalOperator arg) throws AlgebricksException {
    AbstractLogicalOperator aop = (AbstractLogicalOperator) arg;
    if (aop.getOperatorTag() != LogicalOperatorTag.DISTRIBUTE_RESULT) {
        return Boolean.FALSE;
    }
    DistributeResultOperator writeOpArg = (DistributeResultOperator) copyAndSubstituteVar(op, arg);
    boolean isomorphic = VariableUtilities.varListEqualUnordered(op.getSchema(), writeOpArg.getSchema());
    return isomorphic;
}
Also used : AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) DistributeResultOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.DistributeResultOperator)

Example 100 with AbstractLogicalOperator

use of org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator in project asterixdb by apache.

the class IsomorphismOperatorVisitor method visitUnionOperator.

@Override
public Boolean visitUnionOperator(UnionAllOperator op, ILogicalOperator arg) throws AlgebricksException {
    AbstractLogicalOperator aop = (AbstractLogicalOperator) arg;
    if (aop.getOperatorTag() != LogicalOperatorTag.UNIONALL) {
        return Boolean.FALSE;
    }
    UnionAllOperator unionOpArg = (UnionAllOperator) copyAndSubstituteVar(op, arg);
    List<Triple<LogicalVariable, LogicalVariable, LogicalVariable>> mapping = op.getVariableMappings();
    List<Triple<LogicalVariable, LogicalVariable, LogicalVariable>> mappingArg = unionOpArg.getVariableMappings();
    if (mapping.size() != mappingArg.size()) {
        return Boolean.FALSE;
    }
    return VariableUtilities.varListEqualUnordered(mapping, mappingArg);
}
Also used : Triple(org.apache.hyracks.algebricks.common.utils.Triple) AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) UnionAllOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.UnionAllOperator)

Aggregations

AbstractLogicalOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator)236 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)116 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)91 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)82 ArrayList (java.util.ArrayList)65 Mutable (org.apache.commons.lang3.mutable.Mutable)60 ILogicalPlan (org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan)44 AssignOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator)41 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)34 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)32 HashSet (java.util.HashSet)27 GroupByOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator)24 AggregateOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AggregateOperator)20 AbstractOperatorWithNestedPlans (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractOperatorWithNestedPlans)19 SelectOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.SelectOperator)19 StructuralPropertiesVector (org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector)19 AbstractBinaryJoinOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractBinaryJoinOperator)18 SubplanOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.SubplanOperator)16 UnnestOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.UnnestOperator)16 LinkedList (java.util.LinkedList)14