Search in sources :

Example 1 with ITypeEnvPointer

use of org.apache.hyracks.algebricks.core.algebra.typing.ITypeEnvPointer 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 ITypeEnvPointer

use of org.apache.hyracks.algebricks.core.algebra.typing.ITypeEnvPointer 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 3 with ITypeEnvPointer

use of org.apache.hyracks.algebricks.core.algebra.typing.ITypeEnvPointer 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 4 with ITypeEnvPointer

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

Example 5 with ITypeEnvPointer

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

the class GroupByOperator 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];
    int i = 0;
    for (ILogicalPlan p : nestedPlans) {
        for (Mutable<ILogicalOperator> r : p.getRoots()) {
            envPointers[i] = new OpRefTypeEnvPointer(r, ctx);
            i++;
        }
    }
    IVariableTypeEnvironment env = new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMissableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers);
    ILogicalOperator child = inputs.get(0).getValue();
    IVariableTypeEnvironment env2 = ctx.getOutputTypeEnvironment(child);
    for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : getGroupByList()) {
        ILogicalExpression expr = p.second.getValue();
        if (p.first != null) {
            env.setVarType(p.first, env2.getType(expr));
            if (expr.getExpressionTag() == LogicalExpressionTag.VARIABLE) {
                LogicalVariable v1 = ((VariableReferenceExpression) expr).getVariableReference();
                env.setVarType(v1, env2.getVarType(v1));
            }
        } else {
            VariableReferenceExpression vre = (VariableReferenceExpression) p.second.getValue();
            LogicalVariable v2 = vre.getVariableReference();
            env.setVarType(v2, env2.getVarType(v2));
        }
    }
    for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : getDecorList()) {
        ILogicalExpression expr = p.second.getValue();
        if (p.first != null) {
            env.setVarType(p.first, env2.getType(expr));
        } else {
            VariableReferenceExpression vre = (VariableReferenceExpression) p.second.getValue();
            LogicalVariable v2 = vre.getVariableReference();
            env.setVarType(v2, env2.getVarType(v2));
        }
    }
    return env;
}
Also used : PropagatingTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment) LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) Mutable(org.apache.commons.lang3.mutable.Mutable) ILogicalExpression(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression) VariableReferenceExpression(org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression) 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) IVariableTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment)

Aggregations

ITypeEnvPointer (org.apache.hyracks.algebricks.core.algebra.typing.ITypeEnvPointer)7 PropagatingTypeEnvironment (org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment)7 OpRefTypeEnvPointer (org.apache.hyracks.algebricks.core.algebra.typing.OpRefTypeEnvPointer)6 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)3 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)3 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 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)2 ArrayList (java.util.ArrayList)1 Mutable (org.apache.commons.lang3.mutable.Mutable)1 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)1