Search in sources :

Example 6 with ITypeEnvPointer

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

the class SelectOperator method computeOutputTypeEnvironment.

@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException {
    ITypeEnvPointer[] envPointers = new ITypeEnvPointer[1];
    envPointers[0] = new OpRefTypeEnvPointer(inputs.get(0), ctx);
    PropagatingTypeEnvironment env = new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMissableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers);
    if (condition.getValue().getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
        return env;
    }
    AbstractFunctionCallExpression f1 = (AbstractFunctionCallExpression) condition.getValue();
    if (!f1.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.NOT)) {
        return env;
    }
    ILogicalExpression a1 = f1.getArguments().get(0).getValue();
    if (a1.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
        AbstractFunctionCallExpression f2 = (AbstractFunctionCallExpression) a1;
        if (f2.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.IS_MISSING)) {
            ILogicalExpression a2 = f2.getArguments().get(0).getValue();
            if (a2.getExpressionTag() == LogicalExpressionTag.VARIABLE) {
                LogicalVariable var = ((VariableReferenceExpression) a2).getVariableReference();
                env.getNonNullVariables().add(var);
            }
        }
    }
    return env;
}
Also used : PropagatingTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment) LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) ILogicalExpression(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression) VariableReferenceExpression(org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression) AbstractFunctionCallExpression(org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression) OpRefTypeEnvPointer(org.apache.hyracks.algebricks.core.algebra.typing.OpRefTypeEnvPointer) ITypeEnvPointer(org.apache.hyracks.algebricks.core.algebra.typing.ITypeEnvPointer)

Example 7 with ITypeEnvPointer

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

the class NestedTupleSourceOperator method computeOutputTypeEnvironment.

@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(final ITypingContext ctx) throws AlgebricksException {
    ITypeEnvPointer[] p = new ITypeEnvPointer[1];
    p[0] = new ITypeEnvPointer() {

        @Override
        public IVariableTypeEnvironment getTypeEnv() {
            ILogicalOperator op = dataSourceReference.getValue().getInputs().get(0).getValue();
            return ctx.getOutputTypeEnvironment(op);
        }
    };
    return new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMissableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, p);
}
Also used : PropagatingTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) 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