Examples of UserFuncExpression


Examples of org.apache.pig.newplan.logical.expression.UserFuncExpression

        }

    }

    LogicalExpression buildInvokerUDF(SourceLocation loc, LogicalExpressionPlan plan, String packageName, String funcName, boolean isStatic, List<LogicalExpression> args) throws RecognitionException {
        LogicalExpression le = new UserFuncExpression(plan, new FuncSpec(InvokerGenerator.class.getName()), args, false, true, isStatic, packageName, funcName);
        le.setLocation(loc);
        return le;
    }
View Full Code Here

Examples of org.apache.pig.newplan.logical.expression.UserFuncExpression

        if( funcSpec == null ) {
            funcName = func.getName();
            funcSpec = new FuncSpec(funcName);
            //this point is only reached if there was no DEFINE statement for funcName
            //in which case, we pass that information along
            le = new UserFuncExpression(plan, funcSpec, args, false);
        } else {
            le = new UserFuncExpression(plan, funcSpec, args, true);
        }

        le.setLocation(loc);
        return le;
    }
View Full Code Here

Examples of org.apache.pig.newplan.logical.expression.UserFuncExpression

            }

            @Override
            protected void execute(LogicalExpression op) throws FrontendException {
                if (op instanceof UserFuncExpression) {
                    UserFuncExpression udf = (UserFuncExpression)op;
                    if (!udf.getEvalFunc().allowCompileTimeCalculation()) {
                        return;
                    }
                }
                boolean valSet = false;
                Object val = null;
                if (currentWalker.getPlan().getSuccessors(op) != null) {
                    // If has successors and all successors are constant, calculate the constant
                    for (Operator succ : currentWalker.getPlan().getSuccessors(op)) {
                        if (!(succ instanceof ConstantExpression)) {
                            return;
                        }
                    }
                    // All successors are constant, calculate the value
                    OperatorPlan expLogicalPlan = new LogicalExpressionPlan();
                    ((BaseOperatorPlan)currentWalker.getPlan()).moveTree(op, (BaseOperatorPlan)expLogicalPlan);
                    PhysicalPlan expPhysicalPlan = new PhysicalPlan();
                    Map<Operator, PhysicalOperator> logToPhyMap = new HashMap<Operator, PhysicalOperator>();
                    PlanWalker childWalker = new ReverseDependencyOrderWalkerWOSeenChk(expLogicalPlan);

                    // Save the old walker and use childWalker as current Walker
                    pushWalker(childWalker);
                    ExpToPhyTranslationVisitor expTranslationVisitor = new
                            ExpToPhyTranslationVisitor(expLogicalPlan,
                                    childWalker, currentOp, expPhysicalPlan, logToPhyMap);
                    expTranslationVisitor.visit();
                    popWalker();
                    PhysicalOperator root = expPhysicalPlan.getLeaves().get(0);
                    try {
                        UDFContext.getUDFContext().addJobConf(ConfigurationUtil.toConfiguration(pc.getProperties(), true));
                        PigHadoopLogger pigHadoopLogger = PigHadoopLogger.getInstance();
                        PhysicalOperator.setPigLogger(pigHadoopLogger);
                        val = root.getNext(root.getResultType()).result;
                        UDFContext.getUDFContext().addJobConf(null);
                    } catch (ExecException e) {
                        throw new FrontendException(e);
                    }
                    valSet = true;
                } else if (op instanceof UserFuncExpression) {
                    // If solo UDF, calculate UDF
                    UserFuncExpression udf = (UserFuncExpression)op;
                    try {
                        UDFContext.getUDFContext().addJobConf(ConfigurationUtil.toConfiguration(pc.getProperties(), true));
                        val = udf.getEvalFunc().exec(null);
                        UDFContext.getUDFContext().addJobConf(null);
                    } catch (IOException e) {
                        throw new FrontendException(e);
                    }
                    valSet = true;
View Full Code Here

Examples of org.apache.pig.newplan.logical.expression.UserFuncExpression

        LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
        //  Generate a filter condition.
        LogicalExpression konst = new ConstantExpression( filterPlan, value);
        konst.setLocation( valLoc );
        UserFuncExpression udf = new UserFuncExpression( filterPlan, new FuncSpec( RANDOM.class.getName() ) );
        new LessThanExpression( filterPlan, udf, konst );
        LOFilter filter = new LOFilter( plan, true );
        return buildFilterOp( loc, filter, alias, inputAlias, filterPlan );
    }
View Full Code Here

Examples of org.apache.pig.newplan.logical.expression.UserFuncExpression

    String buildSampleOp(SourceLocation loc, LOFilter filter, String alias, String inputAlias,
            LogicalExpressionPlan samplePlan, LogicalExpression expr)
                    throws ParserValidationException {

        UserFuncExpression udf = new UserFuncExpression( samplePlan, new FuncSpec( RANDOM.class.getName() ) );
        new LessThanExpression( samplePlan, udf, expr );
        return buildFilterOp( loc, filter, alias, inputAlias, samplePlan );
    }
View Full Code Here

Examples of org.apache.pig.newplan.logical.expression.UserFuncExpression

            }

            // Create UDF with user specified dimensions
            LogicalExpressionPlan uexpPlan = new LogicalExpressionPlan();
            if (operations.get(operIdx).equals("CUBE")) {
                new UserFuncExpression(uexpPlan, new FuncSpec(CubeDimensions.class.getName()),
                        lexpList);
            } else {
                new UserFuncExpression(uexpPlan, new FuncSpec(RollupDimensions.class.getName()),
                        lexpList);
            }

            for (LogicalExpressionPlan lexp : lexpPlanList) {
                Iterator<Operator> it = lexp.getOperators();
View Full Code Here

Examples of org.apache.pig.newplan.logical.expression.UserFuncExpression

            ConstantExpression rhs = new ConstantExpression(exprPlan, new Boolean(false));
            BinCondExpression binCond = new BinCondExpression(exprPlan, expr, lhs, rhs);
            args.add(binCond);
            ConstantExpression constExpr = new ConstantExpression(exprPlan, (comment == null ? "" : comment));
            args.add(constExpr);
            UserFuncExpression udf = new UserFuncExpression(exprPlan, new FuncSpec( Assert.class.getName() ), args );
            exprPlan.add(udf);
            filterOp.setFilterPlan(exprPlan);
            // pass the inputAlias to alias
            return buildFilterOp(loc, filterOp, inputAlias, inputAlias, exprPlan);
        } catch (Exception ex) {
View Full Code Here

Examples of org.apache.pig.newplan.logical.expression.UserFuncExpression

        }

    }

    LogicalExpression buildInvokerUDF(SourceLocation loc, LogicalExpressionPlan plan, String packageName, String funcName, boolean isStatic, List<LogicalExpression> args) throws RecognitionException {
        LogicalExpression le = new UserFuncExpression(plan, new FuncSpec(InvokerGenerator.class.getName()), args, false, true, isStatic, packageName, funcName);
        le.setLocation(loc);
        return le;
    }
View Full Code Here

Examples of org.apache.pig.newplan.logical.expression.UserFuncExpression

        if( funcSpec == null ) {
            funcName = func.getName();
            funcSpec = new FuncSpec(funcName);
            //this point is only reached if there was no DEFINE statement for funcName
            //in which case, we pass that information along
            le = new UserFuncExpression(plan, funcSpec, args, false);
        } else {
            le = new UserFuncExpression(plan, funcSpec, args, true);
        }

        le.setLocation(loc);
        return le;
    }
View Full Code Here

Examples of org.apache.pig.newplan.logical.expression.UserFuncExpression

        LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
        //  Generate a filter condition.
        LogicalExpression konst = new ConstantExpression( filterPlan, value);
        konst.setLocation( valLoc );
        UserFuncExpression udf = new UserFuncExpression( filterPlan, new FuncSpec( RANDOM.class.getName() ) );
        new LessThanExpression( filterPlan, udf, konst );
        LOFilter filter = new LOFilter( plan, true );
        return buildFilterOp( loc, filter, alias, inputAlias, filterPlan );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.