code: private static int partitionForKey(byte[] key, int numPartitions) {
          CRC32 crc32 = new CRC32();
          crc32.update(key);
          long rv = (crc32.getValue() >> 16) & 0x7fff;
          return (int) rv &numPartitions - 1;
      }
docs: Calculate the vbucket for the given key.
  
  @param key the key to calculate from.
  @param numPartitions the number of partitions in the bucket.
  @return the calculated partition.