private ObjectInspectorConverters.Converter getConverter(ObjectInspector arg) {

    switch (arg.getCategory()) {
      case PRIMITIVE:
        return ObjectInspectorConverters.getConverter(arg, arg);
      case LIST:
      case MAP:
      case STRUCT:
        return ObjectInspectorConverters.getConverter(arg, solveOi(arg));
      default:
        return null;
    }
  }
 public static ConstantObjectInspector getConstantObjectInspector(
     ObjectInspector oi, Object value) {
   if (oi instanceof ConstantObjectInspector) {
     return (ConstantObjectInspector) oi;
   }
   ObjectInspector writableOI = getStandardObjectInspector(oi, ObjectInspectorCopyOption.WRITABLE);
   Object writableValue = ObjectInspectorConverters.getConverter(oi, writableOI).convert(value);
   switch (writableOI.getCategory()) {
     case PRIMITIVE:
       PrimitiveObjectInspector poi = (PrimitiveObjectInspector) oi;
       return PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
           poi.getTypeInfo(), writableValue);
     case LIST:
       ListObjectInspector loi = (ListObjectInspector) oi;
       return ObjectInspectorFactory.getStandardConstantListObjectInspector(
           getStandardObjectInspector(
               loi.getListElementObjectInspector(), ObjectInspectorCopyOption.WRITABLE),
           (List<?>) writableValue);
     case MAP:
       MapObjectInspector moi = (MapObjectInspector) oi;
       return ObjectInspectorFactory.getStandardConstantMapObjectInspector(
           getStandardObjectInspector(
               moi.getMapKeyObjectInspector(), ObjectInspectorCopyOption.WRITABLE),
           getStandardObjectInspector(
               moi.getMapValueObjectInspector(), ObjectInspectorCopyOption.WRITABLE),
           (Map<?, ?>) writableValue);
     default:
       throw new IllegalArgumentException(
           writableOI.getCategory() + " not yet supported for constant OI");
   }
 }