public static Object serializeField(Object field, ObjectInspector fieldObjectInspector)
    throws SerDeException {

    Object res;
    if (fieldObjectInspector.getCategory() == Category.PRIMITIVE) {
      res = serializePrimitiveField(field, fieldObjectInspector);
    } else if (fieldObjectInspector.getCategory() == Category.STRUCT) {
      res = serializeStruct(field, (StructObjectInspector) fieldObjectInspector);
    } else if (fieldObjectInspector.getCategory() == Category.LIST) {
      res = serializeList(field, (ListObjectInspector) fieldObjectInspector);
    } else if (fieldObjectInspector.getCategory() == Category.MAP) {
      res = serializeMap(field, (MapObjectInspector) fieldObjectInspector);
    } else {
      throw new SerDeException(HCatRecordSerDe.class.toString()
        + " does not know what to do with fields of unknown category: "
        + fieldObjectInspector.getCategory() + " , type: " + fieldObjectInspector.getTypeName());
    }
    return res;
  }
Return underlying Java Object from an object-representation
that is readable by a provided ObjectInspector.
hcatalog/core/src/main/java/org/apache/hive/hcatalog/data/HCatRecordSerDe.java