Package org.apache.pig.data

Examples of org.apache.pig.data.NonSpillableDataBag


    if (fieldDescriptor.isRepeated()) {
      // The protobuf contract is that if the field is repeated, then the object returned is actually a List
      // of the underlying datatype, which in this case is a nested message.
      List<Message> messageList = (List<Message>) (fieldValue != null ? fieldValue : Lists.newArrayList());

      DataBag bag = new NonSpillableDataBag(messageList.size());
      for (Message m : messageList) {
        bag.add(new ProtobufTuple(m));
      }
      return bag;
    } else {
      return new ProtobufTuple((Message)fieldValue);
    }
View Full Code Here


    if (fieldDescriptor.isRepeated()) {
      // The protobuf contract is that if the field is repeated, then the object returned is actually a List
      // of the underlying datatype, which in this case is a "primitive" like int, float, String, etc.
      // We have to make a single-item tuple out of it to put it in the bag.
      List<Object> fieldValueList = (List<Object>) (fieldValue != null ? fieldValue : Collections.emptyList());
      DataBag bag = new NonSpillableDataBag(fieldValueList.size());
      for (Object singleFieldValue : fieldValueList) {
        Object nonEnumFieldValue = coerceToPigTypes(fieldDescriptor, singleFieldValue);
        Tuple innerTuple = tupleFactory_.newTuple(1);
        try {
          innerTuple.set(0, nonEnumFieldValue);
        } catch (ExecException e) { // not expected
          throw new RuntimeException(e);
        }
        bag.add(innerTuple);
      }
      return bag;
    } else {
      return coerceToPigTypes(fieldDescriptor, fieldValue);
    }
View Full Code Here

    if (isNestedLoadEnabled && value instanceof JSONObject) {
      return walkJson((JSONObject) value);
    else if (isNestedLoadEnabled && value instanceof JSONArray) {
     
      JSONArray a = (JSONArray) value;
      DataBag mapValue = new NonSpillableDataBag(a.size());
      for (int i=0; i<a.size(); i++) {
        Tuple t = tupleFactory.newTuple(wrap(a.get(i)));
        mapValue.add(t);
      }
      return mapValue;
     
    } else {
      return value != null ? value.toString() : null;
View Full Code Here

  private static Tuple personTuple(String name, int id, String email, String phoneNumber,
      String phoneType) {
    TupleFactory tf = TupleFactory.getInstance();
    return tf.newTupleNoCopy(
        Lists.<Object> newArrayList(name, id, email,
          new NonSpillableDataBag(
              Lists.<Tuple>newArrayList(
                  tf.newTupleNoCopy(
                      Lists.<Object> newArrayList(phoneNumber, phoneType))))));
  }
View Full Code Here

  }

  private static Tuple personTuple(String name, int id, String email, String phoneNumber,
      String phoneType) {
    return tuple(tuple(name, null), id, email,
        new NonSpillableDataBag(Lists.<Tuple>newArrayList(tuple(phoneNumber, phoneType))));
  }
View Full Code Here

    .setId(123)
    .build();
  }
 
  public static Tuple buildPersonTuple() throws ExecException {
    DataBag phoneBag = new NonSpillableDataBag(
      Lists.newArrayList(makePhoneNumberTuple("415-999-9999", null),
      makePhoneNumberTuple("415-666-6666", "MOBILE"),
      makePhoneNumberTuple("415-333-3333", "WORK")));
   
    Tuple entryTuple = tf_.newTuple(4);
View Full Code Here

    entryTuple.set(3, phoneBag);
    return entryTuple;
  }
  // {(Elephant Bird,123,elephant@bird.com,{(415-999-9999,HOME),(415-666-6666,MOBILE),(415-333-3333,WORK)})}
  public static Tuple buildAddressBookTuple() throws ExecException {
    DataBag entryBag = new NonSpillableDataBag(
     Lists.newArrayList(buildPersonTuple(),
     buildPersonTuple()));
    return tf_.newTuple(entryBag);
  }
View Full Code Here

      }
      return (int) sum/nums.length;
    }

    private DataBag newSimpleBag(Object... objects) {
      DataBag bag = new NonSpillableDataBag(objects.length);
      for (Object o : objects) {
        bag.add(tf_.newTuple(o));
      }
      return bag;
    }
View Full Code Here

TOP

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

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.