Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplify get_range_batch. Break inner loop if no more records are pul…

…led.
  • Loading branch information...
commit dc067695fda399490da8ea4e3f860682af16d4fe 1 parent 2d8989c
Robert Jackson authored
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/cassandra/cassandra.rb
View
13 lib/cassandra/cassandra.rb
@@ -749,18 +749,18 @@ def get_range_batch(column_family, options = {})
batch_size = options.delete(:batch_size) || 100
count = options.delete(:key_count)
result = (!block_given? && {}) || nil
- num_results = 0
+ num_results = 0
- first_key = options[:start_key] || ''
+ options[:start_key] ||= ''
last_key = nil
- while first_key != last_key && (count.nil? || count > num_results)
- first_key = last_key
-
- res = get_range_single(column_family, options.merge!(:start_key => first_key,
+ while count.nil? || count > num_results
+ res = get_range_single(column_family, options.merge!(:start_key => last_key || options[:start_key],
:key_count => batch_size,
:return_empty_rows => true
))
+ break if res.keys.last == last_key
+
res.each do |key, columns|
next if last_key == key
next if num_results == count
@@ -773,6 +773,7 @@ def get_range_batch(column_family, options = {})
end
num_results += 1
end
+
last_key = key
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.