Package org.apache.pig.newplan.logical.relational

Examples of org.apache.pig.newplan.logical.relational.LOJoin


                       "b = load 'B'; " +
                       "c = Join a by $0, b by $0 using 'default'; "+
                       "store c into 'output';";
        LogicalPlan lp = Util.buildLp(pigServer, query);
        Operator store = lp.getSinks().get(0);
        LOJoin join = (LOJoin) lp.getPredecessors( store ).get(0);
        assertEquals(JOINTYPE.HASH, join.getJoinType());
    }
View Full Code Here


                       "b = load 'B'; " +
                       "c = Join a by $0, b by $0 using 'repl'; "+
                       "store c into 'output';";
        LogicalPlan lp = Util.buildLp(pigServer, query);
        Operator store = lp.getSinks().get(0);
        LOJoin join = (LOJoin) lp.getPredecessors( store ).get(0);
        assertEquals(JOINTYPE.REPLICATED, join.getJoinType());
    }
View Full Code Here

                       "b = load 'B'; " +
                       "c = Join a by $0, b by $0 using 'replicated'; "+
                       "store c into 'output';";
        LogicalPlan lp = Util.buildLp(pigServer, query);
        Operator store = lp.getSinks().get(0);
        LOJoin join = (LOJoin) lp.getPredecessors( store ).get(0);
        assertEquals(JOINTYPE.REPLICATED, join.getJoinType());
    }
View Full Code Here

            new ProjectExpression(bprojplan, 1, 0, null);
            MultiMap<Integer, LogicalExpressionPlan> mm =
                new MultiMap<Integer, LogicalExpressionPlan>();
            mm.put(0, aprojplan);
            mm.put(1, bprojplan);
            LOJoin C = new LOJoin(lp, mm, JOINTYPE.HASH, new boolean[] {true, true});
            C.neverUseForRealSetSchema(cschema);
            lp.add(C);
            lp.connect(A, C);
            lp.connect(B, C);
           
            // D = filter
            LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
            ProjectExpression fy = new ProjectExpression(filterPlan, 0, 1, null);
            ConstantExpression fc = new ConstantExpression(filterPlan, new Integer(0));
            new EqualExpression(filterPlan, fy, fc);
            LOFilter D = new LOFilter(lp, filterPlan);
            D.neverUseForRealSetSchema(cschema);
            lp.add(D);
            lp.connect(C, D);
        }
       
        // Build a second similar plan to test equality
        // A = load
        LogicalPlan lp1 = new LogicalPlan();
        {
            LogicalSchema aschema = new LogicalSchema();
            aschema.addField(new LogicalSchema.LogicalFieldSchema(
                "x", null, DataType.INTEGER));
            LOLoad A = newLOLoad(new FileSpec("/abc",
                new FuncSpec(DummyLoad.class.getName(), new String[] {"x", "y"})), aschema, lp1, conf);
            lp1.add(A);
           
            // B = load
            LogicalSchema bschema = new LogicalSchema();
            bschema.addField(new LogicalSchema.LogicalFieldSchema(
                "y", null, DataType.INTEGER));
            LOLoad B = newLOLoad(new FileSpec("/def",
                new FuncSpec("PigStorage", "\t")), bschema, lp1, conf);
            lp1.add(B);
           
            // C = join
            LogicalSchema cschema = new LogicalSchema();
            cschema.addField(new LogicalSchema.LogicalFieldSchema(
                "x", null, DataType.INTEGER));
            cschema.addField(new LogicalSchema.LogicalFieldSchema(
                "y", null, DataType.INTEGER));
            LogicalExpressionPlan aprojplan = new LogicalExpressionPlan();
            new ProjectExpression(aprojplan, 0, 0, null);
            LogicalExpressionPlan bprojplan = new LogicalExpressionPlan();
            new ProjectExpression(bprojplan, 1, 0, null);
            MultiMap<Integer, LogicalExpressionPlan> mm =
                new MultiMap<Integer, LogicalExpressionPlan>();
            mm.put(0, aprojplan);
            mm.put(1, bprojplan);
            LOJoin C = new LOJoin(lp1, mm, JOINTYPE.HASH, new boolean[] {true, true});
            C.neverUseForRealSetSchema(cschema);
            lp1.add(C);
            lp1.connect(A, C);
            lp1.connect(B, C);
               
           
View Full Code Here

        new ProjectExpression(bprojplan1, 1, 0, null);
        MultiMap<Integer, LogicalExpressionPlan> mm1 =
            new MultiMap<Integer, LogicalExpressionPlan>();
        mm1.put(0, aprojplan1);
        mm1.put(1, bprojplan1);
        LOJoin C1 = new LOJoin(lp, mm1, JOINTYPE.HASH, new boolean[] {true, true});
        C1.neverUseForRealSetSchema(jcschema1);
        lp.add(C1);
        lp.connect(A1, C1);
        lp.connect(B1, C1);
       
        // A = load
        LogicalSchema jaschema2 = new LogicalSchema();
        jaschema2.addField(new LogicalSchema.LogicalFieldSchema(
           "x", null, DataType.INTEGER));
        LOLoad A2 = newLOLoad(new FileSpec("/abc",
           new FuncSpec("org.apache.pig.test.TestNewPlanOperatorPlan$FooLoad", new String[] {"x", "y"})), jaschema2, lp, conf);
        lp.add(A2);
       
        // B = load
        LogicalSchema jbschema2 = new LogicalSchema();
        jbschema2.addField(new LogicalSchema.LogicalFieldSchema(
            "y", null, DataType.INTEGER));
        LOLoad B2 = newLOLoad(new FileSpec("/def",
            new FuncSpec("PigStorage", "\t")), jbschema2, lp, conf);
        lp.add(B2);
       
        // C = join
        LogicalSchema jcschema2 = new LogicalSchema();
        jcschema2.addField(new LogicalSchema.LogicalFieldSchema(
            "x", null, DataType.INTEGER));
        jcschema2.addField(new LogicalSchema.LogicalFieldSchema(
            "y", null, DataType.INTEGER));
        LogicalExpressionPlan aprojplan2 = new LogicalExpressionPlan();
        new ProjectExpression(aprojplan2, 0, 0, null);
        LogicalExpressionPlan bprojplan2 = new LogicalExpressionPlan();
        new ProjectExpression(bprojplan2, 1, 0, null);
        MultiMap<Integer, LogicalExpressionPlan> mm2 =
            new MultiMap<Integer, LogicalExpressionPlan>();
        mm2.put(0, aprojplan2);
        mm2.put(1, bprojplan2);
        LOJoin C2 = new LOJoin(lp, mm2, JOINTYPE.SKEWED, new boolean[] {true, true});
        C2.neverUseForRealSetSchema(jcschema2);
        lp.add(C2);
        lp.connect(A2, C2);
        lp.connect(B2, C2);
       
        assertFalse(C1.isEqual(C2));
View Full Code Here

        new ProjectExpression(bprojplan1, 1, 0, null);
        MultiMap<Integer, LogicalExpressionPlan> mm1 =
            new MultiMap<Integer, LogicalExpressionPlan>();
        mm1.put(0, aprojplan1);
        mm1.put(1, bprojplan1);
        LOJoin C1 = new LOJoin(lp, mm1, JOINTYPE.HASH, new boolean[] {true, true});
        C1.neverUseForRealSetSchema(jcschema1);
        lp.add(C1);
        lp.connect(A1, C1);
        lp.connect(B1, C1);
       
        // Test different inner status
        // A = load
        LogicalSchema jaschema3 = new LogicalSchema();
        jaschema3.addField(new LogicalSchema.LogicalFieldSchema(
           "x", null, DataType.INTEGER));
        LOLoad A3 = newLOLoad(new FileSpec("/abc",
           new FuncSpec("org.apache.pig.test.TestNewPlanOperatorPlan$FooLoad", new String[] {"x", "y"})), jaschema3, lp, conf);
        lp.add(A3);
       
        // B = load
        LogicalSchema jbschema3 = new LogicalSchema();
        jbschema3.addField(new LogicalSchema.LogicalFieldSchema(
            "y", null, DataType.INTEGER));
        LOLoad B3 = newLOLoad(new FileSpec("/def",
            new FuncSpec("PigStorage", "\t")), jbschema3, lp, conf);
        lp.add(B3);
       
        // C = join
        LogicalSchema jcschema3 = new LogicalSchema();
        jcschema3.addField(new LogicalSchema.LogicalFieldSchema(
            "x", null, DataType.INTEGER));
        jcschema3.addField(new LogicalSchema.LogicalFieldSchema(
            "y", null, DataType.INTEGER));
        LogicalExpressionPlan aprojplan3 = new LogicalExpressionPlan();
        new ProjectExpression(aprojplan3, 0, 0, null);
        LogicalExpressionPlan bprojplan3 = new LogicalExpressionPlan();
        new ProjectExpression(bprojplan3, 1, 0, null);
        MultiMap<Integer, LogicalExpressionPlan> mm3 =
            new MultiMap<Integer, LogicalExpressionPlan>();
        mm3.put(0, aprojplan3);
        mm3.put(1, bprojplan3);
        LOJoin C3 = new LOJoin(lp, mm3, JOINTYPE.HASH, new boolean[] {true, false});
        C3.neverUseForRealSetSchema(jcschema3);
        lp.add(C3);
        lp.connect(A3, C3);
        lp.connect(B3, C3);
       
       
View Full Code Here

        new ProjectExpression(bprojplan1, 1, 0, null);
        MultiMap<Integer, LogicalExpressionPlan> mm1 =
            new MultiMap<Integer, LogicalExpressionPlan>();
        mm1.put(0, aprojplan1);
        mm1.put(1, bprojplan1);
        LOJoin C1 = new LOJoin(lp, mm1, JOINTYPE.HASH, new boolean[] {true, true});
        C1.neverUseForRealSetSchema(jcschema1);
        lp.add(C1);
        lp.connect(A1, C1);
        lp.connect(B1, C1);
        // A = load
        LogicalSchema jaschema5 = new LogicalSchema();
        jaschema5.addField(new LogicalSchema.LogicalFieldSchema(
           "x", null, DataType.INTEGER));
        LOLoad A5 = newLOLoad(new FileSpec("/abc",
           new FuncSpec("org.apache.pig.test.TestNewPlanOperatorPlan$FooLoad", new String[] {"x", "y"})), jaschema5, lp, conf);
        lp.add(A5);
       
        // B = load
        LogicalSchema jbschema5 = new LogicalSchema();
        jbschema5.addField(new LogicalSchema.LogicalFieldSchema(
            "y", null, DataType.INTEGER));
        LOLoad B5 = newLOLoad(new FileSpec("/def",
            new FuncSpec("PigStorage", "\t")), jbschema5, lp, conf);
        lp.add(B5);
       
        // Beta = load
        LogicalSchema jbetaschema5 = new LogicalSchema();
        jbetaschema5.addField(new LogicalSchema.LogicalFieldSchema(
            "y", null, DataType.INTEGER));
        LOLoad Beta5 = newLOLoad(new FileSpec("/ghi",
            new FuncSpec("PigStorage", "\t")), jbetaschema5, lp, conf);
        lp.add(Beta5);
       
        // C = join
        LogicalSchema jcschema5 = new LogicalSchema();
        jcschema5.addField(new LogicalSchema.LogicalFieldSchema(
            "x", null, DataType.INTEGER));
        jcschema5.addField(new LogicalSchema.LogicalFieldSchema(
            "y", null, DataType.INTEGER));
        LogicalExpressionPlan aprojplan5 = new LogicalExpressionPlan();
        new ProjectExpression(aprojplan5, 0, 0, null);
        LogicalExpressionPlan bprojplan5 = new LogicalExpressionPlan();
        new ProjectExpression(bprojplan5, 1, 0, null);
        LogicalExpressionPlan betaprojplan5 = new LogicalExpressionPlan();
        new ProjectExpression(betaprojplan5, 1, 0, null);
        MultiMap<Integer, LogicalExpressionPlan> mm5 =
            new MultiMap<Integer, LogicalExpressionPlan>();
        mm5.put(0, aprojplan5);
        mm5.put(1, bprojplan5);
        mm5.put(2, betaprojplan5);
        LOJoin C5 = new LOJoin(lp, mm5, JOINTYPE.HASH, new boolean[] {true, true});
        C5.neverUseForRealSetSchema(jcschema5);
        lp.add(C5);
        lp.connect(A5, C5);
        lp.connect(B5, C5);
        lp.connect(Beta5, C5);
       
View Full Code Here

        MultiMap<Integer, LogicalExpressionPlan> mm6 =
            new MultiMap<Integer, LogicalExpressionPlan>();
        mm6.put(0, aprojplan6);
        mm6.put(1, bprojplan6);
        mm6.put(1, b2projplan6);
        LOJoin C6 = new LOJoin(lp, mm6, JOINTYPE.HASH, new boolean[] {true, true});
        C6.neverUseForRealSetSchema(jcschema6);
        lp.add(C6);
        lp.connect(A6, C6);
        lp.connect(B6, C6);
       
       
        LogicalSchema jaschema7 = new LogicalSchema();
        jaschema7.addField(new LogicalSchema.LogicalFieldSchema(
           "x", null, DataType.INTEGER));
        LOLoad A7 = newLOLoad(new FileSpec("/abc",
           new FuncSpec("org.apache.pig.test.TestNewPlanOperatorPlan$FooLoad", new String[] {"x", "y"})), jaschema7, lp, conf);
        lp.add(A7);
       
        // B = load
        LogicalSchema jbschema7 = new LogicalSchema();
        jbschema7.addField(new LogicalSchema.LogicalFieldSchema(
            "y", null, DataType.INTEGER));
        jbschema7.addField(new LogicalSchema.LogicalFieldSchema(
            "z", null, DataType.LONG));
        LOLoad B7 = newLOLoad(new FileSpec("/def",
            new FuncSpec("PigStorage", "\t")), jbschema7, lp, conf);
        lp.add(B7);
       
        // C = join
        LogicalSchema jcschema7 = new LogicalSchema();
        jcschema7.addField(new LogicalSchema.LogicalFieldSchema(
            "x", null, DataType.INTEGER));
        jcschema7.addField(new LogicalSchema.LogicalFieldSchema(
            "y", null, DataType.INTEGER));
        LogicalExpressionPlan aprojplan7 = new LogicalExpressionPlan();
        new ProjectExpression(aprojplan7, 0, 0, null);
        LogicalExpressionPlan bprojplan7 = new LogicalExpressionPlan();
        new ProjectExpression(bprojplan7, 1, 1, null);
        LogicalExpressionPlan b2projplan7 = new LogicalExpressionPlan();
        new ProjectExpression(b2projplan7, 1, 0, null);
        MultiMap<Integer, LogicalExpressionPlan> mm7 =
            new MultiMap<Integer, LogicalExpressionPlan>();
        mm7.put(0, aprojplan7);
        mm7.put(1, bprojplan7);
        mm7.put(1, b2projplan7);
        LOJoin C7 = new LOJoin(lp, mm7, JOINTYPE.HASH, new boolean[] {true, true});
        C7.neverUseForRealSetSchema(jcschema7);
        lp.add(C7);
        lp.connect(A7, C7);
        lp.connect(B7, C7);
       
        assertFalse(C6.isEqual(C7));
View Full Code Here

        MultiMap<Integer, LogicalExpressionPlan> mm6 =
            new MultiMap<Integer, LogicalExpressionPlan>();
        mm6.put(0, aprojplan6);
        mm6.put(1, bprojplan6);
        mm6.put(1, b2projplan6);
        LOJoin C6 = new LOJoin(lp, mm6, JOINTYPE.HASH, new boolean[] {true, true});
        C6.neverUseForRealSetSchema(jcschema6);
        lp.add(C6);
        lp.connect(A6, C6);
        lp.connect(B6, C6);
       
        // Test different different number of join keys
        LogicalSchema jaschema8 = new LogicalSchema();
        jaschema8.addField(new LogicalSchema.LogicalFieldSchema(
           "x", null, DataType.INTEGER));
        LOLoad A8 = newLOLoad(new FileSpec("/abc",
           new FuncSpec("org.apache.pig.test.TestNewPlanOperatorPlan$FooLoad", new String[] {"x", "y"})), jaschema8, lp, conf);
        lp.add(A8);
       
        // B = load
        LogicalSchema jbschema8 = new LogicalSchema();
        jbschema8.addField(new LogicalSchema.LogicalFieldSchema(
            "y", null, DataType.INTEGER));
        jbschema8.addField(new LogicalSchema.LogicalFieldSchema(
            "z", null, DataType.LONG));
        LOLoad B8 = newLOLoad(new FileSpec("/def",
            new FuncSpec("PigStorage", "\t")), jbschema8, lp, conf);
        lp.add(B8);
       
        // C = join
        LogicalSchema jcschema8 = new LogicalSchema();
        jcschema8.addField(new LogicalSchema.LogicalFieldSchema(
            "x", null, DataType.INTEGER));
        jcschema8.addField(new LogicalSchema.LogicalFieldSchema(
            "y", null, DataType.INTEGER));
        LogicalExpressionPlan aprojplan8 = new LogicalExpressionPlan();
        new ProjectExpression(aprojplan8, 0, 0, null);
        LogicalExpressionPlan bprojplan8 = new LogicalExpressionPlan();
        new ProjectExpression(bprojplan8, 1, 0, null);
        MultiMap<Integer, LogicalExpressionPlan> mm8 =
            new MultiMap<Integer, LogicalExpressionPlan>();
        mm8.put(0, aprojplan8);
        mm8.put(1, bprojplan8);
        LOJoin C8 = new LOJoin(lp, mm8, JOINTYPE.HASH, new boolean[] {true, true});
        C8.neverUseForRealSetSchema(jcschema8);
        lp.add(C8);
        lp.connect(A8, C8);
        lp.connect(B8, C8);
       
        assertFalse(C6.isEqual(C8));
View Full Code Here

                        "is only allowed if the input has a schema");
    }

    private LOJoin checkNumExpressionPlansForJoin(LogicalPlan lp, int numPlans) {
        Class<?> joinClass = org.apache.pig.newplan.logical.relational.LOJoin.class;
        LOJoin join = (LOJoin) NewLogicalPlanUtil.getRelOpFromPlan(lp, joinClass);

        for( int inp : join.getExpressionPlans().keySet()){
            List<LogicalExpressionPlan> plans = join.getExpressionPlans().get(inp);
            assertEquals("number of join exp plans", numPlans, plans.size());
        }

        return join;
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.newplan.logical.relational.LOJoin

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.