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);
}