@Override
    public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException {
      HypotheticalSetDenseRankBuffer rankBuffer = (HypotheticalSetDenseRankBuffer) agg;

      CompareResult compareResult = compare(parameters);
      if (compareResult.getCompareResult() == 0) {
        return;
      }

      if (compareResult.getOrder() == ASCENDING_CODE && compareResult.getCompareResult() < 0 ||
              compareResult.getOrder() == DESCENDING_CODE && compareResult.getCompareResult() > 0) {
        List<Object> columnValues = new ArrayList<>(parameters.length / 4);
        for (int i = 0; i < parameters.length / 4; ++i) {
          columnValues.add(parameters[i * 4 + 1]);
        }
        RowData rowData = new RowData(columnValues);
        if (!rankBuffer.elements.contains(rowData)) {
          rankBuffer.elements.add(rowData);
          rankBuffer.rank++;
        }
      }
    }
Evaluator for calculating the dense rank.
SELECT dense_rank(expression1[, expressionn]*) WITHIN GROUP (ORDER BY col1[, coln]*)
Implementation is based on hypothetical rank calculation but the group of values are considered distinct.
Since the source of the input stream is not sorted a HashSet is used for filter out duplicate values
which can lead to OOM in large data sets.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFDenseRank.java