Package org.apache.pig.data

Examples of org.apache.pig.data.DataByteArray


    // Verify union table
    HashMap<Integer, ArrayList<ArrayList<Object>>> resultTable
      = new HashMap<Integer, ArrayList<ArrayList<Object>>>();
   
    ArrayList<ArrayList<Object>> rows = new ArrayList<ArrayList<Object>>();
    addResultRow(rows, 0,  -1,   3.25f1000L50e+2"zebra"new DataByteArray("zebra"), m1);
    addResultRow(rows, 05,    -3.25f1001L51e+2"Zebra"new DataByteArray("Zebra"),  m1)
    addResultRow(rows, 010000.0f1002L52e+2"hadoop"new DataByteArray("hadoop"),m1);
    addResultRow(rows, 01001100.0f1003L50e+2"Apple"new DataByteArray("Apple"),  m1);
    addResultRow(rows, 01001101.0f1001L50e+2"apple"new DataByteArray("apple"),  m1);
    addResultRow(rows, 01001101.0f1001L50e+2"apple"new DataByteArray("apple"),  m1);
    addResultRow(rows, 0100150.0f1000L50e+2"Pig",    new DataByteArray("Pig"),  m1);
    addResultRow(rows, 0100152.0f1001L50e+2"pig",    new DataByteArray("pig"),  m1);
    addResultRow(rows, 0100228.0f1000L50e+2"Hadoop"new DataByteArray("Hadoop"),m1);
    resultTable.put(0, rows);
   
    rows = new ArrayList<ArrayList<Object>>();
    addResultRow(rows, 1,  -1,    -99.0f1002L51e+2"orange"new DataByteArray("orange"),m2);
    addResultRow(rows, 115,   56.0f1004L50e+2"green"new DataByteArray("green"), m2);
    addResultRow(rows, 11001, 100.0f, 1003L55e+2"white"new DataByteArray("white"), m2);
    addResultRow(rows, 11001, 102.0f, 1001L52e+2"purple", new DataByteArray("purple"),m2);
    addResultRow(rows, 11001, 50.0f1008L52e+2"gray",   new DataByteArray("gray"),  m2);
    addResultRow(rows, 11001, 53.0f1001L52e+2"brown"new DataByteArray("brown"), m2);
    addResultRow(rows, 12000, 33.0f1006L52e+2"beige"new DataByteArray("beige"), m2);
    resultTable.put(1, rows);
   
   
    // Verify union table
    Iterator<Tuple> it = pigServer.openIterator("records1");
View Full Code Here


    // Verify union table
    HashMap<Integer, ArrayList<ArrayList<Object>>> resultTable =
      new HashMap<Integer, ArrayList<ArrayList<Object>>>();
   
    ArrayList<ArrayList<Object>> rows = new ArrayList<ArrayList<Object>>();
    addResultRow(rows, 0,  -3.25f5,    1001L51e+2"Zebra"new DataByteArray("Zebra"),  m1);
    addResultRow(rows, 00.0f10001002L52e+2"hadoop"new DataByteArray("hadoop"),m1);
    addResultRow(rows, 03.25f,  -1,    1000L50e+2"zebra"new DataByteArray("zebra"),  m1)
    addResultRow(rows, 028.0f10021000L50e+2"Hadoop"new DataByteArray("Hadoop"),m1);
    addResultRow(rows, 050.0f10011000L50e+2"Pig",    new DataByteArray("Pig"),  m1)
    addResultRow(rows, 052.0f10011001L50e+2"pig",    new DataByteArray("pig"),  m1);
    addResultRow(rows, 0100.0f10011003L50e+2"Apple"new DataByteArray("Apple"),  m1);
    addResultRow(rows, 0101.0f10011001L50e+2"apple"new DataByteArray("apple"),  m1);
    addResultRow(rows, 0101.0f10011001L50e+2"apple"new DataByteArray("apple"),  m1);
    resultTable.put(0, rows);
   
    rows = new ArrayList<ArrayList<Object>>();
    addResultRow(rows, 1,  -99.0f,  -1,    1002L51e+2"orange"new DataByteArray("orange"),m2);
    addResultRow(rows, 133.0f2000, 1006L52e+2"beige"new DataByteArray("beige"), m2);
    addResultRow(rows, 150.0f1001, 1008L52e+2"gray",   new DataByteArray("gray"),  m2);
    addResultRow(rows, 153.0f1001, 1001L52e+2"brown"new DataByteArray("brown"), m2);
    addResultRow(rows, 156.0f15,   1004L50e+2"green"new DataByteArray("green"), m2);
    addResultRow(rows, 1100.0f, 1001, 1003L55e+2"white"new DataByteArray("white"), m2);
    addResultRow(rows, 1102.0f, 1001, 1001L52e+2"purple", new DataByteArray("purple"),m2);
    resultTable.put(1, rows);
   
    // Verify union table
    Iterator<Tuple> it = pigServer.openIterator("records1");
    int numbRows = verifyTable(resultTable, 1, 0, it);
View Full Code Here

   
    // Verify union table
    HashMap<Integer, ArrayList<ArrayList<Object>>> resultTable = new HashMap<Integer, ArrayList<ArrayList<Object>>>();
   
    ArrayList<ArrayList<Object>> rows = new ArrayList<ArrayList<Object>>();
    addResultRow(rows, 01000L,  -1,   3.25f50e+2"zebra"new DataByteArray("zebra"), m1);
    addResultRow(rows, 01000L1001, 50.0f50e+2"Pig",    new DataByteArray("Pig"), m1);
    addResultRow(rows, 01000L1002, 28.0f50e+2"Hadoop", new DataByteArray("Hadoop"),m1);
    addResultRow(rows, 01001L5,    -3.25f51e+2"Zebra"new DataByteArray("Zebra"),  m1);
    addResultRow(rows, 01001L1001101.0f50e+2"apple"new DataByteArray("apple"),  m1);
    addResultRow(rows, 01001L1001101.0f50e+2"apple"new DataByteArray("apple"),  m1);
    addResultRow(rows, 01001L100152.0f50e+2"pig",    new DataByteArray("pig"),  m1);
    addResultRow(rows, 01002L10000.0f52e+2"hadoop"new DataByteArray("hadoop"),m1);
    addResultRow(rows, 01003L1001100.0f50e+2"Apple"new DataByteArray("Apple"),  m1);
    resultTable.put(0, rows);
   
    rows = new ArrayList<ArrayList<Object>>();
    addResultRow(rows, 11001L1001102.0f52e+2"purple"new DataByteArray("purple"),m2);
    addResultRow(rows, 11001L1001, 53.0f52e+2"brown"new DataByteArray("brown"), m2);
    addResultRow(rows, 11002L,  -1,   -99.0f, 51e+2"orange", new DataByteArray("orange"),m2);
    addResultRow(rows, 11003L1001, 100.0f, 55e+2"white"new DataByteArray("white"), m2);
    addResultRow(rows, 11004L15,   56.0f50e+2"green"new DataByteArray("green"), m2);
    addResultRow(rows, 11006L2000, 33.0f52e+2"beige"new DataByteArray("beige"), m2);
    addResultRow(rows, 11008L1001, 50.0f52e+2"gray",   new DataByteArray("gray"),  m2);
    resultTable.put(1, rows);
   
    // Verify union table
    Iterator<Tuple> it = pigServer.openIterator("records1");
    int numbRows = verifyTable(resultTable, 1, 0, it);
View Full Code Here

   
    // Verify union table
    HashMap<Integer, ArrayList<ArrayList<Object>>> resultTable = new HashMap<Integer, ArrayList<ArrayList<Object>>>();
   
    ArrayList<ArrayList<Object>> rows = new ArrayList<ArrayList<Object>>();
    addResultRow(rows, 0,50e+2,  -1,   3.25f1000L"zebra"new DataByteArray("zebra"), m1);
    addResultRow(rows, 0,50e+21001100.0f1003L"Apple"new DataByteArray("Apple"),  m1);
    addResultRow(rows, 0,50e+21001101.0f1001L"apple"new DataByteArray("apple"),  m1);
    addResultRow(rows, 0,50e+21001101.0f1001L"apple"new DataByteArray("apple"),  m1);
    addResultRow(rows, 0,50e+2100150.0f1000L"Pig",    new DataByteArray("Pig"),  m1);
    addResultRow(rows, 0,50e+2100152.0f1001L"pig",    new DataByteArray("pig"),  m1);
    addResultRow(rows, 0,50e+2100228.0f1000L"Hadoop"new DataByteArray("Hadoop"),m1);
    addResultRow(rows, 0,51e+25,    -3.25f1001L"Zebra"new DataByteArray("Zebra"),  m1);
    addResultRow(rows, 0,52e+210000.0f1002L"hadoop"new DataByteArray("hadoop"),m1);
    resultTable.put(0, rows);
   
    rows = new ArrayList<ArrayList<Object>>();
    addResultRow(rows, 1,50e+215,    56.0f1004L"green"new DataByteArray("green"),  m2);
    addResultRow(rows, 1,51e+2,  -1,   -99.0f, 1002L"orange", new DataByteArray("orange"),m2);
    addResultRow(rows, 1,52e+21001, 102.0f, 1001L"purple", new DataByteArray("purple"),m2);
    addResultRow(rows, 1,52e+21001, 50.0f1008L"gray",   new DataByteArray("gray"),  m2);
    addResultRow(rows, 1,52e+21001, 53.0f1001L"brown"new DataByteArray("brown"), m2);
    addResultRow(rows, 1,52e+22000, 33.0f1006L"beige"new DataByteArray("beige"), m2);
    addResultRow(rows, 1,55e+21001, 100.0f, 1003L"white"new DataByteArray("white"), m2);
    resultTable.put(1, rows);
   
    // Verify union table
    Iterator<Tuple> it = pigServer.openIterator("records1");
    int numbRows = verifyTable(resultTable, 1, 0, it);
View Full Code Here

   
    // Verify union table
    HashMap<Integer, ArrayList<ArrayList<Object>>> resultTable = new HashMap<Integer, ArrayList<ArrayList<Object>>>();
   
    ArrayList<ArrayList<Object>> rows = new ArrayList<ArrayList<Object>>();
    addResultRow(rows, 0,"Apple"1001100.0f1003L50e+2new DataByteArray("Apple"),  m1);
    addResultRow(rows, 0,"Hadoop"100228.0f1000L50e+2new DataByteArray("Hadoop"),m1);
    addResultRow(rows, 0,"Pig",    100150.0f1000L50e+2new DataByteArray("Pig"),  m1);
    addResultRow(rows, 0,"Zebra"5,    -3.25f1001L51e+2new DataByteArray("Zebra"),  m1);
    addResultRow(rows, 0,"apple"1001101.0f1001L50e+2new DataByteArray("apple"),  m1);
    addResultRow(rows, 0,"apple"1001101.0f1001L50e+2new DataByteArray("apple"),  m1);
    addResultRow(rows, 0,"hadoop"10000.0f1002L52e+2new DataByteArray("hadoop"),m1);
    addResultRow(rows, 0,"pig",    100152.0f1001L50e+2new DataByteArray("pig"),  m1);
    addResultRow(rows, 0,"zebra",  -1,    3.25f1000L50e+2new DataByteArray("zebra"),  m1);
    resultTable.put(0, rows);
   
    rows = new ArrayList<ArrayList<Object>>();
    addResultRow(rows, 1,"beige"2000, 33.0f1006L52e+2new DataByteArray("beige"), m2);
    addResultRow(rows, 1,"brown"1001, 53.0f1001L52e+2new DataByteArray("brown"), m2);
    addResultRow(rows, 1,"gray",   1001, 50.0f1008L52e+2new DataByteArray("gray"),  m2);
    addResultRow(rows, 1,"green"15,   56.0f1004L50e+2new DataByteArray("green"), m2);
    addResultRow(rows, 1,"orange", -1,   -99.0f, 1002L51e+2new DataByteArray("orange"),m2);
    addResultRow(rows, 1,"purple", 1001, 102.0f, 1001L52e+2new DataByteArray("purple"),m2);
    addResultRow(rows, 1,"white"1001, 100.0f, 1003L55e+2new DataByteArray("white"), m2);
    resultTable.put(1, rows);
   
    // Verify union table
    Iterator<Tuple> it = pigServer.openIterator("records1");
    int numbRows = verifyTable(resultTable, 1, 0, it);
View Full Code Here

   
    // Verify union table
    HashMap<Integer, ArrayList<ArrayList<Object>>> resultTable = new HashMap<Integer, ArrayList<ArrayList<Object>>>();
   
    ArrayList<ArrayList<Object>> rows = new ArrayList<ArrayList<Object>>();
    addResultRow(rows, 0,new DataByteArray("Apple")1001100.0f1003L50e+2"Apple",  m1);
    addResultRow(rows, 0,new DataByteArray("Hadoop"),100228.0f1000L50e+2"Hadoop",  m1);
    addResultRow(rows, 0,new DataByteArray("Pig")100150.0f1000L50e+2"Pig",    m1);
    addResultRow(rows, 0,new DataByteArray("Zebra")5,    -3.25f1001L51e+2"Zebra",  m1)
    addResultRow(rows, 0,new DataByteArray("apple")1001101.0f1001L50e+2"apple",  m1);
    addResultRow(rows, 0,new DataByteArray("apple")1001101.0f1001L50e+2"apple",  m1);
    addResultRow(rows, 0,new DataByteArray("hadoop"),10000.0f1002L52e+2"hadoop",  m1);
    addResultRow(rows, 0,new DataByteArray("pig")100152.0f1001L50e+2"pig",    m1);
    addResultRow(rows, 0,new DataByteArray("zebra"),  -1,    3.25f1000L50e+2"zebra",  m1);
    resultTable.put(0, rows);
   
    rows = new ArrayList<ArrayList<Object>>();
    addResultRow(rows, 1,new DataByteArray("beige"), 2000, 33.0f1006L52e+2"beige",  m2);
    addResultRow(rows, 1,new DataByteArray("brown"), 1001, 53.0f1001L52e+2"brown",  m2);
   
    addResultRow(rows, 1,new DataByteArray("gray")1001, 50.0f1008L52e+2"gray",   m2);
    addResultRow(rows, 1,new DataByteArray("green"), 15,   56.0f1004L50e+2"green",  m2);
    addResultRow(rows, 1,new DataByteArray("orange"),-1,   -99.0f, 1002L51e+2"orange", m2);
    addResultRow(rows, 1,new DataByteArray("purple"),1001, 102.0f, 1001L52e+2"purple", m2);
    addResultRow(rows, 1,new DataByteArray("white"), 1001, 100.0f, 1003L55e+2"white",  m2);
    resultTable.put(1, rows);
   
    // Verify union table
    Iterator<Tuple> it = pigServer.openIterator("records1");
    int numbRows = verifyTable(resultTable, 1, 0, it);
View Full Code Here

            key = makeKey(total);
          }
          TypesUtils.resetTuple(tuple);
          for (int k = 0; k < tuple.size(); ++k) {
            try {
              tuple.set(k, new DataByteArray(makeString("col-" + colNames[k], rows * 10).getBytes()));
            } catch (ExecException e) {
              e.printStackTrace();
            }
          }
          inserter.insert(key, tuple);
View Full Code Here

            tuple.set(0, 100);
            tuple.set(1, 100.1f);
            tuple.set(2, 100L);
            tuple.set(3, 50e+2);
            tuple.set(4, "something");
            tuple.set(5, new DataByteArray("something"));
 
          }
          // the middle + 1 row of the table, the smallest row
          else if (i == 0 && b == (numsBatch / 2)) {
            tuple.set(0, -100);
            tuple.set(1, -100.1f);
            tuple.set(2, -100L);
            tuple.set(3, -50e+2);
            tuple.set(4, "so");
            tuple.set(5, new DataByteArray("so"));
 
          }
 
          else {
            Float f = 1.1f;
            long l = 11;
            double d = 1.1;
            tuple.set(0, b);
            tuple.set(1, f);
            tuple.set(2, l);
            tuple.set(3, d);
            tuple.set(4, "some");
            tuple.set(5, new DataByteArray("some"));
          }
 
          // insert record
          tupRecord1.set(0, "" + b);
          tupRecord1.set(1, "" + b);
View Full Code Here

    tuple.set(0, true); // bool
    tuple.set(1, 1); // int
    tuple.set(2, 1001L); // long
    tuple.set(3, 1.1); // float
    tuple.set(4, "hello world 1"); // string
    tuple.set(5, new DataByteArray("hello byte 1")); // byte

    // r1:record(f1:int, f2:long
    tupRecord1.set(0, 1);
    tupRecord1.set(1, 1001L);
    tuple.set(6, tupRecord1);

    // r2:record(r3:record(f3:float, f4))
    tupRecord2.set(0, tupRecord3);
    tupRecord3.set(0, 1.3);
    tupRecord3.set(1, new DataByteArray("r3 row 1 byte array "));
    tuple.set(7, tupRecord2);

    // m1:map(string)
    Map<String, String> m1 = new HashMap<String, String>();
    m1.put("a", "A");
    m1.put("b", "B");
    m1.put("c", "C");
    tuple.set(8, m1);

    // m2:map(map(int))
    HashMap<String, Map> m2 = new HashMap<String, Map>();
    Map<String, Integer> m3 = new HashMap<String, Integer>();
    m3.put("m311", 311);
    m3.put("m321", 321);
    m3.put("m331", 331);
    Map<String, Integer> m4 = new HashMap<String, Integer>();
    m4.put("m411", 411);
    m4.put("m421", 421);
    m4.put("m431", 431);
    m2.put("x", m3);
    m2.put("y", m4);
    tuple.set(9, m2);

    // c:collection(f13:double, f14:float, f15:bytes)
    DataBag bagColl = TypesUtils.createBag();
    Schema schColl = schema.getColumn(10).getSchema().getColumn(0).getSchema();
    Tuple tupColl1 = TypesUtils.createTuple(schColl);
    Tuple tupColl2 = TypesUtils.createTuple(schColl);
    byte[] abs1 = new byte[3];
    byte[] abs2 = new byte[4];
    tupColl1.set(0, 3.1415926);
    tupColl1.set(1, 1.6);
    abs1[0] = 11;
    abs1[1] = 12;
    abs1[2] = 13;
    tupColl1.set(2, new DataByteArray(abs1));
    bagColl.add(tupColl1);
    tupColl2.set(0, 123.456789);
    tupColl2.set(1, 100);
    abs2[0] = 21;
    abs2[1] = 22;
    abs2[2] = 23;
    abs2[3] = 24;
    tupColl2.set(2, new DataByteArray(abs2));
    bagColl.add(tupColl2);
    tuple.set(10, bagColl);

    int row = 0;
    inserter.insert(new BytesWritable(String.format("k%d%d", part + 1, row + 1)
        .getBytes()), tuple);

    // row 2
    row++;
    TypesUtils.resetTuple(tuple);
    TypesUtils.resetTuple(tupRecord1);
    TypesUtils.resetTuple(tupRecord2);
    TypesUtils.resetTuple(tupRecord3);
    m1.clear();
    m2.clear();
    m3.clear();
    m4.clear();
    tuple.set(0, false);
    tuple.set(1, 2); // int
    tuple.set(2, 1002L); // long
    tuple.set(3, 3.1); // float
    tuple.set(4, "hello world 2"); // string
    tuple.set(5, new DataByteArray("hello byte 2")); // byte

    // r1:record(f1:int, f2:long
    tupRecord1.set(0, 2);
    tupRecord1.set(1, 1002L);
    tuple.set(6, tupRecord1);

    // r2:record(r3:record(f3:float, f4))
    tupRecord2.set(0, tupRecord3);
    tupRecord3.set(0, 2.3);
    tupRecord3.set(1, new DataByteArray("r3 row2  byte array"));
    tuple.set(7, tupRecord2);

    // m1:map(string)
    m1.put("a2", "A2");
    m1.put("b2", "B2");
    m1.put("c2", "C2");
    tuple.set(8, m1);

    // m2:map(map(int))
    m3.put("m321", 321);
    m3.put("m322", 322);
    m3.put("m323", 323);
    m2.put("z", m3);
    tuple.set(9, m2);

    // c:collection(f13:double, f14:float, f15:bytes)
    bagColl.clear();
    TypesUtils.resetTuple(tupColl1);
    TypesUtils.resetTuple(tupColl2);
    tupColl1.set(0, 7654.321);
    tupColl1.set(1, 0.0001);
    abs1[0] = 31;
    abs1[1] = 32;
    abs1[2] = 33;
    tupColl1.set(2, new DataByteArray(abs1));
    bagColl.add(tupColl1);
    tupColl2.set(0, 0.123456789);
    tupColl2.set(1, 0.3333);
    abs2[0] = 41;
    abs2[1] = 42;
    abs2[2] = 43;
    abs2[3] = 44;
    tupColl2.set(2, new DataByteArray(abs2));
    bagColl.add(tupColl2);
    tuple.set(10, bagColl);

    inserter.insert(new BytesWritable(String.format("k%d%d", part + 1, row + 1)
        .getBytes()), tuple);
View Full Code Here

        double sum = 0;
        boolean sawNonNull = false;
        for (Iterator<Tuple> it = values.iterator(); it.hasNext();) {
            Tuple t = it.next();
            try{
                DataByteArray dba = (DataByteArray)t.get(0);
                Double d = dba != null ? Double.valueOf(dba.toString()) : null;
                if (d == null) continue;
                sawNonNull = true;
                sum += d;
            }catch(RuntimeException exp) {
                int errCode = 2103;
View Full Code Here

TOP

Related Classes of org.apache.pig.data.DataByteArray

Copyright © 2018 www.massapicom. 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.