Search in sources :

Example 71 with LogicalVariable

use of org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable in project asterixdb by apache.

the class ProducedVariableVisitor method visitUnnestNonMapOperator.

private Void visitUnnestNonMapOperator(AbstractUnnestNonMapOperator op) {
    producedVariables.addAll(op.getVariables());
    LogicalVariable positionalVariable = op.getPositionalVariable();
    if (positionalVariable != null) {
        if (!producedVariables.contains(positionalVariable)) {
            producedVariables.add(positionalVariable);
        }
    }
    return null;
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)

Example 72 with LogicalVariable

use of org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable in project asterixdb by apache.

the class SchemaVariableVisitor method visitDistinctOperator.

@Override
public Void visitDistinctOperator(DistinctOperator op, Void arg) throws AlgebricksException {
    List<LogicalVariable> allLiveVars = new ArrayList<LogicalVariable>();
    for (Mutable<ILogicalOperator> c : op.getInputs()) {
        VariableUtilities.getLiveVariables(c.getValue(), allLiveVars);
    }
    VariableUtilities.getProducedVariables(op, allLiveVars);
    /** put distinct vars first */
    schemaVariables.addAll(op.getDistinctByVarList());
    /** then other live vars */
    for (LogicalVariable var : allLiveVars) {
        if (!schemaVariables.contains(var)) {
            schemaVariables.add(var);
        }
    }
    return null;
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) ArrayList(java.util.ArrayList)

Example 73 with LogicalVariable

use of org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable in project asterixdb by apache.

the class LogicalOperatorDeepCopyWithNewVariablesVisitor method visitUnionOperator.

@Override
public ILogicalOperator visitUnionOperator(UnionAllOperator op, ILogicalOperator arg) throws AlgebricksException {
    List<Mutable<ILogicalOperator>> copiedInputs = new ArrayList<>();
    for (Mutable<ILogicalOperator> childRef : op.getInputs()) {
        copiedInputs.add(deepCopyOperatorReference(childRef, null));
    }
    List<List<LogicalVariable>> liveVarsInInputs = new ArrayList<>();
    for (Mutable<ILogicalOperator> inputOpRef : copiedInputs) {
        List<LogicalVariable> liveVars = new ArrayList<>();
        VariableUtilities.getLiveVariables(inputOpRef.getValue(), liveVars);
        liveVarsInInputs.add(liveVars);
    }
    List<LogicalVariable> liveVarsInLeftInput = liveVarsInInputs.get(0);
    List<LogicalVariable> liveVarsInRightInput = liveVarsInInputs.get(1);
    List<Triple<LogicalVariable, LogicalVariable, LogicalVariable>> copiedTriples = new ArrayList<>();
    int index = 0;
    for (Triple<LogicalVariable, LogicalVariable, LogicalVariable> triple : op.getVariableMappings()) {
        LogicalVariable producedVar = deepCopyVariable(triple.third);
        Triple<LogicalVariable, LogicalVariable, LogicalVariable> copiedTriple = new Triple<>(liveVarsInLeftInput.get(index), liveVarsInRightInput.get(index), producedVar);
        copiedTriples.add(copiedTriple);
        ++index;
    }
    UnionAllOperator opCopy = new UnionAllOperator(copiedTriples);
    deepCopyInputsAnnotationsAndExecutionMode(op, arg, opCopy);
    return opCopy;
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) ArrayList(java.util.ArrayList) Triple(org.apache.hyracks.algebricks.common.utils.Triple) Mutable(org.apache.commons.lang3.mutable.Mutable) UnionAllOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.UnionAllOperator) List(java.util.List) ArrayList(java.util.ArrayList)

Example 74 with LogicalVariable

use of org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable in project asterixdb by apache.

the class OperatorDeepCopyVisitor method visitTokenizeOperator.

@Override
public ILogicalOperator visitTokenizeOperator(TokenizeOperator op, Void arg) throws AlgebricksException {
    List<Mutable<ILogicalExpression>> newPrimaryKeyExpressions = new ArrayList<>();
    deepCopyExpressionRefs(newPrimaryKeyExpressions, op.getPrimaryKeyExpressions());
    List<Mutable<ILogicalExpression>> newSecondaryKeyExpressions = new ArrayList<>();
    deepCopyExpressionRefs(newSecondaryKeyExpressions, op.getSecondaryKeyExpressions());
    List<LogicalVariable> newTokenizeVars = new ArrayList<>();
    deepCopyVars(newTokenizeVars, op.getTokenizeVars());
    Mutable<ILogicalExpression> newFilterExpression = new MutableObject<>(((AbstractLogicalExpression) op.getFilterExpression()).cloneExpression());
    List<Object> newTokenizeVarTypes = new ArrayList<>();
    deepCopyObjects(newTokenizeVarTypes, op.getTokenizeVarTypes());
    TokenizeOperator tokenizeOp = new TokenizeOperator(op.getDataSourceIndex(), newPrimaryKeyExpressions, newSecondaryKeyExpressions, newTokenizeVars, newFilterExpression, op.getOperation(), op.isBulkload(), op.isPartitioned(), newTokenizeVarTypes);
    return tokenizeOp;
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) Mutable(org.apache.commons.lang3.mutable.Mutable) ILogicalExpression(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression) TokenizeOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.TokenizeOperator) ArrayList(java.util.ArrayList) MutableObject(org.apache.commons.lang3.mutable.MutableObject) MutableObject(org.apache.commons.lang3.mutable.MutableObject)

Example 75 with LogicalVariable

use of org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable in project asterixdb by apache.

the class LogicalOperatorDeepCopyWithNewVariablesVisitor method deepCopyVariable.

private LogicalVariable deepCopyVariable(LogicalVariable var) {
    if (var == null) {
        return null;
    }
    LogicalVariable givenVarReplacement = outputVarToInputVarMapping.get(var);
    if (givenVarReplacement != null) {
        inputVarToOutputVarMapping.put(var, givenVarReplacement);
        return givenVarReplacement;
    }
    LogicalVariable varCopy = inputVarToOutputVarMapping.get(var);
    if (varCopy == null) {
        varCopy = varContext.newVar();
        inputVarToOutputVarMapping.put(var, varCopy);
    }
    return varCopy;
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)

Aggregations

LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)376 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)196 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)182 ArrayList (java.util.ArrayList)171 Mutable (org.apache.commons.lang3.mutable.Mutable)136 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)127 AbstractLogicalOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator)92 AssignOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator)79 Pair (org.apache.hyracks.algebricks.common.utils.Pair)75 HashSet (java.util.HashSet)60 MutableObject (org.apache.commons.lang3.mutable.MutableObject)60 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)60 ILogicalPlan (org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan)54 ScalarFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression)46 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)36 GroupByOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator)33 ConstantExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression)32 AggregateOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AggregateOperator)28 FunctionalDependency (org.apache.hyracks.algebricks.core.algebra.properties.FunctionalDependency)28 IAType (org.apache.asterix.om.types.IAType)27