Package org.apache.pig

Examples of org.apache.pig.PigServer.openIterator()


        HashMap<String, Object[]> results = new HashMap<String, Object[]>();
        results.put("pig1", new Object[] {"pig1","bag-place-holder",75L,9.4});
        results.put("pig2", new Object[] {"pig2","bag-place-holder",48L,7.8});
        results.put("pig5", new Object[] {"pig5","bag-place-holder",45L,2.4});
        Iterator<Tuple> it = pigServer.openIterator("c");
        while(it.hasNext()) {
            Tuple t = it.next();
            List<Object> fields = t.getAll();
            Object[] expected = results.get((String)fields.get(0));
            int i = 0;
View Full Code Here


            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            PrintStream ps = new PrintStream(baos);
            pigServer.explain("c", ps);
            assertFalse(baos.toString().matches("(?si).*combine plan.*"));
   
            Iterator<Tuple> it = pigServer.openIterator("c");
            int count = 0;
            while (it.hasNext()) {
                Tuple t = it.next();
                assertEquals(expected[count++], t.toString());
            }
View Full Code Here

        
         PigServer ps = new PigServer(ExecType.LOCAL);
         // load as bytearray and use as map
         ps.registerQuery("a = load 'file://" + inputFileName + "' as (m);");
         ps.registerQuery("b = foreach a generate m#'k1';");
         Iterator<Tuple> it = ps.openIterator("b");
         String[] expectedResults = new String[] {"(hello)", "(good)"};
         int i = 0;
         while(it.hasNext()) {
             assertEquals(expectedResults[i++], it.next().toString());
         }
View Full Code Here

        String query = "a = load '" + inputFileName + "' as (s1:chararray, s2:chararray, extra:chararray);" +
            "b = foreach a generate s1, s2, extra;";
       
        PigServer ps = new PigServer(ExecType.LOCAL);
        Util.registerMultiLineQuery(ps, query);
        Iterator<Tuple> it = ps.openIterator("b");
        Tuple[] expectedResults = new Tuple[] {
                (Tuple) Util.getPigConstant("('hello', 'world', null)"),
                (Tuple) Util.getPigConstant("('good', 'bye', null)")
        };
        int i = 0;
View Full Code Here

            "t:tuple(s1:chararray, s2:chararray, s3:chararray));" +
                "b = foreach a generate t.(s2,s3);";
       
        PigServer ps = new PigServer(ExecType.LOCAL);
        Util.registerMultiLineQuery(ps, query);
        Iterator<Tuple> it = ps.openIterator("b");
        Tuple[] expectedResults = new Tuple[] {
                (Tuple) Util.getPigConstant("((null, null))"),
                (Tuple) Util.getPigConstant("((null, null))")
        };
        int i = 0;
View Full Code Here

                "b = group a all;" +
                "c = foreach b generate flatten(a.($1, $2)),a.$2;";
       
        PigServer ps = new PigServer(ExecType.LOCAL);
        Util.registerMultiLineQuery(ps, query);
        Iterator<Tuple> it = ps.openIterator("c");
        Tuple[] expectedResults = new Tuple[] {
                (Tuple) Util.getPigConstant("('world', null, {(null),(null)})"),
                (Tuple) Util.getPigConstant("('bye', null, {(null),(null)})")
        };
        int i = 0;
View Full Code Here

            "t:tuple(s1:chararray, s2:chararray));" +
                "b = foreach a generate t.s1, t.s2;";
       
        PigServer ps = new PigServer(ExecType.LOCAL);
        Util.registerMultiLineQuery(ps, query);
        Iterator<Tuple> it = ps.openIterator("b");
        Tuple[] expectedResults = new Tuple[] {
                (Tuple) Util.getPigConstant("('hello', 'world')"),
                (Tuple) Util.getPigConstant("(null, null)"),
                (Tuple) Util.getPigConstant("(null, null)")
        };
View Full Code Here

        // will do the value verification later
        assertEquals(-1, cis.read(new byte[100]));
        cis.close();
       
        pig.registerQuery("B = load '" + out.getAbsolutePath() + "';");
        pig.openIterator("B");
       
        in.delete();
        out.delete();
       
    }
View Full Code Here

        }
        assertEquals(true, numPartFiles > 0);
       
        // verify record count to verify we read bzip data correctly
        Util.registerMultiLineQuery(pig, script);
        Iterator<Tuple> it = pig.openIterator("c");
        Long result = (Long) it.next().get(0);
        assertEquals(expectedCount, result);
       
    }
   
View Full Code Here

            // pig script to read uncompressed input
            String script = "a = load '" + unCompressedInputFileName +"';";
            PigServer pig = new PigServer(ExecType.MAPREDUCE, cluster
                    .getProperties());
            pig.registerQuery(script);
            Iterator<Tuple> it1 = pig.openIterator("a");
           
            // pig script to read compressed concatenated input
            script = "a = load '" + compressedInputFileName1 +"';";
            pig.registerQuery(script);
            Iterator<Tuple> it2 = pig.openIterator("a");
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.