protected CompareResult compare(Object[] parameters) {
      int i = 0;
      int c = 0;
      for (RankAssets rankAssets : rankAssetsList) {
        c = rankAssets.compare(parameters[4 * i + 1], parameters[4 * i]);
        if (c != 0) {
          break;
        }
        ++i;
      }

      if (c == 0) {
        return new CompareResult(c, -1);
      }

      return new CompareResult(c, rankAssetsList.get(i).order);
    }
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