Reputation: 10502
I was going through THIS and there is one example
CREATE TABLE groups (
groupname text,
username text,
email text,
age int,
hash_prefix int,
PRIMARY KEY ((groupname, hash_prefix), username)
)
The new column, hash_prefix, holds a prefix of a hash of the username. For example, it could be the first byte of the hash modulo four. Together with groupname, these two columns form the compound partition key. Instead of a group residing on one partition, it’s now spread across four partitions.
Here what is meaning of first byte of the hash modulo four
. Considering the given table can you give one example that what will be the query to sort & pagination ?
Upvotes: 2
Views: 522
Reputation: 11638
It means the remainder of the first byte divided by 4. A Modulo operation is defined as:
In computing, the modulo operation finds the remainder after division of one number by another (sometimes called modulus).
So for example, if the value of the first byte is 0xF7, that modulo four is 3. You may have seen this as the '%' operator in java, python and other languages. You can verify this in a python interpreter, i.e.:
>>> 0xF7 % 4
yields 3.
Upvotes: 5