@SuppressWarnings({ "rawtypes", "unchecked" })
  @Override
  public Object evaluate(GenericUDF.DeferredObject[] arguments) throws HiveException {
    Object maxV = null;
    //for case of conversion, convert both values to common type and then compare.
    for (int i = 0; i < arguments.length; i++) {
      Object ai = arguments[i].get();
      if (ai == null) { //NULL if any of the args are nulls
        return null;
      }

      if (maxV == null) { //First non-null item.
        maxV = converters[i].convert(ai);
        continue;
      }
      Object converted = converters[i].convert(ai);
      if (converted == null) {
        return null;
      }
      int result = ObjectInspectorUtils.compare(
        converted, resultOI,
        maxV, resultOI);
      if (getOrder() * result > 0) {
        maxV = converted;
      }
    }
    return maxV;
  }
@return desired comparison (positive for greatest, negative for least)
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFBaseNwayCompare.java