I am using Random Partitioner
(cassandra version 0.7.8), i want to retrieve all keys in a CF. I try to use get_range_slices
to do this, and it looks like i can get the keys with this method, although the keys are not ordered.
And there is also a post saying: "This is allowed with any partitioner in 0.6" (Fetching all keys using the Cassandra API -- analogy to "SELECT id FROM table;"), but the api document says it is impossible (http://wiki.apache.org/cassandra/API#get_range_slices).
My question is, is this correct to use get_range_slices
in Random Partitioner
? Are there any official document confirm this?
Yes this is possible. The documentation you cited is trying to say that if you have row keys 1..10, and you ask for a range of 5..8 you will not get a set of rows [5, 6, 7, 8].
This is the documentation for fetching all rows from a column family.
Basically you use get_range_slices with a start_key of empty string, and no end_key. Depending on the number of rows specified in count, this might return fewer than all rows in the column family. In that case you use the last row key from the previous result set as the start_key for your next query.
Here is an example of doing this in Java with the Hector client (with multiple threads): https://github.com/zznate/cassandra-tutorial/blob/master/src/main/java/com/datastax/tutorial/KeyIteratorExample.java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With