Examples of EqualExpression


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

        op = (LogicalRelationalOperator)newPlan.getSuccessors(op).get(0);
        assertEquals(op.getClass(), org.apache.pig.experimental.logical.relational.LOFilter.class);
       
        LogicalExpressionPlan exp = ((org.apache.pig.experimental.logical.relational.LOFilter)op).getFilterPlan();
       
        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);
       
        // check store
        op = (LogicalRelationalOperator)newPlan.getSuccessors(op).get(0);
        assertEquals(op.getClass(), org.apache.pig.experimental.logical.relational.LOStore.class);
    }
View Full Code Here

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

        assertEquals(op.getClass(), org.apache.pig.experimental.logical.relational.LOFilter.class);       
        LogicalExpressionPlan exp = ((org.apache.pig.experimental.logical.relational.LOFilter)op).getFilterPlan();
       
        AndExpression ae = (AndExpression)exp.getSources().get(0);
       
        EqualExpression eq = (EqualExpression)exp.getSuccessors(ae).get(0);
        assertEquals(eq.getLhs().getClass(), ProjectExpression.class);
        assertEquals(((ProjectExpression)eq.getLhs()).getColNum(), 0);
        assertEquals(((ProjectExpression)eq.getLhs()).getInputNum(), 0);
       
        assertEquals(eq.getRhs().getClass(), ConstantExpression.class);
       
        eq = (EqualExpression)exp.getSuccessors(ae).get(1);
        assertEquals(eq.getLhs().getClass(), ProjectExpression.class);
        assertEquals(((ProjectExpression)eq.getLhs()).getColNum(), 3);
        assertEquals(((ProjectExpression)eq.getLhs()).getInputNum(), 0);
       
        assertEquals(eq.getRhs().getClass(), ConstantExpression.class);
       
        // check store
        op = (LogicalRelationalOperator)newPlan.getSuccessors(op).get(0);
        assertEquals(op.getClass(), org.apache.pig.experimental.logical.relational.LOStore.class);
    }
View Full Code Here

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

        LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
        ProjectExpression namePrj2 = new ProjectExpression(filterPlan, DataType.CHARARRAY, 0, 0);
        filterPlan.add(namePrj2);
        ConstantExpression constExp = new ConstantExpression(filterPlan, DataType.CHARARRAY, "joe");
        filterPlan.add(constExp);
        EqualExpression equal = new EqualExpression(filterPlan, namePrj2, constExp);
        filterPlan.add(equal);
       
        filter.setFilterPlan(filterPlan);
        filter.setAlias("C");
        plan.add(filter);
View Full Code Here

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

        LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
        ProjectExpression namePrj2 = new ProjectExpression(filterPlan, DataType.CHARARRAY, 0, 0);
        filterPlan.add(namePrj2);
        ConstantExpression constExp = new ConstantExpression(filterPlan, DataType.CHARARRAY, "joe");
        filterPlan.add(constExp);
        EqualExpression equal = new EqualExpression(filterPlan, namePrj2, constExp);
        filterPlan.add(equal);
       
        filter.setFilterPlan(filterPlan);
        filter.setAlias("C");
        plan.add(filter);
       
        LOFilter filter2 = new LOFilter(plan);
        LogicalExpressionPlan filter2Plan = new LogicalExpressionPlan();
        ProjectExpression name2Prj2 = new ProjectExpression(filter2Plan, DataType.CHARARRAY, 0, 1);
        filter2Plan.add(name2Prj2);
        ConstantExpression const2Exp = new ConstantExpression(filter2Plan, DataType.CHARARRAY, "joe");
        filter2Plan.add(const2Exp);
        EqualExpression equal2 = new EqualExpression(filter2Plan, namePrj2, constExp);
        filter2Plan.add(equal2);
       
        filter2.setFilterPlan(filter2Plan);
        filter2.setAlias("C1");
        plan.add(filter2);
View Full Code Here

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

        LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
        ProjectExpression namePrj2 = new ProjectExpression(filterPlan, DataType.CHARARRAY, 0, 0);
        filterPlan.add(namePrj2);
        ConstantExpression constExp = new ConstantExpression(filterPlan, DataType.CHARARRAY, "joe");
        filterPlan.add(constExp);
        EqualExpression equal = new EqualExpression(filterPlan, namePrj2, constExp);
        filterPlan.add(equal);
       
        filter.setFilterPlan(filterPlan);
        filter.setAlias("C");
        plan.add(filter);
       
        LOFilter filter2 = new LOFilter(plan);
        LogicalExpressionPlan filter2Plan = new LogicalExpressionPlan();
        ProjectExpression name2Prj2 = new ProjectExpression(filter2Plan, DataType.CHARARRAY, 0, 0);
        filter2Plan.add(name2Prj2);
        ConstantExpression const2Exp = new ConstantExpression(filter2Plan, DataType.CHARARRAY, "joe2");
        filter2Plan.add(const2Exp);
        EqualExpression equal2 = new EqualExpression(filter2Plan, namePrj2, constExp);
        filter2Plan.add(equal2);
       
        filter2.setFilterPlan(filter2Plan);
        filter2.setAlias("C1");
        plan.add(filter2);
View Full Code Here

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

        LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
        ProjectExpression namePrj2 = new ProjectExpression(filterPlan, DataType.CHARARRAY, 0, 1);
        filterPlan.add(namePrj2);
        ConstantExpression constExp = new ConstantExpression(filterPlan, DataType.CHARARRAY, "joe");
        filterPlan.add(constExp);
        EqualExpression equal = new EqualExpression(filterPlan, namePrj2, constExp);
        filterPlan.add(equal);
       
        filter.setFilterPlan(filterPlan);
        filter.setAlias("C");
        plan.add(filter);
       
        LOFilter filter2 = new LOFilter(plan);
        LogicalExpressionPlan filter2Plan = new LogicalExpressionPlan();
        ProjectExpression name2Prj2 = new ProjectExpression(filter2Plan, DataType.CHARARRAY, 0, 1);
        filter2Plan.add(name2Prj2);
        ConstantExpression const2Exp = new ConstantExpression(filter2Plan, DataType.CHARARRAY, "joe2");
        filter2Plan.add(const2Exp);
        EqualExpression equal2 = new EqualExpression(filter2Plan, namePrj2, constExp);
        filter2Plan.add(equal2);
       
        filter2.setFilterPlan(filter2Plan);
        filter2.setAlias("C1");
        plan.add(filter2);
View Full Code Here

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

        LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
        ProjectExpression namePrj2 = new ProjectExpression(filterPlan, DataType.CHARARRAY, 0, 1);
        filterPlan.add(namePrj2);
        ConstantExpression constExp = new ConstantExpression(filterPlan, DataType.CHARARRAY, "joe");
        filterPlan.add(constExp);
        EqualExpression equal = new EqualExpression(filterPlan, namePrj2, constExp);
        filterPlan.add(equal);
       
        filter.setFilterPlan(filterPlan);
        filter.setAlias("C");
        plan.add(filter);
View Full Code Here

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

        LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
        ProjectExpression namePrj2 = new ProjectExpression(filterPlan, DataType.CHARARRAY, 0, 0);
        filterPlan.add(namePrj2);
        ConstantExpression constExp = new ConstantExpression(filterPlan, DataType.CHARARRAY, "joe");
        filterPlan.add(constExp);
        EqualExpression equal = new EqualExpression(filterPlan, namePrj2, constExp);
        filterPlan.add(equal);
       
        filter.setFilterPlan(filterPlan);
        filter.setAlias("C");
        plan.add(filter);
View Full Code Here

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

        public void visit(LOEqual op) throws VisitorException {   
            ExpressionOperator left = op.getLhsOperand();
            ExpressionOperator right = op.getRhsOperand();
                   
            EqualExpression eq = new EqualExpression(exprPlan, exprOpsMap.get(left), exprOpsMap.get(right));
            exprOpsMap.put(op, eq);
        }
View Full Code Here

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

          // D = filter
          LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
          LOFilter D = new LOFilter(lp, filterPlan);
          ProjectExpression fx = new ProjectExpression(filterPlan, 0, 0, D);
          ConstantExpression fc0 = new ConstantExpression(filterPlan, new Integer(0), new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
          EqualExpression eq1 = new EqualExpression(filterPlan, fx, fc0);
          ProjectExpression fanotherx = new ProjectExpression(filterPlan, 0, 0, D);
          ProjectExpression fa = new ProjectExpression(filterPlan, 0, 2, D);
          EqualExpression eq2 = new EqualExpression(filterPlan, fanotherx, fa);
          AndExpression and1 = new AndExpression(filterPlan, eq1, eq2);
          ProjectExpression fb = new ProjectExpression(filterPlan, 0, 3, D);
          ConstantExpression fc1 = new ConstantExpression(filterPlan, new Integer(1),new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
          EqualExpression eq3 = new EqualExpression(filterPlan, fb, fc1);
          AndExpression and2 = new AndExpression(filterPlan, and1, eq3);
          ProjectExpression fanotherb = new ProjectExpression(filterPlan, 0, 3, D);
          ProjectExpression fy = new ProjectExpression(filterPlan, 0, 1, D);
          EqualExpression eq4 = new EqualExpression(filterPlan, fy, fanotherb);
          new AndExpression(filterPlan, and2, eq4);
         
          D.setAlias("D");
          // Connect D to B, since the transform has happened.
          lp.add(D);
          lp.connect(C, D);
        }
       
        System.out.println(lp);
        LogicalPlanOptimizer optimizer = new LogicalPlanOptimizer(lp, 500, null);
        optimizer.optimize();
       
        LogicalPlan expected = new LogicalPlan();
        {
            // A = load
          LogicalSchema aschema = new LogicalSchema();
          aschema.addField(new LogicalSchema.LogicalFieldSchema(
              "x", null, DataType.BYTEARRAY));
          aschema.addField(new LogicalSchema.LogicalFieldSchema(
              "y", null, DataType.BYTEARRAY));
          LOLoad A = new LOLoad(new FileSpec("bla", new FuncSpec("PigStorage", "\t")), aschema, expected, null);
          expected.add(A);
         
          // DA = filter
          LogicalExpressionPlan DAfilterPlan = new LogicalExpressionPlan();
          LOFilter DA = new LOFilter(expected, DAfilterPlan);
          ProjectExpression fx = new ProjectExpression(DAfilterPlan, 0, 0, DA);
          fx.neverUseForRealSetFieldSchema(new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
          ConstantExpression fc0 = new ConstantExpression(DAfilterPlan, new Integer(0), new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
          new EqualExpression(DAfilterPlan, fx, fc0);
         
          DA.neverUseForRealSetSchema(aschema);
          expected.add(DA);
          expected.connect(A, DA);
         
          // B = load
          LogicalSchema bschema = new LogicalSchema();
          bschema.addField(new LogicalSchema.LogicalFieldSchema(
              "a", null, DataType.BYTEARRAY));
          bschema.addField(new LogicalSchema.LogicalFieldSchema(
              "b", null, DataType.BYTEARRAY));
          LOLoad B = new LOLoad(new FileSpec("morebla", new FuncSpec("PigStorage", "\t")), bschema, expected, null);
          expected.add(B);
         
          // DB = filter
          LogicalExpressionPlan DBfilterPlan = new LogicalExpressionPlan();
            LOFilter DB = new LOFilter(expected, DBfilterPlan);
          ProjectExpression fb = new ProjectExpression(DBfilterPlan, 0, 1, DB);
          fb.neverUseForRealSetFieldSchema(new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
          ConstantExpression fc1 = new ConstantExpression(DBfilterPlan, new Integer(1), new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
          new EqualExpression(DBfilterPlan, fb, fc1);

          DB.neverUseForRealSetSchema(bschema);
          expected.add(DB);
          expected.connect(B, DB);
         
          // C = join
          LogicalSchema cschema = new LogicalSchema();
          cschema.addField(new LogicalSchema.LogicalFieldSchema(
              "D::x", null, DataType.BYTEARRAY));
          cschema.addField(new LogicalSchema.LogicalFieldSchema(
              "D::y", null, DataType.BYTEARRAY));
          cschema.addField(new LogicalSchema.LogicalFieldSchema(
              "null::a", null, DataType.BYTEARRAY));
          cschema.addField(new LogicalSchema.LogicalFieldSchema(
              "null::b", null, DataType.BYTEARRAY));
          cschema.getField(0).uid = 1;
          cschema.getField(1).uid = 2;
          cschema.getField(2).uid = 3;
          cschema.getField(3).uid = 4;
          LogicalExpressionPlan aprojplan = new LogicalExpressionPlan();
            MultiMap<Integer, LogicalExpressionPlan> mm =
                new MultiMap<Integer, LogicalExpressionPlan>();
            LOJoin C = new LOJoin(expected, mm, JOINTYPE.HASH, new boolean[] {true, true});

          ProjectExpression x = new ProjectExpression(aprojplan, 0, 0, C);
          x.neverUseForRealSetFieldSchema(new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
          LogicalExpressionPlan bprojplan = new LogicalExpressionPlan();
          ProjectExpression y = new ProjectExpression(bprojplan, 1, 0, C);
          y.neverUseForRealSetFieldSchema(new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
          mm.put(0, aprojplan);
          mm.put(1, bprojplan);
          C.neverUseForRealSetSchema(cschema);
          expected.add(C);
          expected.connect(DA, C);
          expected.connect(DB, C);
         
          // D = filter
          LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
            LOFilter D = new LOFilter(expected, filterPlan);
          ProjectExpression fanotherx = new ProjectExpression(filterPlan, 0, 0, D);
          fanotherx.neverUseForRealSetFieldSchema(new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
          ProjectExpression fa = new ProjectExpression(filterPlan, 0, 2, D);
          fa.neverUseForRealSetFieldSchema(new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
          EqualExpression eq2 = new EqualExpression(filterPlan, fanotherx, fa);
          ProjectExpression fanotherb = new ProjectExpression(filterPlan, 0, 3, D);
          fanotherb.neverUseForRealSetFieldSchema(new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
          ProjectExpression fy = new ProjectExpression(filterPlan, 0, 1, D);
          fy.neverUseForRealSetFieldSchema(new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
          EqualExpression eq4 = new EqualExpression(filterPlan, fy, fanotherb);
          new AndExpression(filterPlan, eq2, eq4);
         
          D.neverUseForRealSetSchema(cschema);
          expected.add(D);
          expected.connect(C, D);
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.