public static HCatRecordObjectInspector getHCatRecordObjectInspector(
    StructTypeInfo typeInfo) throws SerDeException {
    HCatRecordObjectInspector oi = cachedHCatRecordObjectInspectors.getIfPresent(typeInfo);
    if (oi == null) {

      LOG.debug("Got asked for OI for {} [{} ]", typeInfo.getCategory(), typeInfo.getTypeName());
      switch (typeInfo.getCategory()) {
      case STRUCT:
        StructTypeInfo structTypeInfo = (StructTypeInfo) typeInfo;
        List<String> fieldNames = structTypeInfo.getAllStructFieldNames();
        List<TypeInfo> fieldTypeInfos = structTypeInfo.getAllStructFieldTypeInfos();
        List<ObjectInspector> fieldObjectInspectors = new ArrayList<ObjectInspector>(fieldTypeInfos.size());
        for (int i = 0; i < fieldTypeInfos.size(); i++) {
          fieldObjectInspectors.add(getStandardObjectInspectorFromTypeInfo(fieldTypeInfos.get(i)));
        }
        oi = new HCatRecordObjectInspector(fieldNames, fieldObjectInspectors);

        break;
      default:
        // Hmm.. not good,
        // the only type expected here is STRUCT, which maps to HCatRecord
        // - anything else is an error. Return null as the inspector.
        throw new SerDeException("TypeInfo [" + typeInfo.getTypeName()
          + "] was not of struct type - HCatRecord expected struct type, got ["
          + typeInfo.getCategory().toString() + "]");
      }
      cachedHCatRecordObjectInspectors.put(typeInfo, oi);
    }
    return oi;
  }
Returns HCatRecordObjectInspector given a StructTypeInfo type definition for the record to look into
@param typeInfo Type definition for the record to look into
@return appropriate HCatRecordObjectInspector
@throws SerDeException
hcatalog/core/src/main/java/org/apache/hive/hcatalog/data/HCatRecordObjectInspectorFactory.java