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


Java PigServer.getPigContext方法代码示例

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


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

示例1: testPartialExecution

import org.apache.pig.PigServer; //导入方法依赖的package包/类
@Test
public void testPartialExecution() throws Throwable {
    PigServer server = new PigServer(cluster.getExecType(), cluster.getProperties());
    PigContext context = server.getPigContext();
    FileLocalizer.setInitialized(false);

    String strCmd = "rmf bar; rmf baz; "
            + "a = load '"
            + Util.generateURI("file:test/org/apache/pig/test/data/passwd",
                    context)
            + "';"
            + "store a into 'bar'; exec; a = load 'bar'; store a into 'baz';\n";

    ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
    InputStreamReader reader = new InputStreamReader(cmd);

    Grunt grunt = new Grunt(new BufferedReader(reader), context);

    grunt.exec();
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:21,代码来源:TestGrunt.java

示例2: testIllustrateScript4

import org.apache.pig.PigServer; //导入方法依赖的package包/类
@Test
public void testIllustrateScript4() throws Throwable {
    // empty line/field test
    PigServer server = new PigServer(ExecType.LOCAL, new Properties());
    PigContext context = server.getPigContext();

    String strCmd = "illustrate -script "
            + basedir + "/illustrate4.pig;";

    ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
    InputStreamReader reader = new InputStreamReader(cmd);

    Grunt grunt = new Grunt(new BufferedReader(reader), context);

    grunt.exec();
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:17,代码来源:TestGrunt.java

示例3: testIllustrateScript4

import org.apache.pig.PigServer; //导入方法依赖的package包/类
@Test
public void testIllustrateScript4() throws Throwable {
    // empty line/field test
    PigServer server = new PigServer(ExecType.LOCAL, new Properties());
    PigContext context = server.getPigContext();
    
    String strCmd = "illustrate -script "
            + basedir + "/illustrate4.pig;";
    
    ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
    InputStreamReader reader = new InputStreamReader(cmd);
    
    Grunt grunt = new Grunt(new BufferedReader(reader), context);

    grunt.exec();
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:17,代码来源:TestGrunt.java

示例4: testCommaSeparatedString3

import org.apache.pig.PigServer; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testCommaSeparatedString3() throws Exception {
    PigServer pig = servers[0];
    pc = pig.getPigContext();
    boolean noConversionExpected = true;
    checkLoadPath("hdfs:/tmp/test,hdfs:/tmp/test2,hdfs:/tmp/test3",
            "hdfs:/tmp/test,hdfs:/tmp/test2,hdfs:/tmp/test3", noConversionExpected );
    
    // check if a location 'hdfs:<abs path>,hdfs:<abs path>' can actually be 
    // read using PigStorage
    String[] inputFileNames = new String[] {
            "/tmp/TestLoad-testCommaSeparatedString3-input1.txt",
            "/tmp/TestLoad-testCommaSeparatedString3-input2.txt"};
    String inputString = "hdfs:" + inputFileNames[0] + ",hdfs:" + 
    inputFileNames[1];
    testLoadingMultipleFiles(inputFileNames, inputString);
    
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:20,代码来源:TestLoad.java

示例5: testParsingAsInForeachBlock

import org.apache.pig.PigServer; //导入方法依赖的package包/类
@Test 
public void testParsingAsInForeachBlock() throws Throwable {
    PigServer server = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
    PigContext context = server.getPigContext();
    
    String strCmd = "a = load 'foo' as (foo, fast); "
            + "b = group a by foo; c = foreach b "
            + "{generate SUM(a.fast) as fast;};\n";
    
    ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
    InputStreamReader reader = new InputStreamReader(cmd);
    
    Grunt grunt = new Grunt(new BufferedReader(reader), context);

    grunt.exec();
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:17,代码来源:TestGrunt.java

示例6: testParsingAsGenerateInForeachWithOutBlock

import org.apache.pig.PigServer; //导入方法依赖的package包/类
@Test 
public void testParsingAsGenerateInForeachWithOutBlock() throws Throwable {
    PigServer server = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
    PigContext context = server.getPigContext();
    
    String strCmd = "a = load 'foo' as (foo, fast, regenerate); "
            + "b = group a by foo; c = foreach b generate "
            + "{(1, '1', 0.4f),(2, '2', 0.45)} "
            + "as b: bag{t:(i: int, cease:chararray, degenerate: double)}, "
            + "SUM(a.fast) as fast, a.regenerate as degenerated;\n";
    
    ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
    InputStreamReader reader = new InputStreamReader(cmd);
    
    Grunt grunt = new Grunt(new BufferedReader(reader), context);

    grunt.exec();
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:19,代码来源:TestGrunt.java

示例7: testPartialExecution

import org.apache.pig.PigServer; //导入方法依赖的package包/类
@Test
public void testPartialExecution() throws Throwable {
    PigServer server = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
    PigContext context = server.getPigContext();
    FileLocalizer.setInitialized(false);
    
    String strCmd = "rmf bar; rmf baz; "
            + "a = load '"
            + Util.generateURI("file:test/org/apache/pig/test/data/passwd",
                    context)
            + "';"
            + "store a into 'bar'; exec; a = load 'bar'; store a into 'baz';\n";
    
    ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
    InputStreamReader reader = new InputStreamReader(cmd);
    
    Grunt grunt = new Grunt(new BufferedReader(reader), context);

    grunt.exec();
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:21,代码来源:TestGrunt.java

示例8: testDump

import org.apache.pig.PigServer; //导入方法依赖的package包/类
@Test
public void testDump() throws Throwable {
    PigServer server = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
    PigContext context = server.getPigContext();
    
    String strCmd = 
        "rmf bla;"
        +"a = load '"
        + Util.generateURI("file:test/org/apache/pig/test/data/passwd", context) + "';"
        +"e = group a by $0;"
        +"f = foreach e generate group, COUNT($1);"
        +"store f into 'bla';"
        +"f1 = load 'bla';"
        +"g = order f1 by $1;"
        +"dump g;";

    ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
    InputStreamReader reader = new InputStreamReader(cmd);
    
    Grunt grunt = new Grunt(new BufferedReader(reader), context);

    grunt.exec();
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:24,代码来源:TestGrunt.java

示例9: testCD

import org.apache.pig.PigServer; //导入方法依赖的package包/类
@Test
public void testCD() throws Throwable {
    PigServer server = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
    PigContext context = server.getPigContext();

    String strCmd = 
        "mkdir /tmp;"
        +"mkdir /tmp/foo;"
        +"cd /tmp;"
        +"rmf bar; rmf foo/baz;"
        +"copyFromLocal test/org/apache/pig/test/data/passwd bar;"
        +"a = load 'bar';"
        +"cd foo;"
        +"store a into 'baz';"
        +"cd /;"
        +"rm /tmp/bar; rm /tmp/foo/baz;";
    
    ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
    InputStreamReader reader = new InputStreamReader(cmd);
    
    Grunt grunt = new Grunt(new BufferedReader(reader), context);

    grunt.exec();
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:25,代码来源:TestGrunt.java

示例10: testKeepGoigFailed

import org.apache.pig.PigServer; //导入方法依赖的package包/类
@Test
public void testKeepGoigFailed() throws Throwable {
    PigServer server = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
    PigContext context = server.getPigContext();
    Util.copyFromLocalToCluster(cluster, "test/org/apache/pig/test/data/passwd", "passwd");
    String strCmd = 
        "rmf bar;"
        +"rmf foo;"
        +"rmf baz;"
        +"A = load 'passwd';"
        +"B = foreach A generate 1;"
        +"C = foreach A generate 0/0;"
        +"store B into 'foo';"
        +"store C into 'bar';"
        +"A = load 'passwd';"
        +"B = stream A through `false`;"
        +"store B into 'baz';"
        +"cat baz;";
        
    ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
    InputStreamReader reader = new InputStreamReader(cmd);
    
    Grunt grunt = new Grunt(new BufferedReader(reader), context);

    boolean caught = false;
    try {
        grunt.exec();
    } catch (Exception e) {
        caught = true;
        assertTrue(e.getMessage().contains("baz does not exist"));
    }
    assertTrue(caught);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:34,代码来源:TestGrunt.java

示例11: testGlobChars

import org.apache.pig.PigServer; //导入方法依赖的package包/类
@Test
public void testGlobChars() throws Exception {
    for (PigServer pig : servers) {
        pc = pig.getPigContext();
        checkLoadPath("t?s*","/tmp/t?s*");
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:8,代码来源:TestLoad.java

示例12: testCommaSeparatedString

import org.apache.pig.PigServer; //导入方法依赖的package包/类
@Test
public void testCommaSeparatedString() throws Exception {
    for (PigServer pig : servers) {
        pc = pig.getPigContext();
        checkLoadPath("usr/pig/a,usr/pig/b","/tmp/usr/pig/a,/tmp/usr/pig/b");
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:8,代码来源:TestLoad.java

示例13: testCopyFromLocal

import org.apache.pig.PigServer; //导入方法依赖的package包/类
@Test
public void testCopyFromLocal() throws Throwable {
    PigServer server = new PigServer(cluster.getExecType(), cluster.getProperties());
    PigContext context = server.getPigContext();

    String strCmd = "copyFromLocal README.txt sh_copy ;";

    ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
    InputStreamReader reader = new InputStreamReader(cmd);

    Grunt grunt = new Grunt(new BufferedReader(reader), context);

    grunt.exec();
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:15,代码来源:TestGrunt.java

示例14: testParsingWordWithAsInForeachWithOutBlock2

import org.apache.pig.PigServer; //导入方法依赖的package包/类
@Test
public void testParsingWordWithAsInForeachWithOutBlock2() throws Throwable {
    PigServer server = new PigServer(cluster.getExecType(), cluster.getProperties());
    PigContext context = server.getPigContext();

    String strCmd = "cash = load 'foo' as (foo, fast); "
            + "b = foreach cash generate fast * 2.0;\n";

    ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
    InputStreamReader reader = new InputStreamReader(cmd);

    Grunt grunt = new Grunt(new BufferedReader(reader), context);

    grunt.exec();
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:16,代码来源:TestGrunt.java

示例15: setUp

import org.apache.pig.PigServer; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    pig = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
    pigContext = pig.getPigContext();
    int LOOP_SIZE = 20;
    tmpFile = File.createTempFile("test", "txt");
    tmpFile.deleteOnExit();
    PrintStream ps = new PrintStream(new FileOutputStream(tmpFile));
    for(int i = 1; i <= LOOP_SIZE; i++) {
        ps.println(i);
    }
    ps.close();
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:14,代码来源:TestSplitStore.java


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