Database Reference
In-Depth Information
on the options available for querying ranges of rows. There are a few different partitioners you
can use, which we look at now.
NOTE
The choice of partitioner does not apply to column sorting, only row key sorting.
You set the partitioner by updating the value of the Partitioner element in the config
file or in the API. It takes as a value the name of a class that implements the
org.apache.cassandra.dht.IPartitioner interface. Out of the box, Cassandra provides
three of these: the random partitioner, which is the default; the order-preserving partitioner;
and collating order-preserving partitioner. Because of Cassandra's generally pluggable design,
you
can
also
create
your
own
partitioner
by
implementing
the
org.apache.cassandra.dht.IPartitioner class and placing it on Cassandra's classpath.
WARNING
Keep in mind that the partitioner can modify the on-disk SSTable representations. So if you change the
partitioner type, you will have to delete your data directories.
Random Partitioner
The random partitioner is implemented by org.apache.cassandra.dht.RandomPartition-
er and is Cassandra's default. It uses a BigIntegerToken with an MD5 hash applied to it to de-
termine where to place the keys on the node ring. This has the advantage of spreading your keys
evenly across your cluster, because the distribution is random. It has the disadvantage of causing
inefficient range queries, because keys within a specified range might be placed in a variety of
disparate locations in the ring, and key range queries will return data in an essentially random
order.
Order-Preserving Partitioner
The order-preserving partitioner is implemented by
org.apache.cassandra.dht.OrderPreservingPartitioner , which implements IParti-
tioner<StringToken> . Using this type of partitioner, the token is a UTF-8 string, based on a
key. Rows are therefore stored by key order, aligning the physical structure of the data with your
sort order. Configuring your column family to use order-preserving partitioning (OPP) allows
you to perform range slices.
Search WWH ::




Custom Search