@Override
    public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException {
      super.init(m, parameters);

      if (mode == Mode.PARTIAL1 || mode == Mode.COMPLETE) {
        rankAssetsList = new ArrayList<>(parameters.length / 4);
        for (int i = 0; i < parameters.length / 4; ++i) {
          TypeInfo directArgumentType = TypeInfoUtils.getTypeInfoFromObjectInspector(parameters[4 * i]);
          TypeInfo inputType = TypeInfoUtils.getTypeInfoFromObjectInspector(parameters[4 * i + 1]);
          TypeInfo commonTypeInfo = FunctionRegistry.getCommonClassForComparison(inputType, directArgumentType);
          ObjectInspector commonInputOI = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(commonTypeInfo);
          rankAssetsList.add(new RankAssets(
                  commonInputOI,
                  ObjectInspectorConverters.getConverter(parameters[4 * i], commonInputOI),
                  ObjectInspectorConverters.getConverter(parameters[4 * i + 1], commonInputOI),
                  ((WritableConstantIntObjectInspector) parameters[4 * i + 2]).
                          getWritableConstantValue().get(),
                  NullOrdering.fromCode(((WritableConstantIntObjectInspector) parameters[4 * i + 3]).
                          getWritableConstantValue().get())));
        }
      } else {
        initPartial2AndFinalOI(parameters);
      }

      if (mode == Mode.PARTIAL1 || mode == Mode.PARTIAL2) {
        return partialOutputOI;
      }

      return finalOI;
    }
Hypothetical rank calculation.
 Calculates the rank of a hypothetical row specified by the arguments of the
 function in a group of values specified by the order by clause.
 SELECT rank(expression1[, expressionn]*) WITHIN GROUP (ORDER BY col1[, coln]*)
 (the number of rows where col1 &lt; expression1 [and coln &lt; expressionn]*) + 1
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFRank.java