Search in sources :

Example 1 with PropagatingTypeEnvironment

use of org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment in project asterixdb by apache.

the class AbstractLogicalOperator method createPropagatingAllInputsTypeEnvironment.

protected PropagatingTypeEnvironment createPropagatingAllInputsTypeEnvironment(ITypingContext ctx) {
    int n = inputs.size();
    ITypeEnvPointer[] envPointers = new ITypeEnvPointer[n];
    for (int i = 0; i < n; i++) {
        envPointers[i] = new OpRefTypeEnvPointer(inputs.get(i), ctx);
    }
    return new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMissableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers);
}
Also used : PropagatingTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment) OpRefTypeEnvPointer(org.apache.hyracks.algebricks.core.algebra.typing.OpRefTypeEnvPointer) ITypeEnvPointer(org.apache.hyracks.algebricks.core.algebra.typing.ITypeEnvPointer)

Example 2 with PropagatingTypeEnvironment

use of org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment in project asterixdb by apache.

the class AssignOperator method computeOutputTypeEnvironment.

@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException {
    PropagatingTypeEnvironment env = createPropagatingAllInputsTypeEnvironment(ctx);
    int n = variables.size();
    for (int i = 0; i < n; i++) {
        env.setVarType(variables.get(i), ctx.getExpressionTypeComputer().getType(expressions.get(i).getValue(), ctx.getMetadataProvider(), env));
        if (expressions.get(i).getValue().getExpressionTag() == LogicalExpressionTag.VARIABLE) {
            LogicalVariable var = ((VariableReferenceExpression) expressions.get(i).getValue()).getVariableReference();
            for (List<LogicalVariable> list : env.getCorrelatedMissableVariableLists()) {
                if (list.contains(var)) {
                    list.add(variables.get(i));
                }
            }
        }
    }
    return env;
}
Also used : PropagatingTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment) LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) VariableReferenceExpression(org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)

Example 3 with PropagatingTypeEnvironment

use of org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment in project asterixdb by apache.

the class SinkOperator method computeOutputTypeEnvironment.

@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException {
    ITypeEnvPointer[] envPointers = new ITypeEnvPointer[inputs.size()];
    for (int i = 0; i < inputs.size(); i++) {
        envPointers[i] = new OpRefTypeEnvPointer(inputs.get(i), ctx);
    }
    PropagatingTypeEnvironment env = new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMissableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers);
    return env;
}
Also used : PropagatingTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment) OpRefTypeEnvPointer(org.apache.hyracks.algebricks.core.algebra.typing.OpRefTypeEnvPointer) ITypeEnvPointer(org.apache.hyracks.algebricks.core.algebra.typing.ITypeEnvPointer)

Example 4 with PropagatingTypeEnvironment

use of org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment in project asterixdb by apache.

the class SubplanOperator method computeOutputTypeEnvironment.

@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException {
    int n = 0;
    for (ILogicalPlan p : nestedPlans) {
        n += p.getRoots().size();
    }
    ITypeEnvPointer[] envPointers = new ITypeEnvPointer[n + 1];
    envPointers[0] = new OpRefTypeEnvPointer(inputs.get(0), ctx);
    int i = 1;
    for (ILogicalPlan p : nestedPlans) {
        for (Mutable<ILogicalOperator> r : p.getRoots()) {
            envPointers[i] = new OpRefTypeEnvPointer(r, ctx);
            i++;
        }
    }
    return new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMissableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers);
}
Also used : PropagatingTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) ILogicalPlan(org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan) OpRefTypeEnvPointer(org.apache.hyracks.algebricks.core.algebra.typing.OpRefTypeEnvPointer) ITypeEnvPointer(org.apache.hyracks.algebricks.core.algebra.typing.ITypeEnvPointer)

Example 5 with PropagatingTypeEnvironment

use of org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment in project asterixdb by apache.

the class LeftOuterJoinOperator method computeOutputTypeEnvironment.

@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException {
    int n = inputs.size();
    ITypeEnvPointer[] envPointers = new ITypeEnvPointer[n];
    for (int i = 0; i < n; i++) {
        envPointers[i] = new OpRefTypeEnvPointer(inputs.get(i), ctx);
    }
    PropagatingTypeEnvironment env = new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMissableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.LEFT_OUTER, envPointers);
    List<LogicalVariable> liveVars = new ArrayList<LogicalVariable>();
    // live variables from outer branch can be null together
    VariableUtilities.getLiveVariables(inputs.get(1).getValue(), liveVars);
    env.getCorrelatedMissableVariableLists().add(liveVars);
    return env;
}
Also used : PropagatingTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment) LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) ArrayList(java.util.ArrayList) OpRefTypeEnvPointer(org.apache.hyracks.algebricks.core.algebra.typing.OpRefTypeEnvPointer) ITypeEnvPointer(org.apache.hyracks.algebricks.core.algebra.typing.ITypeEnvPointer)

Aggregations

PropagatingTypeEnvironment (org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment)10 ITypeEnvPointer (org.apache.hyracks.algebricks.core.algebra.typing.ITypeEnvPointer)7 OpRefTypeEnvPointer (org.apache.hyracks.algebricks.core.algebra.typing.OpRefTypeEnvPointer)6 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)5 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)3 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)3 ArrayList (java.util.ArrayList)2 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)2 ILogicalPlan (org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan)2 IVariableTypeEnvironment (org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment)2 Mutable (org.apache.commons.lang3.mutable.Mutable)1 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)1