Package org.apache.pig.experimental.logical.expression

Examples of org.apache.pig.experimental.logical.expression.LogicalExpression


       
        EqualExpression eq = (EqualExpression)exp.getSources().get(0);
        assertEquals(eq.getLhs().getClass(), CastExpression.class);
               
        assertEquals(eq.getLhs().getClass(), CastExpression.class);
        LogicalExpression ep = (LogicalExpression)exp.getSuccessors(eq.getLhs()).get(0);
        assertEquals(ep.getClass(), ProjectExpression.class);
        assertEquals(((ProjectExpression)ep).getColNum(), 0);
        assertEquals(((ProjectExpression)ep).getInputNum(), 0);
       
        assertEquals(eq.getRhs().getClass(), ConstantExpression.class);
       
View Full Code Here


        @Override
        public boolean check(OperatorPlan matched) throws IOException {
            LOFilter filter = (LOFilter)matched.getSources().get(0);
            LogicalExpressionPlan cond = filter.getFilterPlan();
            LogicalExpression root = (LogicalExpression) cond.getSources().get(0);
            if (root instanceof AndExpression) {
                return true;
            }
           
            return false;
View Full Code Here

            subPlan = new OperatorSubPlan(currentPlan);
           
            // split one LOFilter into 2 by "AND"
            LOFilter filter = (LOFilter)matched.getSources().get(0);
            LogicalExpressionPlan cond = filter.getFilterPlan();
            LogicalExpression root = (LogicalExpression) cond.getSources().get(0);
            if (!(root instanceof AndExpression)) {
                return;
            }
            LogicalExpressionPlan op1 = new LogicalExpressionPlan();
            op1.add((LogicalExpression)cond.getSuccessors(root).get(0));
View Full Code Here

             while(iter.hasNext()) {
                 long uid = iter.next();
                 boolean found = false;
                 for(int i=0; i<ll.size(); i++) {
                     LogicalExpressionPlan exp = ll.get(i);
                     LogicalExpression op = (LogicalExpression)exp.getSources().get(0);
                    
                     if (op.getUid() == uid) {
                         collectUids(gen, exp, input);                        
                         found = true;
                       
                     } else if (op instanceof ProjectExpression && ((ProjectExpression)op).isProjectStar()) {
                         int inputNum = ((ProjectExpression)op).getInputNum();                             
View Full Code Here

        }
       
        schema = new LogicalSchema();
       
        for(int i=0; i<outputPlans.size(); i++) {
            LogicalExpression exp = (LogicalExpression)outputPlans.get(i).getSources().get(0);
            byte t = exp.getType();
            LogicalSchema fieldSchema = null;
            String alias = null;
           
            // for tuple and bag type, if there is projection, calculate schema of this field
            if (exp instanceof ProjectExpression) {               
                LogicalRelationalOperator op = null;
                try{
                    op = ((ProjectExpression)exp).findReferent(this);
                }catch(Exception e) {
                    throw new RuntimeException(e);
                }
                LogicalSchema s = op.getSchema();
                if (s != null) {
                    if (((ProjectExpression)exp).isProjectStar()) {
                        for(LogicalFieldSchema f: s.getFields()) {
                            schema.addField(f);
                        }
                        continue;
                    }
                   
                    fieldSchema = s.getField(((ProjectExpression)exp).getColNum()).schema;
                    alias = s.getField(((ProjectExpression)exp).getColNum()).alias;
                }
            }
           
            // if type is primitive, just add to schema
            if (t != DataType.TUPLE && t != DataType.BAG) {
                LogicalFieldSchema f = new LogicalSchema.LogicalFieldSchema(alias, fieldSchema, t, exp.getUid());               
                schema.addField(f);
                continue;
            }
           
            // if flatten is set, set schema of tuple field to this schema
            if (flattenFlags[i]) {
                if (t == DataType.BAG) {
                    // if it is bag of tuples, get the schema of tuples
                    if (fieldSchema != null && fieldSchema.size() == 1
                        && fieldSchema.getField(0).type == DataType.TUPLE) {
                       
                        fieldSchema = fieldSchema.getField(0).schema;
                    }else {
                        fieldSchema = null;
                    }
                }
               
                if (fieldSchema != null) {
                    List<LogicalFieldSchema> ll = fieldSchema.getFields();
                    for(LogicalFieldSchema f: ll) {
                        LogicalFieldSchema nf = new LogicalSchema.LogicalFieldSchema(alias+"::"+f.alias, f.schema, f.type, f.uid);
                        schema.addField(nf);
                    }                              
                } else {
                    schema = null;
                    break;
                }
            } else {
                 LogicalFieldSchema f = new LogicalSchema.LogicalFieldSchema(alias, fieldSchema, t, exp.getUid());                
                 schema.addField(f)
            }                                                     
        }
        return schema;
    }
View Full Code Here

            UserFuncExpression exp = new UserFuncExpression(exprPlan, op.getFuncSpec(), op.getType());
           
            List<ExpressionOperator> args = op.getArguments();
           
            for( ExpressionOperator arg : args ) {
                LogicalExpression expArg = exprOpsMap.get(arg);
                exprPlan.connect(exp, expArg);
            }
           
            exprOpsMap.put(op, exp);
        }
View Full Code Here

           
            LogicalSchema.LogicalFieldSchema logfieldSchema =
                new LogicalSchema.LogicalFieldSchema( fieldSchema.alias,
                        translateSchema(fieldSchema.schema), fieldSchema.type);
           
            LogicalExpression map = exprOpsMap.get( colOp.getMap() );
           
            MapLookupExpression op = new MapLookupExpression(exprPlan,
                    colOp.getValueType(), colOp.getLookUpKey(),  logfieldSchema);
           
            exprPlan.connect(op, map);
View Full Code Here

     * that can be generated using this expression plan
     * @param exprPlan ExpressionPlan which generates this field
     * @return
     */
    private LogicalFieldSchema getPlanSchema( LogicalExpressionPlan exprPlan ) {
        LogicalExpression sourceExp = (LogicalExpression) exprPlan.getSources().get(0);
        byte sourceType = sourceExp.getType();
        // We dont support bags for Cogroup
        if( sourceType == DataType.BAG ) {
            return null;
        }
        LogicalSchema fieldSchema = null;
        String alias = null;

        // If we have a projection then caculate the schema of the projection
        if (sourceExp instanceof ProjectExpression) {               
            LogicalRelationalOperator op = null;
            try{
                op = ((ProjectExpression)sourceExp).findReferent(this);
            }catch(Exception e) {
                throw new RuntimeException(e);
            }
            LogicalSchema s = op.getSchema();
            if (s != null) {
                fieldSchema = s.getField(((ProjectExpression)sourceExp).getColNum()).schema;
                alias = s.getField(((ProjectExpression)sourceExp).getColNum()).alias;
            }
        }
       
        return new LogicalFieldSchema(alias, fieldSchema, sourceType, sourceExp.getUid());
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.experimental.logical.expression.LogicalExpression

Copyright © 2018 www.massapicom. 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.