private static List<Long> extractNDVGroupingColumns(List<ColStatistics> colStats, Statistics parentStats) {
    List<Long> ndvValues = new ArrayList<>(colStats.size());

    // compute product of distinct values of grouping columns
    for (ColStatistics cs : colStats) {
      if (cs != null) {
        long ndv = cs.getCountDistint();
        if (cs.getNumNulls() > 0) {
          ndv = StatsUtils.safeAdd(ndv, 1);
        }
        ndvValues.add(ndv);
      } else {
        if (parentStats.getColumnStatsState().equals(Statistics.State.COMPLETE)) {
          // the column must be an aggregate column inserted by GBY. We
          // don't have to account for this column when computing product
          // of NDVs
          continue;
        } else {
          // partial column statistics on grouping attributes case.
          // if column statistics on grouping attribute is missing, then
          // assume worst case.
          ndvValues = null;
        }
        break;
      }
    }

    return ndvValues;
  }
Update the basic statistics of the statistics object based on the row number
@param stats
         - statistics to be updated
@param newNumRows
         - new number of rows
@param useColStats
         - use column statistics to compute data size
ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUtils.java