private static long convert(ImmutableBitSet targetGroupSet, ImmutableBitSet groupSet) {
    long value = 0L;
    for (int i = 0; i < groupSet.length(); ++i) {
      int bit = groupSet.nth(i);
      value += targetGroupSet.get(bit) ? 0L : (1L << groupSet.length() - i - 1);
    }
    return value;
  }
Computes the results of the grouping function given the grouping set and the
group by columns.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/views/HiveMaterializedViewUtils.java