Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make UUID comparisions simpler

  • Loading branch information...
commit 2dfbbe59cb1ce57b17e0382c5e358b175975a8f4 1 parent 7e41a6a
@ryanking ryanking authored
Showing with 5 additions and 7 deletions.
  1. +5 −7 lib/cassandra/mock.rb
View
12 lib/cassandra/mock.rb
@@ -2,14 +2,10 @@
class UUID
def >=(other)
- other = nil if other == ''
- other = UUID.new(other) unless other.kind_of?(UUID)
(self <=> other) >= 0
end
def <=(other)
- other = nil if other == ''
- other = UUID.new(other) unless other.kind_of?(UUID)
(self <=> other) <= 0
end
end
@@ -116,7 +112,7 @@ def get_super(column_family, key, column, sub_column, options)
finish = to_compare_with_type(options[:finish], column_family, false)
ret = OrderedHash.new
row.keys.each do |key|
- if (key >= start || start.nil?) && (key <= finish || finish.nil?)
+ if (start.nil? || key >= start) && (finish.nil? || key <= finish)
ret[key] = row[key]
end
end
@@ -186,7 +182,7 @@ def multi_count_columns(column_family, keys)
def get_range(column_family, options = {})
column_family, _, _, options =
extract_and_validate_params_for_real(column_family, "", [options], READ_DEFAULTS)
- _get_range(column_family, options[:start].to_s, options[:finish].to_s, options[:count]).keys
+ _get_range(column_family, options[:start], options[:finish], options[:count]).keys
end
def count_range(column_family, options={})
@@ -212,9 +208,11 @@ def schema(load=true)
def _get_range(column_family, start, finish, count)
ret = OrderedHash.new
+ start = to_compare_with_type(start, column_family)
+ finish = to_compare_with_type(finish, column_family)
cf(column_family).keys.sort.each do |key|
break if ret.keys.size >= count
- if (key >= start || start == '') && (key <= finish || finish == '')
+ if (start.nil? || key >= start) && (finish.nil? || key <= finish)
ret[key] = cf(column_family)[key]
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.