private ObjectInspector createObjectInspector(FieldDescriptor descriptor,
      Map<Descriptor, ObjectInspector> cache) throws SerDeException {
    ObjectInspector oi;
    switch(descriptor.getJavaType()) {
    case BOOLEAN:
      oi = getPrimitive(PrimitiveCategory.BOOLEAN);
      break;
    case BYTE_STRING:
      oi = getPrimitive(PrimitiveCategory.BINARY);
      break;
    case DOUBLE:
      oi = getPrimitive(PrimitiveCategory.DOUBLE);
      break;
    case ENUM:
      oi = getPrimitive(PrimitiveCategory.STRING);
      break;
    case FLOAT:
      oi = getPrimitive(PrimitiveCategory.FLOAT);
      break;
    case INT:
      oi = getPrimitive(PrimitiveCategory.INT);
      break;
    case LONG:
      oi = getPrimitive(PrimitiveCategory.LONG);
      break;
    case STRING:
      oi = getPrimitive(PrimitiveCategory.STRING);
      break;
    case MESSAGE:
      Descriptor msgType = descriptor.getMessageType();
      if (descriptor.isRepeated() && mapTypes.contains(msgType.getFullName())) {
        return getMapObjectInspector(msgType, cache);
      } else {
        oi = createStructObjectInspector(msgType, cache);
      }
      break;
    default:
      throw new IllegalArgumentException("unexpected type: " + descriptor.getJavaType());
    }
    return descriptor.isRepeated() ? ObjectInspectorFactory.getStandardListObjectInspector(oi) : oi;
  }
Convert the given writable to a message.
@param writable The writable object containing the message.
@return The converted message object.
@throws SerDeException
ql/src/java/org/apache/hadoop/hive/ql/io/protobuf/ProtobufSerDe.java