Search in sources :

Example 21 with ProjectOperator

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

the class MoveFreeVariableOperatorOutOfSubplanRule method producedVariablesCanbePropagated.

// Checks whether there is a variable killing operator in the nested pipeline
private boolean producedVariablesCanbePropagated(ILogicalOperator operator) throws AlgebricksException {
    ILogicalOperator currentOperator = operator;
    // Makes sure the produced variables by operator are not killed in the nested pipeline below it.
    while (!currentOperator.getInputs().isEmpty()) {
        LogicalOperatorTag operatorTag = currentOperator.getOperatorTag();
        if (operatorTag == LogicalOperatorTag.AGGREGATE || operatorTag == LogicalOperatorTag.RUNNINGAGGREGATE || operatorTag == LogicalOperatorTag.GROUP) {
            return false;
        }
        if (operatorTag == LogicalOperatorTag.PROJECT) {
            Set<LogicalVariable> producedVars = new HashSet<>();
            VariableUtilities.getProducedVariables(currentOperator, producedVars);
            ProjectOperator projectOperator = (ProjectOperator) currentOperator;
            if (!projectOperator.getVariables().containsAll(producedVars)) {
                return false;
            }
        }
        currentOperator = currentOperator.getInputs().get(0).getValue();
    }
    return true;
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) LogicalOperatorTag(org.apache.hyracks.algebricks.core.algebra.base.LogicalOperatorTag) ProjectOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.ProjectOperator) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) HashSet(java.util.HashSet)

Example 22 with ProjectOperator

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

the class PushProjectDownRule method pushAllProjectionsOnTopOf.

// It does not try to push above another Projection.
private static boolean pushAllProjectionsOnTopOf(Collection<LogicalVariable> toPush, Mutable<ILogicalOperator> opRef, IOptimizationContext context, ILogicalOperator initialOp) throws AlgebricksException {
    if (toPush.isEmpty()) {
        return false;
    }
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    if (context.checkAndAddToAlreadyCompared(initialOp, op)) {
        return false;
    }
    if (op.getOperatorTag() == LogicalOperatorTag.PROJECT) {
        return false;
    }
    ProjectOperator pi2 = new ProjectOperator(new ArrayList<LogicalVariable>(toPush));
    pi2.getInputs().add(new MutableObject<ILogicalOperator>(op));
    opRef.setValue(pi2);
    pi2.setExecutionMode(op.getExecutionMode());
    context.computeAndSetTypeEnvironmentForOperator(pi2);
    return true;
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) ProjectOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.ProjectOperator) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)

Aggregations

ProjectOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.ProjectOperator)22 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)16 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)15 AbstractLogicalOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator)10 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)9 AssignOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator)9 MutableObject (org.apache.commons.lang3.mutable.MutableObject)7 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)7 ArrayList (java.util.ArrayList)6 Mutable (org.apache.commons.lang3.mutable.Mutable)6 ScalarFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression)5 HashSet (java.util.HashSet)4 Pair (org.apache.hyracks.algebricks.common.utils.Pair)4 CommitOperator (org.apache.asterix.algebra.operators.CommitOperator)3 GbyVariableExpressionPair (org.apache.asterix.lang.common.expression.GbyVariableExpressionPair)3 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)3 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)3 AggregateFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression)3 IFunctionInfo (org.apache.hyracks.algebricks.core.algebra.functions.IFunctionInfo)3 DataSourceScanOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.DataSourceScanOperator)3