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


Java LoadFunc.getNext方法代码示例

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


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

示例1: testLFText

import org.apache.pig.LoadFunc; //导入方法依赖的package包/类
/**
 * test {@link TextLoader} - this also tests that {@link TextLoader} is capable
 * of reading data a couple of dirs deep when the input specified is the top
 * level directory
 */
@Test
public void testLFText() throws Exception {
    String input1 = "This is some text.\nWith a newline in it.\n";
    String expected1 = "This is some text.";
    String expected2 = "With a newline in it.";
    Util.createInputFile(cluster,
            "testLFTest-input1.txt",
            new String[] {input1});
    // check that loading the top level dir still reading the file a couple
    // of subdirs below
    LoadFunc text1 = new ReadToEndLoader(new TextLoader(), ConfigurationUtil.
        toConfiguration(cluster.getProperties()), "testLFTest-input1.txt", 0);
    Tuple f1 = text1.getNext();
    Tuple f2 = text1.getNext();
    Util.deleteFile(cluster, "testLFTest-input1.txt");
    assertTrue(expected1.equals(f1.get(0).toString()) &&
        expected2.equals(f2.get(0).toString()));
    Util.createInputFile(cluster, "testLFTest-input2.txt", new String[] {});
    LoadFunc text2 = new ReadToEndLoader(new TextLoader(), ConfigurationUtil.
        toConfiguration(cluster.getProperties()), "testLFTest-input2.txt", 0);
    Tuple f3 = text2.getNext();
    Util.deleteFile(cluster, "testLFTest-input2.txt");
    assertTrue(f3 == null);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:30,代码来源:TestBuiltin.java

示例2: testSFPig

import org.apache.pig.LoadFunc; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testSFPig() throws Exception {
    PigServer mrPigServer = new PigServer(ExecType.MAPREDUCE);
    String inputStr = "amy\tbob\tcharlene\tdavid\terin\tfrank";
    Util.createInputFile(cluster, "testSFPig-input.txt", new String[]
                                                                {inputStr});
    DataByteArray[] input = { new DataByteArray("amy"),
        new DataByteArray("bob"), new DataByteArray("charlene"),
        new DataByteArray("david"), new DataByteArray("erin"),
        new DataByteArray("frank") };
    Tuple f1 = Util.loadTuple(TupleFactory.getInstance().
            newTuple(input.length), input);
    String outputLocation = "testSFPig-output.txt";
    String query = "a = load 'testSFPig-input.txt';" +
    		"store a into '" + outputLocation + "';";
    mrPigServer.setBatchOn();
    Util.registerMultiLineQuery(mrPigServer, query);
    mrPigServer.executeBatch();
    LoadFunc lfunc = new ReadToEndLoader(new PigStorage(), ConfigurationUtil.
        toConfiguration(cluster.getProperties()), outputLocation, 0);
    Tuple f2 = lfunc.getNext();
    Util.deleteFile(cluster, "testSFPig-input.txt");

    Util.deleteFile(cluster, outputLocation);
    assertEquals(f1, f2);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:28,代码来源:TestBuiltin.java

示例3: testSFPig

import org.apache.pig.LoadFunc; //导入方法依赖的package包/类
@Test
public void testSFPig() throws Exception {
    Util.resetStateForExecModeSwitch();
    PigServer mrPigServer = new PigServer(cluster.getExecType(), properties);
    String inputStr = "amy\tbob\tcharlene\tdavid\terin\tfrank";
    Util.createInputFile(cluster, "testSFPig-input.txt", new String[]
                                                                {inputStr});
    DataByteArray[] input = { new DataByteArray("amy"),
        new DataByteArray("bob"), new DataByteArray("charlene"),
        new DataByteArray("david"), new DataByteArray("erin"),
        new DataByteArray("frank") };
    Tuple f1 = Util.loadTuple(TupleFactory.getInstance().
            newTuple(input.length), input);
    String outputLocation = "testSFPig-output.txt";
    String query = "a = load 'testSFPig-input.txt';" +
            "store a into '" + outputLocation + "';";
    mrPigServer.setBatchOn();
    Util.registerMultiLineQuery(mrPigServer, query);
    mrPigServer.executeBatch();
    LoadFunc lfunc = new ReadToEndLoader(new PigStorage(), ConfigurationUtil.
        toConfiguration(cluster.getProperties()), outputLocation, 0);
    Tuple f2 = lfunc.getNext();
    Util.deleteFile(cluster, "testSFPig-input.txt");

    Util.deleteFile(cluster, outputLocation);
    assertEquals(f1, f2);
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:28,代码来源:TestBuiltin.java

示例4: testLFPig

import org.apache.pig.LoadFunc; //导入方法依赖的package包/类
@Test
public void testLFPig() throws Exception {
    Util.createInputFile(cluster, "input.txt", new String[]
        {"this:is:delimited:by:a:colon\n"});
    int arity1 = 6;
    LoadFunc lf = new PigStorage(":");
    LoadFunc p1 = new ReadToEndLoader(lf, ConfigurationUtil.
        toConfiguration(cluster.getProperties()), "input.txt", 0);
    Tuple f1 = p1.getNext();
    assertTrue(f1.size() == arity1);
    Util.deleteFile(cluster, "input.txt");

    int LOOP_COUNT = 100;
    String[] input = new String[LOOP_COUNT * LOOP_COUNT];
    int n = 0;
    for (int i = 0; i < LOOP_COUNT; i++) {
        for (int j = 0; j < LOOP_COUNT; j++) {
            input[n++] = (i + "\t" + i + "\t" + j % 2);
        }
    }
    Util.createInputFile(cluster, "input.txt", input);

    LoadFunc p15 = new ReadToEndLoader(new PigStorage(), ConfigurationUtil.
        toConfiguration(cluster.getProperties()), "input.txt", 0);

    int count = 0;
    while (true) {
        Tuple f15 = p15.getNext();
        if (f15 == null)
            break;
        count++;
        assertEquals(3, f15.size());
    }
    assertEquals(LOOP_COUNT * LOOP_COUNT, count);
    Util.deleteFile(cluster, "input.txt");

    String input2 = ":this:has:a:leading:colon\n";
    int arity2 = 6;
    Util.createInputFile(cluster, "input.txt", new String[] {input2});
    LoadFunc p2 = new ReadToEndLoader(new PigStorage(":"), ConfigurationUtil.
        toConfiguration(cluster.getProperties()), "input.txt", 0);
    Tuple f2 = p2.getNext();
    assertTrue(f2.size() == arity2);
    Util.deleteFile(cluster, "input.txt");

    String input3 = "this:has:a:trailing:colon:\n";
    int arity3 = 6;
    Util.createInputFile(cluster, "input.txt", new String[] {input2});
    LoadFunc p3 = new ReadToEndLoader(new PigStorage(":"), ConfigurationUtil.
        toConfiguration(cluster.getProperties()), "input.txt", 0);
    Tuple f3 = p3.getNext();
    assertTrue(f3.size() == arity3);
    Util.deleteFile(cluster, "input.txt");
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:55,代码来源:TestBuiltin.java

示例5: testLFPig

import org.apache.pig.LoadFunc; //导入方法依赖的package包/类
@Test
public void testLFPig() throws Exception {
    Util.createInputFile(cluster, "input.txt", new String[]
        {"this:is:delimited:by:a:colon\n"});
    int arity1 = 6;
    LoadFunc lf = new PigStorage(":");
    LoadFunc p1 = new ReadToEndLoader(lf, ConfigurationUtil.
        toConfiguration(cluster.getProperties()), "input.txt", 0);
    Tuple f1 = p1.getNext();
    assertTrue(f1.size() == arity1);
    Util.deleteFile(cluster, "input.txt");

    int LOOP_COUNT = 100;
    String[] input = new String[LOOP_COUNT * LOOP_COUNT];
    int n = 0;
    for (int i = 0; i < LOOP_COUNT; i++) {
        for (int j = 0; j < LOOP_COUNT; j++) {
            input[n++] = (i + "\t" + i + "\t" + j % 2);
        }
    }
    Util.createInputFile(cluster, "input.txt", input);

    LoadFunc p15 = new ReadToEndLoader(new PigStorage(), ConfigurationUtil.
        toConfiguration(cluster.getProperties()), "input.txt", 0);

    int count = 0;
    while (true) {
        Tuple f15 = p15.getNext();
        if (f15 == null)
            break;
        count++;
        assertEquals(3, f15.size());
    }
    assertEquals(LOOP_COUNT * LOOP_COUNT, count);
    Util.deleteFile(cluster, "input.txt");

    String input2 = ":this:has:a:leading:colon\n";
    int arity2 = 6;
    Util.createInputFile(cluster, "input.txt", new String[] {input2});
    LoadFunc p2 = new ReadToEndLoader(new PigStorage(":"), ConfigurationUtil.
        toConfiguration(cluster.getProperties()), "input.txt", 0);
    Tuple f2 = p2.getNext();
    assertTrue(f2.size() == arity2);
    Util.deleteFile(cluster, "input.txt");

    String input3 = "this:has:a:trailing:colon:\n";
    int arity3 = 6;
    Util.createInputFile(cluster, "input.txt", new String[] {input3});
    LoadFunc p3 = new ReadToEndLoader(new PigStorage(":"), ConfigurationUtil.
        toConfiguration(cluster.getProperties()), "input.txt", 0);
    Tuple f3 = p3.getNext();
    assertTrue(f3.size() == arity3);
    Util.deleteFile(cluster, "input.txt");
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:55,代码来源:TestBuiltin.java


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