presto-main/src/main/java/io/prestosql/sql/planner/GroupingOperationRewriter.java/GroupingOperationRewriter/calculateGrouping
class GroupingOperationRewriter:    static long calculateGrouping(Set<Integer> groupingSet, List<Integer> columns)
    {
        long grouping = (1L << columns.size()) - 1;

        for (int index = 0; index < columns.size(); index++) {
            int column = columns.get(index);

            if (groupingSet.contains(column)) {
                // Leftmost argument to grouping() (i.e. when index = 0) corresponds to
                // the most significant bit in the result. That is why we shift 1L starting
                // from the columns.size() - 1 bit index.
                grouping = grouping & ~(1L << (columns.size() - 1 - index));
            }
        }

        return grouping;
    }