Package org.apache.pig.data

Examples of org.apache.pig.data.DataByteArray


        public Tuple exec(Tuple input) throws IOException {
            try {
                // input is a bag with one tuple containing
                // the column we are trying to max on
                DataBag bg = (DataBag) input.get(0);
                DataByteArray dba = null;
                if(bg.iterator().hasNext()) {
                    Tuple tp = bg.iterator().next();
                    dba = (DataByteArray)tp.get(0);
                }
                return tfact.newTuple(dba != null ?
                        Double.valueOf(dba.toString()): null);
            } catch (NumberFormatException e) {
                Tuple t = tfact.newTuple(1);
                t.set (0, null);
                return t;
            } catch (ExecException ee) {
View Full Code Here


                }
                Tuple tuple=TupleFactory.getInstance().newTuple(tupleSize);

                int startIndex=0;
                if (loadRowKey_){
                    tuple.set(0, new DataByteArray(rowKey.get()));
                    startIndex++;
                }
                for (int i=0;i<columnList_.size();++i){
                    byte[] cell=result.getValue(columnList_.get(i));
                    if (cell!=null)
                        tuple.set(i+startIndex, new DataByteArray(cell));
                    else
                        tuple.set(i+startIndex, null);
                }
                return tuple;
            }
View Full Code Here

        double curMin = Double.POSITIVE_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;
                curMin = java.lang.Math.min(curMin, d);
            } catch (RuntimeException exp) {
                int errCode = 2103;
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

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

    // insert data in row 2
    row++;
    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
    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

        public Tuple exec(Tuple input) throws IOException {
            try {
                // input is a bag with one tuple containing
                // the column we are trying to min on
                DataBag bg = (DataBag) input.get(0);
                DataByteArray dba = null;
                if(bg.iterator().hasNext()) {
                    Tuple tp = bg.iterator().next();
                    dba = (DataByteArray)tp.get(0);
                }
                return tfact.newTuple(dba != null?
                        Double.valueOf(dba.toString()) : null);
            } catch (NumberFormatException e) {
                // invalid input, send null
                Tuple t =  tfact.newTuple(1);
                t.set(0, null);
                return t;
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) {
View Full Code Here

            // we just send the tuple down
            try {
                // input is a bag with one tuple containing
                // the column we are trying to sum
                DataBag bg = (DataBag) input.get(0);
                DataByteArray dba = null;
                if(bg.iterator().hasNext()) {
                    Tuple tp = bg.iterator().next();
                    dba = (DataByteArray)tp.get(0);
                }
                return tfact.newTuple(dba != null?
                        Double.valueOf(dba.toString()): null);
            }catch(NumberFormatException nfe){
                // treat this particular input as null
                Tuple t = tfact.newTuple(1);
                t.set(0, null);
                return t;
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

      ArrayList<ArrayList<Object>> rows = new ArrayList<ArrayList<Object>>();
      for (int j=0; j<NUMB_TABLE_ROWS; ++j) {
        ArrayList<Object> resultRow = new ArrayList<Object>();
        resultRow.add(tblIndexList[i])// int1
        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

        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

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.