• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DefaultTuple类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.pig.data.DefaultTuple的典型用法代码示例。如果您正苦于以下问题:Java DefaultTuple类的具体用法?Java DefaultTuple怎么用?Java DefaultTuple使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DefaultTuple类属于org.apache.pig.data包,在下文中一共展示了DefaultTuple类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setUpProjFil

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
private void setUpProjFil(boolean withNulls) throws Exception {
    if (withNulls)
        inp = GenRandomData.genRandSmallTupDataBagWithNulls(r, 10, 100);
    else
        inp = GenRandomData.genRandSmallTupDataBag(r, 10, 100);
    t = GenRandomData.genRandSmallBagTuple(r, 10, 100);
    projFil = GenPhyOp.topFilterOpWithProj(1, 50);
    POProject inpPrj = GenPhyOp.exprProject();
    Tuple tmpTpl = new DefaultTuple();
    tmpTpl.append(inp);
    inpPrj.setColumn(0);
    inpPrj.setResultType(DataType.TUPLE);
    inpPrj.setOverloaded(true);
    inpPrj.attachInput(tmpTpl);
    List<PhysicalOperator> inputs = new ArrayList<PhysicalOperator>();
    inputs.add(inpPrj);
    projFil.setInputs(inputs);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:19,代码来源:TestFilter.java


示例2: setUp2

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
private void setUp2() throws PlanException, ExecException{
    lr = GenPhyOp.topLocalRearrangeOPWithPlanPlain(0,0,db.iterator().next());
    List<PhysicalPlan> plans = lr.getPlans();
    POLocalRearrange lrT = GenPhyOp.topLocalRearrangeOPWithPlanPlain(0, 1, db.iterator().next());
    List<PhysicalPlan> plansT = lrT.getPlans();
    plans.add(plansT.get(0));
    lr.setPlans(plans);
    
    POProject proj = GenPhyOp.exprProject();
    proj.setColumn(0);
    proj.setResultType(DataType.TUPLE);
    proj.setOverloaded(true);
    Tuple t = new DefaultTuple();
    t.append(db);
    proj.attachInput(t);
    List<PhysicalOperator> inputs = new ArrayList<PhysicalOperator>();
    inputs.add(proj);
    lr.setInputs(inputs);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:20,代码来源:TestLocalRearrange.java


示例3: testStore

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
@Test
public void testStore() throws Exception {
    inpDB = GenRandomData.genRandSmallTupDataBag(new Random(), 10, 100);
    storeAndCopyLocally(inpDB);

    int size = 0;
    BufferedReader br = new BufferedReader(new FileReader(outputFileName));
    for(String line=br.readLine();line!=null;line=br.readLine()){
        String[] flds = line.split("\t",-1);
        Tuple t = new DefaultTuple();
        t.append(flds[0].compareTo("")!=0 ? flds[0] : null);
        t.append(flds[1].compareTo("")!=0 ? Integer.parseInt(flds[1]) : null);

        System.err.println("Simple data: ");
        System.err.println(line);
        System.err.println("t: ");
        System.err.println(t);
        assertTrue(TestHelper.bagContains(inpDB, t));
        ++size;
    }
    assertEquals(size, inpDB.size());
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:23,代码来源:TestStore.java


示例4: setUp

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    Random r = new Random();
    db = GenRandomData.genRandSmallTupDataBagWithNulls(r, 10, 100);
    projDB = TestHelper.projectBag(db, 0);
    fe = GenPhyOp.topForEachOPWithPlan(0, db.iterator().next());
    POProject proj = GenPhyOp.exprProject();
    proj.setColumn(0);
    proj.setResultType(DataType.TUPLE);
    proj.setOverloaded(true);
    Tuple t = new DefaultTuple();
    t.append(db);
    proj.attachInput(t);
    List<PhysicalOperator> inputs = new ArrayList<PhysicalOperator>();
    inputs.add(proj);
    fe.setInputs(inputs);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:18,代码来源:TestForEach.java


示例5: setUp2

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
private void setUp2() throws PlanException, ExecException{
    lr = GenPhyOp.topLocalRearrangeOPWithPlanPlain(0,0,db.iterator().next());
    List<PhysicalPlan> plans = lr.getPlans();
    POLocalRearrange lrT = GenPhyOp.topLocalRearrangeOPWithPlanPlain(0, 1, db.iterator().next());
    List<PhysicalPlan> plansT = lrT.getPlans();
    plans.add(plansT.get(0));
    lr.setPlans(plans);

    POProject proj = GenPhyOp.exprProject();
    proj.setColumn(0);
    proj.setResultType(DataType.TUPLE);
    proj.setOverloaded(true);
    Tuple t = new DefaultTuple();
    t.append(db);
    proj.attachInput(t);
    List<PhysicalOperator> inputs = new ArrayList<PhysicalOperator>();
    inputs.add(proj);
    lr.setInputs(inputs);
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:20,代码来源:TestLocalRearrange.java


示例6: testStore

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
@Test
public void testStore() throws Exception {
    inpDB = GenRandomData.genRandSmallTupDataBag(new Random(), 10, 100);
    storeAndCopyLocally(inpDB);

    int size = 0;
    BufferedReader br = new BufferedReader(new FileReader(outputFileName));
    for(String line=br.readLine();line!=null;line=br.readLine()){
        String[] flds = line.split("\t",-1);
        Tuple t = new DefaultTuple();
        t.append(flds[0].compareTo("")!=0 ? flds[0] : null);
        t.append(flds[1].compareTo("")!=0 ? Integer.parseInt(flds[1]) : null);

        System.err.println("Simple data: ");
        System.err.println(line);
        System.err.println("t: ");
        System.err.println(t);
        assertTrue(TestHelper.bagContains(inpDB, t));
        ++size;
    }
    assertEquals(size, inpDB.size());
    br.close();
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:24,代码来源:TestStore.java


示例7: setUpProjFil

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
private void setUpProjFil(boolean withNulls) throws Exception{
    Random r = new Random();
    if(withNulls)
        inp = GenRandomData.genRandSmallTupDataBagWithNulls(r, 10, 100);
    else
        inp = GenRandomData.genRandSmallTupDataBag(r, 10, 100);
    t = GenRandomData.genRandSmallBagTuple(r, 10, 100);
    projFil = GenPhyOp.topFilterOpWithProj(1, 50);
    POProject inpPrj = GenPhyOp.exprProject();
    Tuple tmpTpl = new DefaultTuple();
    tmpTpl.append(inp);
    inpPrj.setColumn(0);
    inpPrj.setResultType(DataType.TUPLE);
    inpPrj.setOverloaded(true);
    inpPrj.attachInput(tmpTpl);
    List<PhysicalOperator> inputs = new ArrayList<PhysicalOperator>();
    inputs.add(inpPrj);
    projFil.setInputs(inputs);
}
 
开发者ID:PonIC,项目名称:PonIC,代码行数:20,代码来源:TestFilter.java


示例8: testStore

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
@Test
public void testStore() throws Exception {
    inpDB = GenRandomData.genRandSmallTupDataBag(new Random(), 10, 100);
    storeAndCopyLocally(inpDB);
    
    int size = 0;
    BufferedReader br = new BufferedReader(new FileReader(outputFileName));
    for(String line=br.readLine();line!=null;line=br.readLine()){
        String[] flds = line.split(":",-1);
        Tuple t = new DefaultTuple();
        t.append(flds[0].compareTo("")!=0 ? flds[0] : null);
        t.append(flds[1].compareTo("")!=0 ? Integer.parseInt(flds[1]) : null);
        
        System.err.println("Simple data: ");
        System.err.println(line);
        System.err.println("t: ");
        System.err.println(t);
        assertEquals(true, TestHelper.bagContains(inpDB, t));
        ++size;
    }
    assertEquals(true, size==inpDB.size());
}
 
开发者ID:PonIC,项目名称:PonIC,代码行数:23,代码来源:TestStore.java


示例9: setUp

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    Random r = new Random();
    db = GenRandomData.genRandSmallTupDataBagWithNulls(r, 10, 100);
    projDB = TestHelper.projectBag(db,0);
    fe = GenPhyOp.topForEachOPWithPlan(0,db.iterator().next());
    POProject proj = GenPhyOp.exprProject();
    proj.setColumn(0);
    proj.setResultType(DataType.TUPLE);
    proj.setOverloaded(true);
    Tuple t = new DefaultTuple();
    t.append(db);
    proj.attachInput(t);
    List<PhysicalOperator> inputs = new ArrayList<PhysicalOperator>();
    inputs.add(proj);
    fe.setInputs(inputs);
}
 
开发者ID:PonIC,项目名称:PonIC,代码行数:18,代码来源:TestForEach.java


示例10: createTuple

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
protected Tuple createTuple(Object... entry) {
  Tuple result = new DefaultTuple();
  for (Object o : entry) {
    result.append(o);
  }
  return result;
}
 
开发者ID:lucidworks,项目名称:pig-solr,代码行数:8,代码来源:SolrStoreFuncTest.java


示例11: addToArray

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
/**
 * Called by the default implementation of {@link #readArray} to add a
 * value. Overridden to append to pig bag.
 */
@Override
protected void addToArray(Object array, long pos, Object e) {
    if (e instanceof Tuple) {
        ((DataBag) array).add((Tuple) e);
    } else {
        Tuple t = new DefaultTuple();
        t.append(e);
        ((DataBag) array).add(t);
    }
}
 
开发者ID:linkedin,项目名称:Cubert,代码行数:15,代码来源:PigAvroDatumReader.java


示例12: testFilterCount1

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
@Test
public void testFilterCount1() throws IOException, ParserException {
    Data data = resetData(pigServer);
    data.set("foo", tuple(1,1,3), tuple(1,2,3), tuple(2,1,3), tuple(2,1,3));
    String script = "test   = load 'foo' using mock.Storage() as (col1: int, col2: int, col3: int);" +
            "test2 = group test by col1;" +
            "test3 = foreach test2 {" +
            "        filter_one    = filter test by (col2==1);" +
            "        filter_notone = filter test by (col2!=1);" +
            "        generate group as col1, COUNT(filter_one) as cnt_one, COUNT(filter_notone) as cnt_notone;};";
    pigServer.registerQuery(script);
    Iterator<Tuple> it = pigServer.openIterator("test3");
    Tuple[] expected = new DefaultTuple[2];
    expected[0] = (Tuple) Util.getPigConstant("(1,1L,1L)");
    expected[1] = (Tuple) Util.getPigConstant("(2,2L,0L)");
    Object[] results = new Object[2];
    int i = 0;
    while(it.hasNext()) {
        if(i == 2) {
            fail("Got more tuples than expected!");
        }
        Tuple t = it.next();
        if(t.get(0).equals(1)) {
            // this is the first tuple
            results[0] = t;
        } else {
            results[1] = t;
        }
        i++;
    }
    for (int j = 0; j < expected.length; j++) {
        assertTrue(expected[j].equals(results[j]));
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:35,代码来源:TestRelationToExprProject.java


示例13: castToDBA

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
private Tuple castToDBA(Tuple in) throws ExecException{
    Tuple res = new DefaultTuple();
    for (int i=0;i<in.size();i++) {
        DataByteArray dba = new DataByteArray(in.get(i).toString());
        res.append(dba);
    }
    return res;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:9,代码来源:TestUnion.java


示例14: testGetNextNullInput

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
@Test
public void testGetNextNullInput() throws Exception {
    File f1 = Util.createInputFile("tmp", "a.txt", new String[] {"1\t2\t3", "4\t5\t6"});
    File f2 = Util.createInputFile("tmp", "b.txt", new String[] {"7\t8\t9", "1\t200\t300"});
    File f3 = Util.createInputFile("tmp", "c.txt", new String[] {"1\t20\t30"});
    //FileLocalizer.deleteTempFiles();
    pigServer.registerQuery("a = load '" + f1.getAbsolutePath() + "' ;");
    pigServer.registerQuery("b = load '" + f2.getAbsolutePath() + "';");
    pigServer.registerQuery("c = union a, b;");
    pigServer.registerQuery("d = load '" + f3.getAbsolutePath() + "' ;");
    pigServer.registerQuery("e = cogroup c by $0 inner, d by $0 inner;");
    pigServer.explain("e", System.err);
    // output should be
    // (1,{(1,2,3),(1,200,300)},{(1,20,30)})
    Tuple expectedResult = new DefaultTuple();
    expectedResult.append(new DataByteArray("1"));
    Tuple[] secondFieldContents = new DefaultTuple[2];
    secondFieldContents[0] = Util.createTuple(Util.toDataByteArrays(new String[] {"1", "2", "3"}));
    secondFieldContents[1] = Util.createTuple(Util.toDataByteArrays(new String[] {"1", "200", "300"}));
    DataBag secondField = Util.createBag(secondFieldContents);
    expectedResult.append(secondField);
    DataBag thirdField = Util.createBag(new Tuple[]{Util.createTuple(Util.toDataByteArrays(new String[]{"1", "20", "30"}))});
    expectedResult.append(thirdField);
    Iterator<Tuple> it = pigServer.openIterator("e");
    assertEquals(expectedResult, it.next());
    assertFalse(it.hasNext());
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:28,代码来源:TestUnion.java


示例15: testSingleTupleBagAcess

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
@Test
public void testSingleTupleBagAcess() throws Exception {
    Tuple inputTuple = new DefaultTuple();
    inputTuple.append("a");
    inputTuple.append("b");

    SingleTupleBag bg = new SingleTupleBag(inputTuple);
    Iterator<Tuple> it = bg.iterator();
    assertEquals(inputTuple, it.next());
    assertFalse(it.hasNext());
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:12,代码来源:TestDataBagAccess.java


示例16: projectBag

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
public static DataBag projectBag(DataBag db2, int i) throws ExecException {
    DataBag ret = DefaultBagFactory.getInstance().newDefaultBag();
    for (Tuple tuple : db2) {
        Object o = tuple.get(i);
        Tuple t1 = new DefaultTuple();
        t1.append(o);
        ret.add(t1);
    }
    return ret;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:11,代码来源:TestHelper.java


示例17: getNext

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
@Override
public Tuple getNext() throws IOException {
    String line = is.readLine();
    if(line == null)
        return null;
    String[] members = line.split("\t");
    DefaultTuple tuple = new DefaultTuple();
    for(String member : members)
        tuple.append(member);
    return tuple;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:12,代码来源:TestMapSideCogroup.java


示例18: setUp1

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
private void setUp1() throws PlanException, ExecException{
    lr = GenPhyOp.topLocalRearrangeOPWithPlanPlain(0,0,db.iterator().next());
    POProject proj = GenPhyOp.exprProject();
    proj.setColumn(0);
    proj.setResultType(DataType.TUPLE);
    proj.setOverloaded(true);
    Tuple t = new DefaultTuple();
    t.append(db);
    proj.attachInput(t);
    List<PhysicalOperator> inputs = new ArrayList<PhysicalOperator>();
    inputs.add(proj);
    lr.setInputs(inputs);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:14,代码来源:TestLocalRearrange.java


示例19: testGetNextTuple1

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
@Test
public void testGetNextTuple1() throws ExecException, PlanException {
    setUp1();
    int size=0;
    for(Result res=lr.getNextTuple();res.returnStatus!=POStatus.STATUS_EOP;res=lr.getNextTuple()){
        Tuple t = (Tuple)res.result;
        String key = (String)t.get(1);
        Tuple val = (Tuple)t.get(2);
        // The input data has 2 columns of which the first
        // is the key
        // With the optimized LocalRearrange, the part
        // of the "value" present in the "key" is 
        // excluded from the "value". So to reconstruct
        // the true "value", create a tuple with "key" in
        // first position and the "value" (val) we currently
        // have in the second position
        assertEquals(1, val.size());
        
        Tuple actualVal = new DefaultTuple();
        actualVal.append(key);
        actualVal.append(val.get(0));
        //Check if the index is same as input index
        assertEquals((byte)0, (byte)(Byte)t.get(0));
        
        //Check if the input bag contains the value tuple
        assertTrue(TestHelper.bagContains(db, actualVal));
        
        //Check if the input key and the output key are same
        String inpKey = (String)actualVal.get(0);
        assertEquals(0, inpKey.compareTo((String)t.get(1)));
        ++size;
    }
    
    //check if all the tuples in the input are generated
    assertEquals(db.size(), size);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:37,代码来源:TestLocalRearrange.java


示例20: testStoreComplexData

import org.apache.pig.data.DefaultTuple; //导入依赖的package包/类
@Test
public void testStoreComplexData() throws Exception {
    inpDB = GenRandomData.genRandFullTupTextDataBag(new Random(), 10, 100);
    storeAndCopyLocally(inpDB);
    PigStorage ps = new PigStorage("\t");
    int size = 0;
    BufferedReader br = new BufferedReader(new FileReader(outputFileName));
    for(String line=br.readLine();line!=null;line=br.readLine()){
        String[] flds = line.split("\t",-1);
        Tuple t = new DefaultTuple();

        ResourceFieldSchema bagfs = GenRandomData.getSmallTupDataBagFieldSchema();
        ResourceFieldSchema tuplefs = GenRandomData.getSmallTupleFieldSchema();

        t.append(flds[0].compareTo("")!=0 ? ps.getLoadCaster().bytesToBag(flds[0].getBytes(), bagfs) : null);
        t.append(flds[1].compareTo("")!=0 ? new DataByteArray(flds[1].getBytes()) : null);
        t.append(flds[2].compareTo("")!=0 ? ps.getLoadCaster().bytesToCharArray(flds[2].getBytes()) : null);
        t.append(flds[3].compareTo("")!=0 ? ps.getLoadCaster().bytesToDouble(flds[3].getBytes()) : null);
        t.append(flds[4].compareTo("")!=0 ? ps.getLoadCaster().bytesToFloat(flds[4].getBytes()) : null);
        t.append(flds[5].compareTo("")!=0 ? ps.getLoadCaster().bytesToInteger(flds[5].getBytes()) : null);
        t.append(flds[6].compareTo("")!=0 ? ps.getLoadCaster().bytesToLong(flds[6].getBytes()) : null);
        t.append(flds[7].compareTo("")!=0 ? ps.getLoadCaster().bytesToMap(flds[7].getBytes()) : null);
        t.append(flds[8].compareTo("")!=0 ? ps.getLoadCaster().bytesToTuple(flds[8].getBytes(), tuplefs) : null);
        t.append(flds[9].compareTo("")!=0 ? ps.getLoadCaster().bytesToBoolean(flds[9].getBytes()) : null);
        t.append(flds[10].compareTo("")!=0 ? ps.getLoadCaster().bytesToDateTime(flds[10].getBytes()) : null);
        assertEquals(true, TestHelper.bagContains(inpDB, t));
        ++size;
    }
    assertEquals(true, size==inpDB.size());
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:31,代码来源:TestStore.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ActException类代码示例发布时间:2022-05-23
下一篇:
Java LogInfo类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap