Skip to content

Commit

Permalink
respect count in _get_range, fixes cassandra-rb#22
Browse files Browse the repository at this point in the history
  • Loading branch information
grantr committed May 26, 2010
1 parent 9ed215a commit 55c2dd7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cassandra/protocol.rb
Expand Up @@ -74,7 +74,7 @@ def _multiget(column_family, keys, column, sub_column, count, start, finish, rev
def _get_range(column_family, start, finish, count, consistency)
column_parent = CassandraThrift::ColumnParent.new(:column_family => column_family)
predicate = CassandraThrift::SlicePredicate.new(:slice_range => CassandraThrift::SliceRange.new(:start => '', :finish => ''))
range = CassandraThrift::KeyRange.new(:start_key => start, :end_key => finish)
range = CassandraThrift::KeyRange.new(:start_key => start, :end_key => finish, :count => count)
client.get_range_slices(@keyspace, column_parent, predicate, range, 1)
end

Expand Down
9 changes: 9 additions & 0 deletions test/cassandra_test.rb
Expand Up @@ -167,6 +167,15 @@ def test_get_super_value
# @twitter.insert(:Statuses, '6', {'body' => '1'})
# assert_equal(['3', '4', '5'], @twitter.get_range(:Statuses, :start => '3', :finish => '5'))
# end

def test_get_range_count
@twitter.insert(:Statuses, '2', {'body' => '1'})
@twitter.insert(:Statuses, '3', {'body' => '1'})
@twitter.insert(:Statuses, '4', {'body' => '1'})
@twitter.insert(:Statuses, '5', {'body' => '1'})
@twitter.insert(:Statuses, '6', {'body' => '1'})
assert_equal(3, @twitter.get_range(:Statuses, :count => 3).size)
end

def test_multi_get
@twitter.insert(:Users, key + '1', {'body' => 'v1', 'user' => 'v1'})
Expand Down

0 comments on commit 55c2dd7

Please sign in to comment.