// Append the separator if needed.
if (i>0) {
sb.append((char)separators[0]);
}
// Get the field objectInspector and the field object.
ObjectInspector foi = fields.get(i).getFieldObjectInspector();
Object f = (list == null ? null : list.get(i));
if (declaredFields != null && i >= declaredFields.size()) {
throw new SerDeException(
"Error: expecting " + declaredFields.size()
+ " but asking for field " + i + "\n" + "data=" + obj + "\n"
+ "tableType=" + rowTypeInfo.toString() + "\n"
+ "dataType="
+ TypeInfoUtils.getTypeInfoFromObjectInspector(objInspector));
}
// If the field that is passed in is a primitive, then we serialize the
// primitive object.
if (foi.getCategory().equals(Category.PRIMITIVE)) {
sb.append(f == null ? nullString : f.toString());
} else {
// If the field is not declared (no schema was given at
// initialization), or the field is declared as a primitive in
// initialization, serialize the data to JSON string.