Package org.apache.pig.data

Examples of org.apache.pig.data.DataByteArray


            }                                                                                          
            Text value = (Text) in.getCurrentValue();
            byte[] ba = value.getBytes();
            // make a copy of the bytes representing the input since
            // TextInputFormat will reuse the byte array
            return mTupleFactory.newTuple(new DataByteArray(ba, 0, value.getLength()));
        } catch (InterruptedException e) {
            throw new IOException("Error getting input");
        }
    }
View Full Code Here


      tuple.set(2, i); // int1
      tuple.set(3, random); // int2
      tuple.set(4, "string " + i); // str1
      tuple.set(5, "string random " + random); // str2
      tuple.set(6, new DataByteArray("byte " + i)); // byte1
      tuple.set(7, new DataByteArray("byte random " + random)); // byte2

      tuple.set(8, new Float(i * -1)); // float1 negative
      tuple.set(9, new Long(numbRows - i)); // long1 reverse
      tuple.set(10, new Double(i * 100)); // double1

View Full Code Here

    // insert data in row 1
    int row = 0;
  
    tuple.set(0, "hello world 1"); // string
    tuple.set(1, new DataByteArray("hello byte 1")); // byte
    inserter.insert(new BytesWritable(String.format("k%d%d", part + 1, row + 1)
        .getBytes()), tuple);

    // insert data in row 2
    row++;
  
    tuple.set(0, "hello world 2"); // string
    tuple.set(1, new DataByteArray("hello byte 2")); // byte
    inserter.insert(new BytesWritable(String.format("k%d%d", part + 1, row + 1)
        .getBytes()), tuple);

    // finish building table, closing out the inserter, writer, writer1
    inserter.close();
View Full Code Here

      Object[][] table = new Object[NUMB_TABLE_ROWS][3]// three columns
     
      for (int j=0; j<NUMB_TABLE_ROWS; ++j) {
        table[j][0] = i;
        table[j][1] = new String("string" + j);
        table[j][2] = new DataByteArray("byte" + (NUMB_TABLE_ROWS - j));
        ++totalTableRows;
      }
      // Create table
      createTable(pathTables.get(i), TABLE_SCHEMA, TABLE_STORAGE, table);
     
View Full Code Here

      for (int j=0; j<NUMB_TABLE_ROWS; ++j) {
        ArrayList<Object> resultRow = new ArrayList<Object>();
        resultRow.add(i)// int1
        resultRow.add(i)// source_table
        resultRow.add(new String("string" + j))// str1
        resultRow.add(new DataByteArray("byte" + (NUMB_TABLE_ROWS - j)))// byte1
        rows.add(resultRow);
      }
      resultTable.put(i, rows);
    }
   
View Full Code Here

                    else
                        throw new IOException("Malformed tuple");
                }
                mOut.write(buf);
            }
            DataByteArray value = new DataByteArray(mOut.toByteArray());
            t.append(value);
        }
        return t;
    }
View Full Code Here

                } else if (buf==','&&level.isEmpty()) { // Current map item complete
                    break;
                }
                mOut.write(buf);
            }
            DataByteArray value = null;
            if (mOut.size()>0)
                value = new DataByteArray(mOut.toByteArray());
            m.put(key, value);
            mOut.reset();
            if (buf==']')
                break;
        }
View Full Code Here

            break;
        case DataType.CHARARRAY:
            field = bytesToCharArray(b);
            break;
        case DataType.BYTEARRAY:
            field = new DataByteArray(b);
            break;
        case DataType.BOOLEAN:
            field = bytesToBoolean(b);
            break;
        default:
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(3, 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(tupRecord);
    map.clear();
    tuple.set(0, false);
    tupRecord.set(0, 2);
    tupRecord.set(1, 1002L);
    tuple.set(1, tupRecord);
    map.put("boy", "girl");
    map.put("adam", "amy");
    map.put("bob", "becky");
    map.put("carl", "cathy");
    tuple.set(2, map);
    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(3, bagColl);
    inserter.insert(new BytesWritable(String.format("k%d%d", part + 1, row + 1)
        .getBytes()), tuple);
View Full Code Here

    Map<String, String> 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
    Map<String, String> 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
    Map<String, String> m3 = new HashMap<String, String>();
    m3.put("a","m3-a");
    m3.put("b","m3-b");
    m3.put("c","m3-b");
   
    table3 = new Object[][] {
      {"a 8""Cupertino""California"1,  m3},
      {"a 7""San Jose",    "California"2,  m3},
      {"a 6""Santa Cruz""California"3,  m3},
      {"a 5""Las Vegas""Nevada",    4,  m3},
      {"a 4""New York",    "New York",    5,  m3},
      {"a 3""Phoenix",    "Arizona",    6,  m3},
      {"a 2""Dallas",    "Texas",    7,  m3},
      {"a 1""Reno",      "Nevada",    8,  m3} };
   
    // Create table3
    createTable(pathTable3, TABLE3_SCHEMA, TABLE3_STORAGE, table3);
   
    // Create table4 data
    table4 = new Object[][] {
      {1"Cupertino"1001L},
      {2"San Jose",    1008L},
      {3"Santa Cruz"1008L},
      {4"Las Vegas"1008L},
      {5"Dallas",    1010L},
      {6"Reno",      1000L} };
   
    // Create table4
    createTable(pathTable4, TABLE4_SCHEMA, TABLE4_STORAGE, table4);
   
    // Create table5 data
    table5 = new Object[][] {
      {3.25f,    51e+21001L"string1"new DataByteArray("green")100},
      {3.25f,    51e+21001L"string1"new DataByteArray("green")100},
      {3.25f,    51e+21001L"string1"new DataByteArray("green")100},
      {3.25f,    51e+21001L"string1"new DataByteArray("green")100},
      {3.25f,    51e+21001L"string1"new DataByteArray("green")100},
      {3.25f,    51e+21001L"string1"new DataByteArray("green")100} };
   
    // Create table5
    createTable(pathTable5, TABLE5_SCHEMA, TABLE5_STORAGE, table5);
   
    // Create table6 data
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.