@Override
  public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    if (arguments.length < 2) {
      throw new UDFArgumentLengthException(getFuncName() + " requires at least 2 arguments, got "
        + arguments.length);
    }
    if (arguments[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
      throw new UDFArgumentException(getFuncName() + " only takes primitive types, got "
        + arguments[0].getTypeName());
    }

    argumentOIs = arguments;
    converters = new Converter[arguments.length];

    TypeInfo commonInfo = TypeInfoUtils.getTypeInfoFromObjectInspector(arguments[0]);

    for (int i = 1; i < arguments.length; i++) {
      checkArgPrimitive(arguments, i);
      PrimitiveTypeInfo currInfo = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(arguments[i]);

      commonInfo = FunctionRegistry.getCommonClassForComparison(
        commonInfo, currInfo);
    }

    resultOI = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(
      (commonInfo == null) ?
        TypeInfoFactory.doubleTypeInfo : commonInfo);

    for (int i = 0; i < arguments.length; i++) {
      converters[i] = ObjectInspectorConverters.getConverter(arguments[i], resultOI);
    }

    return resultOI;
  }
@return desired comparison (positive for greatest, negative for least)
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFBaseNwayCompare.java