private static List<?> serializeList(Object f, ListObjectInspector loi) throws SerDeException {
    List l = loi.getList(f);
    if (l == null) {
      return null;
    }

    ObjectInspector eloi = loi.getListElementObjectInspector();
    if (eloi.getCategory() == Category.PRIMITIVE) {
      List<Object> list = new ArrayList<Object>(l.size());
      for (int i = 0; i < l.size(); i++) {
        list.add(((PrimitiveObjectInspector) eloi).getPrimitiveJavaObject(l.get(i)));
      }
      return list;
    } else if (eloi.getCategory() == Category.STRUCT) {
      List<List<?>> list = new ArrayList<List<?>>(l.size());
      for (int i = 0; i < l.size(); i++) {
        list.add(serializeStruct(l.get(i), (StructObjectInspector) eloi));
      }
      return list;
    } else if (eloi.getCategory() == Category.LIST) {
      List<List<?>> list = new ArrayList<List<?>>(l.size());
      for (int i = 0; i < l.size(); i++) {
        list.add(serializeList(l.get(i), (ListObjectInspector) eloi));
      }
      return list;
    } else if (eloi.getCategory() == Category.MAP) {
      List<Map<?, ?>> list = new ArrayList<Map<?, ?>>(l.size());
      for (int i = 0; i < l.size(); i++) {
        list.add(serializeMap(l.get(i), (MapObjectInspector) eloi));
      }
      return list;
    } else {
      throw new SerDeException(HCatRecordSerDe.class.toString()
        + " does not know what to do with fields of unknown category: "
        + eloi.getCategory() + " , type: " + eloi.getTypeName());
    }
  }
Helper method to return underlying Java Map from
an object-representation that is readable by a provided
MapObjectInspector
hcatalog/core/src/main/java/org/apache/hive/hcatalog/data/HCatRecordSerDe.java