Method: Cassandra#get_range
- Defined in:
- lib/cassandra/cassandra.rb
#get_range(column_family, options = {}, &blk) ⇒ Object
Return an Cassandra::OrderedHash containing the columns specified for the given range of keys in the column_family you request.
This method is just a convenience wrapper around Cassandra#get_range_single and Cassandra#get_range_batch. If :key_size, :batch_size, or a block is passed in Cassandra#get_range_batch will be called. Otherwise Cassandra#get_range_single will be used.
The start_key and finish_key parameters are only useful for iterating of all records as is done in the Cassandra#each and Cassandra#each_key methods if you are using the RandomPartitioner.
If the table is partitioned with OrderPreservingPartitioner you may use the start_key and finish_key params to select all records with the same prefix value.
If a block is passed in we will yield the row key and columns for each record returned.
Please note that Cassandra returns a row for each row that has existed in the system since gc_grace_seconds. This is because deleted row keys are marked as deleted, but left in the system until the cluster has had resonable time to replicate the deletion. This function attempts to suppress deleted rows (actually any row returned without columns is suppressed).
Please note that when enabling the :reversed option, :start and :finish should be swapped (e.g. reversal happens before selecting the range).
-
column_family - The column_family that you are inserting into.
-
options - Valid options are:
-
:start_key - The starting value for selecting a range of keys (only useful with OPP).
-
:finish_key - The final value for selecting a range of keys (only useful with OPP).
-
:key_count - The total number of keys to return from the query. (see note regarding deleted records)
-
:batch_size - The maximum number of keys to return per query. If specified will loop until :key_count is obtained or all records have been returned.
-
:columns - A list of columns to return.
-
:count - The number of columns requested to be returned.
-
:start - The starting value for selecting a range of columns.
-
:finish - The final value for selecting a range of columns.
-
:reversed - If set to true the results will be returned in reverse order.
-
:consistency - Uses the default read consistency if none specified.
-
660 661 662 663 664 665 666 |
# File 'lib/cassandra/cassandra.rb', line 660 def get_range(column_family, = {}, &blk) if block_given? || [:key_count] || [:batch_size] get_range_batch(column_family, , &blk) else get_range_single(column_family, , &blk) end end |