当前位置: 首页>>代码示例>>Java>>正文


Java PigStats.getOutputNames方法代码示例

本文整理汇总了Java中org.apache.pig.tools.pigstats.PigStats.getOutputNames方法的典型用法代码示例。如果您正苦于以下问题:Java PigStats.getOutputNames方法的具体用法?Java PigStats.getOutputNames怎么用?Java PigStats.getOutputNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.pig.tools.pigstats.PigStats的用法示例。


在下文中一共展示了PigStats.getOutputNames方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: simpleMultiQueryTest

import org.apache.pig.tools.pigstats.PigStats; //导入方法依赖的package包/类
@Test
public void simpleMultiQueryTest() throws Exception {
    final String OUTPUT_FILE_2 = "output2";
    
    PrintWriter w = new PrintWriter(new FileWriter(PIG_FILE));
    w.println("A = load '" + INPUT_FILE + "' as (a0:int, a1:int, a2:int);");
    w.println("B = filter A by a0 >= 4;");
    w.println("C = filter A by a0 < 4;");
    w.println("store B into '" + OUTPUT_FILE_2 + "';");
    w.println("store C into '" + OUTPUT_FILE + "';");
    w.close();
    
    try {
        String[] args = { PIG_FILE };
        PigStats stats = PigRunner.run(args, new TestNotificationListener());
        assertTrue(stats.isSuccessful());
        assertTrue(stats.getJobGraph().size() == 1);
        // Each output file should include the following:
        // output:
        //   1\t2\t3\n
        //   3\t4\t5\n
        //   3\t7\t8\n
        // output2:
        //   5\t3\t4\n
        //   5\t6\t7\n
        final int numOfRecords = 5;
        final int numOfCharsPerRecord = 6;
        assertEquals(numOfRecords, stats.getRecordWritten());
        assertEquals(numOfRecords * numOfCharsPerRecord, stats.getBytesWritten());
        assertTrue(stats.getOutputNames().size() == 2);
        for (String fname : stats.getOutputNames()) {
            assertTrue(fname.equals(OUTPUT_FILE) || fname.equals(OUTPUT_FILE_2));
            if (fname.equals(OUTPUT_FILE)) {
                assertEquals(3, stats.getNumberRecords(fname));
            } else {
                assertEquals(2, stats.getNumberRecords(fname));
            }                
        }            
        assertEquals("A,B,C",
                ((JobStats)stats.getJobGraph().getSinks().get(0)).getAlias());
    } finally {
        new File(PIG_FILE).delete();
        Util.deleteFile(cluster, OUTPUT_FILE);
        Util.deleteFile(cluster, OUTPUT_FILE_2);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:47,代码来源:TestPigRunner.java

示例2: simpleMultiQueryTest2

import org.apache.pig.tools.pigstats.PigStats; //导入方法依赖的package包/类
@Test
public void simpleMultiQueryTest2() throws Exception {
    final String OUTPUT_FILE_2 = "output2";
    
    PrintWriter w = new PrintWriter(new FileWriter(PIG_FILE));
    w.println("A = load '" + INPUT_FILE + "' as (a0:int, a1:int, a2:int);");
    w.println("B = filter A by a0 >= 4;");
    w.println("C = filter A by a0 < 4;");
    w.println("D = group C by a0;");
    w.println("E = foreach D generate group, COUNT(C);");
    w.println("store B into '" + OUTPUT_FILE_2 + "';");
    w.println("store E into '" + OUTPUT_FILE + "';");
    w.close();
    
    try {
        String[] args = { PIG_FILE };
        PigStats stats = PigRunner.run(args, new TestNotificationListener());
        assertTrue(stats.isSuccessful());
        assertTrue(stats.getJobGraph().size() == 1);
        // Each output file should include the following:
        // output:
        //   5\t3\t4\n
        //   5\t6\t7\n
        // output2:
        //   1\t1\n
        //   3\t2\n
        final int numOfRecords1 = 2;
        final int numOfRecords2 = 2;
        final int numOfCharsPerRecord1 = 6;
        final int numOfCharsPerRecord2 = 4;
        assertEquals(numOfRecords1 + numOfRecords2, stats.getRecordWritten());
        assertEquals((numOfRecords1 * numOfCharsPerRecord1) + (numOfRecords2 * numOfCharsPerRecord2),
                stats.getBytesWritten());
        assertTrue(stats.getOutputNames().size() == 2);
        for (String fname : stats.getOutputNames()) {               
            assertTrue(fname.equals(OUTPUT_FILE) || fname.equals(OUTPUT_FILE_2));
            if (fname.equals(OUTPUT_FILE)) {
                assertEquals(2, stats.getNumberRecords(fname));
            } else {
                assertEquals(2, stats.getNumberRecords(fname));
            }                
        }           
        assertEquals("A,B,C,D,E",
                ((JobStats)stats.getJobGraph().getSinks().get(0)).getAlias());
    } finally {
        new File(PIG_FILE).delete();
        Util.deleteFile(cluster, OUTPUT_FILE);
        Util.deleteFile(cluster, OUTPUT_FILE_2);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:51,代码来源:TestPigRunner.java

示例3: simpleMultiQueryTest

import org.apache.pig.tools.pigstats.PigStats; //导入方法依赖的package包/类
@Test
public void simpleMultiQueryTest() throws Exception {
    final String OUTPUT_FILE_2 = "output2";

    PrintWriter w = new PrintWriter(new FileWriter(PIG_FILE));
    w.println("A = load '" + INPUT_FILE + "' as (a0:int, a1:int, a2:int);");
    w.println("B = filter A by a0 >= 4;");
    w.println("C = filter A by a0 < 4;");
    w.println("store B into '" + OUTPUT_FILE_2 + "';");
    w.println("store C into '" + OUTPUT_FILE + "';");
    w.close();

    try {
        String[] args = { "-x", execType, PIG_FILE };
        PigStats stats = PigRunner.run(args, new TestNotificationListener(execType));
        assertTrue(stats.isSuccessful());
        assertTrue(stats.getJobGraph().size() == 1);
        // Each output file should include the following:
        // output:
        //   1\t2\t3\n
        //   3\t4\t5\n
        //   3\t7\t8\n
        // output2:
        //   5\t3\t4\n
        //   5\t6\t7\n
        final int numOfRecords = 5;
        final int numOfCharsPerRecord = 6;
        assertEquals(numOfRecords, stats.getRecordWritten());
        assertEquals(numOfRecords * numOfCharsPerRecord, stats.getBytesWritten());
        assertTrue(stats.getOutputNames().size() == 2);
        for (String fname : stats.getOutputNames()) {
            assertTrue(fname.equals(OUTPUT_FILE) || fname.equals(OUTPUT_FILE_2));
            if (fname.equals(OUTPUT_FILE)) {
                assertEquals(3, stats.getNumberRecords(fname));
            } else {
                assertEquals(2, stats.getNumberRecords(fname));
            }
        }
        assertEquals("A,B,C",
                ((JobStats)stats.getJobGraph().getSinks().get(0)).getAlias());
    } finally {
        new File(PIG_FILE).delete();
        Util.deleteFile(cluster, OUTPUT_FILE);
        Util.deleteFile(cluster, OUTPUT_FILE_2);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:47,代码来源:TestPigRunner.java

示例4: simpleMultiQueryTest2

import org.apache.pig.tools.pigstats.PigStats; //导入方法依赖的package包/类
@Test
public void simpleMultiQueryTest2() throws Exception {
    final String OUTPUT_FILE_2 = "output2";

    PrintWriter w = new PrintWriter(new FileWriter(PIG_FILE));
    w.println("A = load '" + INPUT_FILE + "' as (a0:int, a1:int, a2:int);");
    w.println("B = filter A by a0 >= 4;");
    w.println("C = filter A by a0 < 4;");
    w.println("D = group C by a0;");
    w.println("E = foreach D generate group, COUNT(C);");
    w.println("store B into '" + OUTPUT_FILE_2 + "';");
    w.println("store E into '" + OUTPUT_FILE + "';");
    w.close();

    try {
        String[] args = { "-x", execType, PIG_FILE };
        PigStats stats = PigRunner.run(args, new TestNotificationListener(execType));
        assertTrue(stats.isSuccessful());
        assertEquals(stats.getJobGraph().size(), 1);

        // Each output file should include the following:
        // output:
        //   5\t3\t4\n
        //   5\t6\t7\n
        // output2:
        //   1\t1\n
        //   3\t2\n
        final int numOfRecords1 = 2;
        final int numOfRecords2 = 2;
        final int numOfCharsPerRecord1 = 6;
        final int numOfCharsPerRecord2 = 4;
        assertEquals(numOfRecords1 + numOfRecords2, stats.getRecordWritten());
        assertEquals((numOfRecords1 * numOfCharsPerRecord1) + (numOfRecords2 * numOfCharsPerRecord2),
                stats.getBytesWritten());
        assertTrue(stats.getOutputNames().size() == 2);
        for (String fname : stats.getOutputNames()) {
            assertTrue(fname.equals(OUTPUT_FILE) || fname.equals(OUTPUT_FILE_2));
            if (fname.equals(OUTPUT_FILE)) {
                assertEquals(2, stats.getNumberRecords(fname));
            } else {
                assertEquals(2, stats.getNumberRecords(fname));
            }
        }
        assertEquals("A,B,C,D,E",
                ((JobStats)stats.getJobGraph().getSinks().get(0)).getAlias());
    } finally {
        new File(PIG_FILE).delete();
        Util.deleteFile(cluster, OUTPUT_FILE);
        Util.deleteFile(cluster, OUTPUT_FILE_2);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:52,代码来源:TestPigRunner.java


注:本文中的org.apache.pig.tools.pigstats.PigStats.getOutputNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。