groupingSets is a set of bitmask of which a set bit represents a groupby key which is an element of the corresponding group set. BitSet1 is used for quick access to the groupby keys in a grouping set, similar to the HIVE implementation. If you think bit testing via shift operation is better, I can remove it.