Package org.apache.pig.impl

Examples of org.apache.pig.impl.PigContext


    PigContext pc;
   
    @Override
    @BeforeClass
    public void setUp() throws ExecException {
        pc = new PigContext(ExecType.LOCAL, new Properties());
        pc.connect();
    }
View Full Code Here


        String query = "a = load 'students.txt' as (c1,c2,c3,c4); " +
                       "c = group a by c2; " +
                       "f = foreach c generate COUNT(org.apache.pig.builtin.Distinct($1.$2)); " +
                       "store f into 'out';";
        PigServer pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
        PigContext pc = pigServer.getPigContext();
        assertTrue((Util.buildMRPlan(Util.buildPp(pigServer,query),pc).getRoots().get(0).combinePlan.isEmpty()));
    }
View Full Code Here

                       "c = group a by c2; " +
                       "f = foreach c generate COUNT(" + dummyUDF + "" +
                      "(org.apache.pig.builtin.Distinct($1.$2),"+dummyUDF+"())); " +
                      "store f into 'out';";
        PigServer pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
        PigContext pc = pigServer.getPigContext();
        assertTrue((Util.buildMRPlan(Util.buildPp(pigServer,query),pc).getRoots().get(0).combinePlan.isEmpty()));
    }
View Full Code Here

            throw new IllegalStateException("ExecType: " + context.getExecType());
        }
    }

    public static Object getPigConstant(String pigConstantAsString) throws ParserException {
        QueryParserDriver queryParser = new QueryParserDriver( new PigContext(),
            "util", new HashMap<String, String>() ) ;
        return queryParser.parseConstant(pigConstantAsString);
    }
View Full Code Here

                    replFile);
           
            Properties props = new Properties();                                         
            props.setProperty(MapRedUtil.FILE_SYSTEM_NAME, "file:///");
                        
            PigContext pc = new PigContext(ExecType.LOCAL, props);  
            ld.setPc(pc);
            // We use LocalRearrange Operator to seperate Key and Values
            // eg. ( a, b, c ) would generate a, ( a, b, c )
            // And we use 'a' as the key to the HashMap
            // The rest '( a, b, c )' is added to HashMap as value
View Full Code Here

    MiniCluster cluster = MiniCluster.buildCluster();
   
    @Before
    @Override
    protected void setUp() throws Exception {
        pigContext = new PigContext(ExecType.LOCAL, getProperties());
        input = File.createTempFile("PigContextTest-", ".txt");
    }
View Full Code Here

        String jarFile = tmpDir.getAbsolutePath() + FILE_SEPARATOR + jarName;
        status = Util.executeJavaCommand("jar -cf " + tmpDir.getAbsolutePath() + FILE_SEPARATOR + jarName +
                              " -C " + tmpDir.getAbsolutePath() + " " + "com");
        assertTrue(status==0);
        Properties properties = cluster.getProperties();
        PigContext pigContext = new PigContext(ExecType.MAPREDUCE, properties);
       
        //register jar using properties
        pigContext.getProperties().setProperty("pig.additional.jars", jarFile);
        PigServer pigServer = new PigServer(pigContext);

        PigContext.initializeImportList("com.xxx.udf1:com.xxx.udf2.");
        ArrayList<String> importList = PigContext.getPackageImportList();
        assertTrue(importList.size()==5);
View Full Code Here

    private MiniCluster cluster = MiniCluster.buildCluster();
   
    @Test
    public void testLocalModeInputPositive() throws Throwable {
       
        PigContext ctx = new PigContext(ExecType.LOCAL, new Properties()) ;
        ctx.connect() ;
       
        String inputfile = generateTempFile().getAbsolutePath() ;
        String outputfile = generateNonExistenceTempFile().getAbsolutePath() ;

        LogicalPlan plan = genNewLoadStorePlan(inputfile, outputfile, ctx.getFs()) ;       
       
        CompilationMessageCollector collector = new CompilationMessageCollector() ;       
        boolean isBeforeOptimizer = false; // we are not optimizing in this testcase
        LogicalPlanValidationExecutor executor = new LogicalPlanValidationExecutor(plan, ctx, isBeforeOptimizer) ;
        executor.validate(plan, collector) ;
View Full Code Here

   
      
    @Test
    public void testLocalModeNegative2() throws Throwable {
       
        PigContext ctx = new PigContext(ExecType.LOCAL, new Properties()) ;
        ctx.connect() ;
       
        String inputfile = generateTempFile().getAbsolutePath() ;
        String outputfile = generateTempFile().getAbsolutePath() ;

        LogicalPlan plan = genNewLoadStorePlan(inputfile, outputfile, ctx.getDfs()) ;       
       
        CompilationMessageCollector collector = new CompilationMessageCollector() ;       
        boolean isBeforeOptimizer = false; // we are not optimizing in this testcase
        LogicalPlanValidationExecutor executor = new LogicalPlanValidationExecutor(plan, ctx, isBeforeOptimizer) ;
        try {
View Full Code Here

    }
       
    @Test
    public void testMapReduceModeInputPositive() throws Throwable {
       
        PigContext ctx = new PigContext(ExecType.MAPREDUCE, cluster.getProperties()) ;      
        ctx.connect() ;
       
        String inputfile = createHadoopTempFile(ctx) ;
        String outputfile = createHadoopNonExistenceTempFile(ctx) ;

        LogicalPlan plan = genNewLoadStorePlan(inputfile, outputfile, ctx.getDfs()) ;                    
       
        CompilationMessageCollector collector = new CompilationMessageCollector() ;       
        boolean isBeforeOptimizer = false; // we are not optimizing in this testcase
        LogicalPlanValidationExecutor executor = new LogicalPlanValidationExecutor(plan, ctx, isBeforeOptimizer) ;
        executor.validate(plan, collector) ;
View Full Code Here

TOP

Related Classes of org.apache.pig.impl.PigContext

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.