Package org.apache.pig.experimental.logical.relational

Examples of org.apache.pig.experimental.logical.relational.LogicalPlan


    LogicalRelationalOperator filter = null;
    LogicalRelationalOperator join = null;
    LogicalRelationalOperator store = null;   
   
    private void prep() {
        plan = new LogicalPlan();
        LogicalSchema schema = new LogicalSchema();
        schema.addField(new LogicalSchema.LogicalFieldSchema("id", null, DataType.INTEGER));
        schema.addField(new LogicalSchema.LogicalFieldSchema("name", null, DataType.CHARARRAY));
        schema.addField(new LogicalSchema.LogicalFieldSchema("age", null, DataType.INTEGER));   
        schema.getField(0).uid = 1;
View Full Code Here


        assertTrue( lp.isEqual(lp1));
    }
   
    @Test
    public void testLoadEqualityDifferentFuncSpecCtorArgs() {
        LogicalPlan lp = new LogicalPlan();
       
        LogicalSchema aschema1 = new LogicalSchema();
        aschema1.addField(new LogicalSchema.LogicalFieldSchema(
            "x", null, DataType.INTEGER));
        LOLoad load1 = new LOLoad(new FileSpec("/abc",
            new FuncSpec("foo", new String[] {"x", "y"})), aschema1, lp);
        lp.add(load1);
       
        LOLoad load2 = new LOLoad(new FileSpec("/abc",
            new FuncSpec("foo", new String[] {"x", "z"})), aschema1, lp);
        lp.add(load2);
       
        assertFalse(load1.isEqual(load2));
    }
View Full Code Here

        assertFalse(load1.isEqual(load2));
    }
   
    @Test
    public void testLoadEqualityDifferentNumFuncSpecCstorArgs() {
        LogicalPlan lp = new LogicalPlan();
       
        LogicalSchema aschema1 = new LogicalSchema();
        aschema1.addField(new LogicalSchema.LogicalFieldSchema(
            "x", null, DataType.INTEGER));
        LOLoad load1 = new LOLoad(new FileSpec("/abc",
            new FuncSpec("foo", new String[] {"x", "y"})), aschema1, lp);
        lp.add(load1);
       
        LOLoad load3 = new LOLoad(new FileSpec("/abc",
            new FuncSpec("foo", "x")), aschema1, lp);
        lp.add(load3);
       
        assertFalse(load1.isEqual(load3));
    }
View Full Code Here

        assertFalse(load1.isEqual(load3));
    }
   
    @Test
    public void testLoadEqualityDifferentFunctionNames() {
        LogicalPlan lp = new LogicalPlan();
       
        LogicalSchema aschema1 = new LogicalSchema();
        aschema1.addField(new LogicalSchema.LogicalFieldSchema(
            "x", null, DataType.INTEGER));
        LOLoad load1 = new LOLoad(new FileSpec("/abc",
            new FuncSpec("foo", new String[] {"x", "y"})), aschema1, lp);
        lp.add(load1);
       
         // Different function names in FuncSpec
        LOLoad load4 = new LOLoad(new FileSpec("/abc",
            new FuncSpec("foobar", new String[] {"x", "z"})), aschema1, lp);
        lp.add(load4);
       
        assertFalse(load1.isEqual(load4));
    }
View Full Code Here

        assertFalse(load1.isEqual(load4));
    }
   
    @Test
    public void testLoadEqualityDifferentFileName() {
        LogicalPlan lp = new LogicalPlan();
        LogicalSchema aschema1 = new LogicalSchema();
        aschema1.addField(new LogicalSchema.LogicalFieldSchema(
            "x", null, DataType.INTEGER));
        LOLoad load1 = new LOLoad(new FileSpec("/abc",
            new FuncSpec("foo", new String[] {"x", "y"})), aschema1, lp);
        lp.add(load1);
   
        // Different file name
        LOLoad load5 = new LOLoad(new FileSpec("/def",
            new FuncSpec("foo", new String[] {"x", "z"})), aschema1, lp);
        lp.add(load5);
       
        assertFalse(load1.isEqual(load5));
    }
View Full Code Here

        assertFalse(load1.isEqual(load5));
    }
   
    @Test
    public void testRelationalEqualityDifferentSchema() {
        LogicalPlan lp = new LogicalPlan();
        LogicalSchema aschema1 = new LogicalSchema();
        aschema1.addField(new LogicalSchema.LogicalFieldSchema(
            "x", null, DataType.INTEGER));
        LOLoad load1 = new LOLoad(new FileSpec("/abc",
            new FuncSpec("foo", new String[] {"x", "y"})), aschema1, lp);
        lp.add(load1);
       
        // Different schema
        LogicalSchema aschema2 = new LogicalSchema();
        aschema2.addField(new LogicalSchema.LogicalFieldSchema(
            "x", null, DataType.CHARARRAY));
       
        LOLoad load6 = new LOLoad(new FileSpec("/abc",
            new FuncSpec("foo", new String[] {"x", "z"})), aschema2, lp);
        lp.add(load6);
           
        assertFalse(load1.isEqual(load6));
    }
View Full Code Here

        assertFalse(load1.isEqual(load6));
    }
   
    @Test
    public void testRelationalEqualityNullSchemas() {
        LogicalPlan lp = new LogicalPlan();
        // Test that two loads with no schema are still equal
        LOLoad load7 = new LOLoad(new FileSpec("/abc",
            new FuncSpec("foo", new String[] {"x", "y"})), null, lp);
        lp.add(load7);
       
        LOLoad load8 = new LOLoad(new FileSpec("/abc",
            new FuncSpec("foo", new String[] {"x", "y"})), null, lp);
        lp.add(load8);
       
        assertTrue(load7.isEqual(load8));
    }
View Full Code Here

        assertTrue(load7.isEqual(load8));
    }
   
    @Test
    public void testRelationalEqualityOneNullOneNotNullSchema() {
        LogicalPlan lp = new LogicalPlan();
        LogicalSchema aschema1 = new LogicalSchema();
        aschema1.addField(new LogicalSchema.LogicalFieldSchema(
            "x", null, DataType.INTEGER));
        LOLoad load1 = new LOLoad(new FileSpec("/abc",
            new FuncSpec("foo", new String[] {"x", "y"})), aschema1, lp);
        lp.add(load1);
       
        // Test that one with schema and one without breaks equality
        LOLoad load9 = new LOLoad(new FileSpec("/abc",
            new FuncSpec("foo", new String[] {"x", "z"})), null, lp);
        lp.add(load9);
       
        assertFalse(load1.isEqual(load9));
    }
View Full Code Here

        assertFalse(load1.isEqual(load9));
    }
       
    @Test
    public void testFilterDifferentPredicates() {
        LogicalPlan lp = new LogicalPlan();
           
        LogicalExpressionPlan fp1 = new LogicalExpressionPlan();
        ProjectExpression fy1 = new ProjectExpression(fp1, DataType.INTEGER, 0, 1);
        ConstantExpression fc1 = new ConstantExpression(fp1, DataType.INTEGER,
            new Integer(0));
        new EqualExpression(fp1, fy1, fc1);
        LOFilter D1 = new LOFilter(lp, fp1);
        LogicalSchema cschema = new LogicalSchema();
        cschema.addField(new LogicalSchema.LogicalFieldSchema(
            "x", null, DataType.INTEGER));
        cschema.addField(new LogicalSchema.LogicalFieldSchema(
            "y", null, DataType.INTEGER));
        D1.neverUseForRealSetSchema(cschema);
        lp.add(D1);
       
        LogicalExpressionPlan fp2 = new LogicalExpressionPlan();
        ProjectExpression fy2 = new ProjectExpression(fp2, DataType.INTEGER, 0, 1);
        ConstantExpression fc2 = new ConstantExpression(fp2, DataType.INTEGER,
            new Integer(1));
        new EqualExpression(fp2, fy2, fc2);
        LOFilter D2 = new LOFilter(lp, fp2);
        D2.neverUseForRealSetSchema(cschema);
        lp.add(D2);
       
        assertFalse(D1.isEqual(D2));
    }
View Full Code Here

    // No tests for LOStore because it tries to actually instantiate the store
    // func, and I don't want to mess with that here.
   
    @Test
    public void testJoinDifferentJoinTypes() throws IOException {
       LogicalPlan lp = new LogicalPlan();
       LogicalSchema jaschema1 = new LogicalSchema();
       jaschema1.addField(new LogicalSchema.LogicalFieldSchema(
           "x", null, DataType.INTEGER));
       LOLoad A1 = new LOLoad(new FileSpec("/abc",
           new FuncSpec("/fooload", new String[] {"x", "y"})), jaschema1, lp);
       lp.add(A1);
       
        // B = load
        LogicalSchema jbschema1 = new LogicalSchema();
        jbschema1.addField(new LogicalSchema.LogicalFieldSchema(
            "y", null, DataType.INTEGER));
        LOLoad B1 = new LOLoad(new FileSpec("/def",
            new FuncSpec("PigStorage", "\t")), jbschema1, lp);
        lp.add(B1);
       
        // C = join
        LogicalSchema jcschema1 = new LogicalSchema();
        jcschema1.addField(new LogicalSchema.LogicalFieldSchema(
            "x", null, DataType.INTEGER));
        jcschema1.addField(new LogicalSchema.LogicalFieldSchema(
            "y", null, DataType.INTEGER));
        LogicalExpressionPlan aprojplan1 = new LogicalExpressionPlan();
        new ProjectExpression(aprojplan1, DataType.INTEGER, 0, 0);
        LogicalExpressionPlan bprojplan1 = new LogicalExpressionPlan();
        new ProjectExpression(bprojplan1, DataType.INTEGER, 1, 0);
        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 = new LOLoad(new FileSpec("/abc",
           new FuncSpec("/fooload", new String[] {"x", "y"})), jaschema2, lp);
        lp.add(A2);
       
        // B = load
        LogicalSchema jbschema2 = new LogicalSchema();
        jbschema2.addField(new LogicalSchema.LogicalFieldSchema(
            "y", null, DataType.INTEGER));
        LOLoad B2 = new LOLoad(new FileSpec("/def",
            new FuncSpec("PigStorage", "\t")), jbschema2, lp);
        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, DataType.INTEGER, 0, 0);
        LogicalExpressionPlan bprojplan2 = new LogicalExpressionPlan();
        new ProjectExpression(bprojplan2, DataType.INTEGER, 1, 0);
        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

TOP

Related Classes of org.apache.pig.experimental.logical.relational.LogicalPlan

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.