Package org.apache.pig.data

Examples of org.apache.pig.data.DataByteArray


            Tuple t = mTupleFactory.newTuple(2);
            try {
                // input is a bag with one tuple containing
                // the column we are trying to avg
                DataBag bg = (DataBag) input.get(0);
                DataByteArray dba = null;
                if(bg.iterator().hasNext()) {
                    Tuple tp = bg.iterator().next();
                    dba = (DataByteArray)tp.get(0);
                }
                t.set(0, dba != null ? Double.valueOf(dba.toString()) : null);
                if (dba == null)
                    t.set(1, 0L);
                else
                    t.set(1, 1L);
                return t;
View Full Code Here


    m1 = new HashMap<String, String>();
    m1.put("a","m1-a");
    m1.put("b","m1-b");
   
    table1 = new Object[][]{
      {5,    -3.25f1001L51e+2"Zebra"new DataByteArray("Zebra"),    m1},
      {-13.25f1000L50e+2"zebra"new DataByteArray("zebra"),    m1},
      {1001100.0f1003L50e+2"Apple"new DataByteArray("Apple"),    m1},
      {1001101.0f1001L50e+2"apple"new DataByteArray("apple"),    m1},
      {100150.0f1000L50e+2"Pig",    new DataByteArray("Pig"),    m1},
      {100152.0f1001L50e+2"pig",    new DataByteArray("pig"),    m1},
      {100228.0f1000L50e+2"Hadoop"new DataByteArray("Hadoop"),  m1},
      {10000.0f1002L52e+2"hadoop"new DataByteArray("hadoop"),  m1} };
   
    // Create table1
    createTable(pathTable1, TABLE1_SCHEMA, TABLE1_STORAGE, table1);
   
    // Create table2 data
    m2 = new HashMap<String, String>();
    m2.put("a","m2-a");
    m2.put("b","m2-b");
   
    table2 = new Object[][] {
      {1556.0f1004L50e+2"green"new DataByteArray("green"),    m2},
      {-1,  -99.0f1002L51e+2"orange"new DataByteArray("orange"),  m2},
      {1001100.0f1003L55e+2"white"new DataByteArray("white"),    m2},
      {1001102.0f1001L52e+2"purple"new DataByteArray("purple"),  m2},
      {100150.0f1008L52e+2"gray",    new DataByteArray("gray"),    m2},
      {100153.0f1001L52e+2"brown"new DataByteArray("brown"),    m2},
      {200033.0f1006L52e+2"beige"new DataByteArray("beige"),    m2} };
   
    // Create table2
    createTable(pathTable2, TABLE2_SCHEMA, TABLE2_STORAGE, table2);
   
    // Create table3 data
    table3 = new Object[][] {
      {3.25f,    51e+21001L"string1"new DataByteArray("green")100}, };
   
    // Create table3
    createTable(pathTable3, TABLE3_SCHEMA, TABLE3_STORAGE, table3);
   
    // Create table4 data
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, -11,  -99.0f1002L51e+2"orange"new DataByteArray("orange"),m2);
    addResultRow(rows, 15156.0f1004L50e+2"green"new DataByteArray("green"),  m2);
    addResultRow(rows, 10011100.0f1003L55e+2"white"new DataByteArray("white"),  m2);
    addResultRow(rows, 10011102.0f1001L52e+2"purple"new DataByteArray("purple"),m2);
   
    addResultRow(rows, 1001150.0f1008L52e+2"gray",    new DataByteArray("gray"),  m2);
    addResultRow(rows, 1001153.0f1001L52e+2"brown"new DataByteArray("brown"),  m2);
    addResultRow(rows, 2000133.0f1006L52e+2"beige"new DataByteArray("beige"),  m2);
    resultTable.put(1, rows);
   
    // Verify union table
    Iterator<Tuple> it = pigServer.openIterator("records1");
    int numbRows = verifyTable(resultTable, 0, 1, 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, "Apple"01001100.0f1003L50e+2new DataByteArray("Apple"),  m1,  null,  null);
    addResultRow(rows, "Hadoop"0100228.0f1000L50e+2new DataByteArray("Hadoop"),m1,  null,  null);
    addResultRow(rows, "Pig"0100150.0f1000L50e+2new DataByteArray("Pig"),  m1,  null,  null);
    addResultRow(rows, "Zebra"05,    -3.25f1001L51e+2new DataByteArray("Zebra"),  m1,  null,  null);
   
    addResultRow(rows, "apple"01001101.0f1001L50e+2new DataByteArray("apple"),  m1,  null,  null);
    addResultRow(rows, "hadoop"010000.0f1002L52e+2new DataByteArray("hadoop"),m1,  null,  null);
    addResultRow(rows, "pig"0100152.0f1001L50e+2new DataByteArray("pig"),  m1,  null,  null);
    addResultRow(rows, "zebra"0,  -1,    3.25f1000L50e+2new DataByteArray("zebra"),  m1,  null,  null);
    resultTable.put(0, rows);
   
    // Verify union table
    Iterator<Tuple> it = pigServer.openIterator("records1");
    int numbRows = verifyTable(resultTable, 0, 1, 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, "Apple"01001, 100.0f, 1003L50e+2new DataByteArray("Apple"), m1, null, null);
    addResultRow(rows, "Hadoop", 01002, 28.0f1000L50e+2new DataByteArray("Hadoop"),m1, null, null);
    addResultRow(rows, "Pig"01001, 50.0f1000L50e+2new DataByteArray("Pig"), m1, null, null);
    addResultRow(rows, "Zebra"05,    -3.25f, 1001L51e+2new DataByteArray("Zebra"), m1, null, null);
   
    addResultRow(rows, "apple"01001, 101.0f, 1001L50e+2new DataByteArray("apple"), m1, null, null);
    addResultRow(rows, "hadoop", 01000, 0.0f, 1002L52e+2new DataByteArray("hadoop"),m1, null, null);
    addResultRow(rows, "pig"01001, 52.0f1001L50e+2new DataByteArray("pig"), m1, null, null);
    addResultRow(rows, "zebra"0,  -1,   3.25f1000L50e+2new DataByteArray("zebra"), m1, null, null);
    resultTable.put(0, rows);
   
    rows = new ArrayList<ArrayList<Object>>();
    addResultRow(rows, "a 1"2,  null,  null,  null,  null,  null,  null,  "Reno",    "Nevada");
    addResultRow(rows, "a 2"2,  null,  null,  null,  null,  null,  null,  "Dallas""Texas");
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, "beige"1200033.0f1006L52e+2new DataByteArray("beige"),  m2, null, null);
    addResultRow(rows, "brown"1100153.0f1001L52e+2new DataByteArray("brown"),  m2, null, null);
    addResultRow(rows, "gray"1100150.0f1008L52e+2new DataByteArray("gray"),  m2, null, null);
    addResultRow(rows, "green"115,    56.0f1004L50e+2new DataByteArray("green"),  m2, null, null);
   
    addResultRow(rows, "orange"1,  -1,    -99.0f1002L51e+2new DataByteArray("orange"),m2, null, null);
    addResultRow(rows, "purple"11001102.0f1001L52e+2new DataByteArray("purple"),m2, null, null);
    addResultRow(rows, "white"11001100.0f1003L55e+2new DataByteArray("white"),  m2, null, null);
    resultTable.put(1, rows);
   
    // Verify union table
    Iterator<Tuple> it = pigServer.openIterator("records1");
    int numbRows = verifyTable(resultTable, 0, 1, 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, "Apple"01001, 100.0f, 1003L50e+2new DataByteArray("Apple"), m1, null, null);
    addResultRow(rows, "Pig"01001, 50.0f1000L50e+2new DataByteArray("Pig"), m1, null, null);
    addResultRow(rows, "apple"01001101.0f1001L50e+2new DataByteArray("apple"),  m1,  null,  null);
    addResultRow(rows, "pig"0100152.0f1001L50e+2new DataByteArray("pig"),  m1,  null,  null);
    resultTable.put(0, rows);
   
    rows = new ArrayList<ArrayList<Object>>();
    addResultRow(rows, "a 1"1,  null,  null,  null,  null,  null,  null,  "Reno",    "Nevada");
    addResultRow(rows, "a 2"1,  null,  null,  null,  null,  null,  null,  "Dallas""Texas");
View Full Code Here

    private void readField(byte[] buf, int start, int end) {
        if (start == end) {
            // NULL value
            mProtoTuple.add(null);
        } else {
            mProtoTuple.add(new DataByteArray(buf, start, end));
        }
    }
View Full Code Here

        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(0, bagColl);

        inserters[i].insert(new BytesWritable(("key" + i).getBytes()), tuple);
      }
View Full Code Here

        double curMax = Double.NEGATIVE_INFINITY;
        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;
                curMax = java.lang.Math.max(curMax, 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.