Examples of registerScript()


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

        for (String line : statement) {
            writer.write(line + "\n");
        }
        writer.close();
       
        pig.registerScript(tmpFile.getAbsolutePath());
        Iterator<Tuple> iterator = pig.openIterator("D");
        while (iterator.hasNext()) {
            Tuple tuple = iterator.next();
            if ("dumb".equals(tuple.get(0).toString())) {
                assertEquals(tuple.get(1).toString(), "joe");
View Full Code Here

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

        pwScript.println("sh " + strRemove + " " + Util.encodeEscape(inputFile.getAbsolutePath()));
        pwScript.close();

        InputStream inputStream = new FileInputStream(inputScript.getAbsoluteFile());
        server.setBatchOn();
        server.registerScript(inputStream);
        List<ExecJob> execJobs = server.executeBatch();
        assertTrue(execJobs.get(0).getStatus() == JOB_STATUS.COMPLETED);
    }

    @Test
View Full Code Here

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

            script.append("set io.sort.mb 1000;")
                    .append("A = LOAD 'foo' USING mock.Storage() AS (f1:chararray,f2:int,f3:chararray);")
                    .append("B = order A by f1,f2,f3 DESC;")
                    .append("STORE B INTO 'bar' USING mock.Storage();");

            pigServer.registerScript(IOUtils.toInputStream(script));
            fail();
        } catch (Exception e) {
            Util.assertExceptionAndMessage(FrontendException.class, e,
                    "SET command is not permitted. ");
        }
View Full Code Here

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

        for (String line : statement) {
            writer.write(line + "\n");
        }
        writer.close();
       
        pig.registerScript(tmpFile.getAbsolutePath());
        Iterator<Tuple> iterator = pig.openIterator("D");
        while (iterator.hasNext()) {
            Tuple tuple = iterator.next();
            if ("dumb".equals(tuple.get(0).toString())) {
                assertEquals(tuple.get(1).toString(), "joe");
View Full Code Here

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

        pwScript.println("sh " + strRemove + " " + Util.encodeEscape(inputFile.getAbsolutePath()));
        pwScript.close();

        InputStream inputStream = new FileInputStream(inputScript.getAbsoluteFile());
        server.setBatchOn();
        server.registerScript(inputStream);
        List<ExecJob> execJobs = server.executeBatch();
        assertTrue(execJobs.get(0).getStatus() == JOB_STATUS.COMPLETED);
    }

    @Test
View Full Code Here

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

      query.append("A = LOAD 'foo' USING mock.Storage() AS (i:int);\n");
      query.append("ASSERT A BY i > 0;\n");
      query.append("STORE A INTO 'bar' USING mock.Storage();");

      InputStream is = new ByteArrayInputStream(query.toString().getBytes());
      pigServer.registerScript(is);

      List<Tuple> out = data.get("bar");
      assertEquals(3, out.size());
      assertEquals(tuple(1), out.get(0));
      assertEquals(tuple(2), out.get(1));
View Full Code Here

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

    }

    @Test
    public void testUDFWithoutParameter() throws Exception {
        PigServer pig = new PigServer(ExecType.LOCAL);
        pig.registerScript(TempScriptFile.getAbsolutePath());

        Iterator<Tuple> iterator=pig.openIterator("B");
        int index=0;
        while(iterator.hasNext()){
            Tuple tuple=iterator.next();
View Full Code Here

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

    }

    @Test
    public void testUDFReturnMap_LocalMode() throws Exception {
        PigServer pig = new PigServer(ExecType.LOCAL);
        pig.registerScript(TempScriptFile.getAbsolutePath());

        Iterator<Tuple> iterator = pig.openIterator("B");
        while (iterator.hasNext()) {
            Tuple tuple = iterator.next();
            Map<Object, Object> result = (Map<Object, Object>) tuple.get(0);
View Full Code Here

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

       
        PigServer pig = new PigServer(ExecType.MAPREDUCE, cluster
                .getProperties());
       
        FileInputStream fis = new FileInputStream(inputScriptName);
        pig.registerScript(fis);
       
        FileSystem fs = FileSystem.get(ConfigurationUtil.toConfiguration(
                pig.getPigContext().getProperties()));
        FileStatus stat = fs.getFileStatus(new Path("output3/part-m-00000.bz2"));       
        assertTrue(stat.getLen() > 0);    
View Full Code Here

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

          "STORE joined INTO '/tmp/test_out.tsv';";

        PigServer pig = new PigServer(ExecType.LOCAL);
        // Execution of the script should fail, but without throwing any exceptions (such as NPE)
        try {
            pig.registerScript(new ByteArrayInputStream(script.getBytes("UTF-8")));
        } catch(Exception ex) {
            fail("Unexpected exception: " + ex);
        }
    }
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.