Skip to content

Commit

Permalink
Set buffer length at correct location
Browse files Browse the repository at this point in the history
Added incompatible argument exception
  • Loading branch information
pilate committed Jul 30, 2013
1 parent 409bdcc commit b24ec32
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pycassa/columnfamily.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,6 @@ def get_range(self, start="", finish="", columns=None, column_start="",
To convert this to a list, use ``list()`` on the result.
"""

cl = read_consistency_level or self.read_consistency_level
cp = self._column_parent(super_column)
sp = self._slice_predicate(columns, column_start, column_finish,
Expand All @@ -918,6 +917,12 @@ def get_range(self, start="", finish="", columns=None, column_start="",
kr_args = {}
count = 0
i = 0

if start_token and (start or finish):
raise ValueError(
"ColumnFamily.get_range() received incompatible arguments: "
"'start_token' may not be used with 'start' or 'finish'")

if not start_token:
kr_args['start_key'] = self._pack_key(start)
else:
Expand All @@ -930,14 +935,14 @@ def get_range(self, start="", finish="", columns=None, column_start="",

if buffer_size is None:
buffer_size = self.buffer_size
kr_args['count'] = buffer_size
while True:
if row_count is not None:
if i == 0 and row_count <= buffer_size:
# We don't need to chunk, grab exactly the number of rows
buffer_size = row_count
else:
buffer_size = min(row_count - count + 1, buffer_size)
kr_args['count'] = buffer_size
key_range = KeyRange(**kr_args)
key_slices = self.pool.execute('get_range_slices', cp, sp, key_range, cl)
# This may happen if nothing was ever inserted
Expand Down

0 comments on commit b24ec32

Please sign in to comment.