def group_by_vbucket_id(self, vbuckets_num, rehash=0):
        g = defaultdict(list)
        for msg in self.msgs:
            cmd, vbucket_id, key, flg, exp, cas, meta, val = msg
            if vbucket_id == 0x0000ffff or rehash == 1:
                # Special case when the source did not supply a vbucket_id
                # (such as stdin source), so we calculate it.
                vbucket_id = (zlib.crc32(key) >> 16) & (vbuckets_num - 1)
                msg = (cmd, vbucket_id, key, flg, exp, cas, meta, val)
            g[vbucket_id].append(msg)
        return g
Returns dict of vbucket_id->[msgs] grouped by msg's vbucket_id.
dataset/ETHPy150Open membase/membase-cli/pump.py/Batch.group_by_vbucket_id