Skip to content

Commit 8a27521

Browse files
committed
Correctly handle scanner that are smaller than expected
Fixes #72.
1 parent 15b5311 commit 8a27521

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

NEWS.rst

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ HappyBase 0.9
99

1010
Release date: *not yet released*
1111

12+
* Fix an issue where scanners would return fewer results than expected due to
13+
HBase not always behaving as its documentation suggests. (`issue #72
14+
<https://github.com/wbolster/happybase/issues/72>`_).
15+
1216
* Add support for the Thrift compact protocol (``TCompactProtocol``) in
1317
:py:class:`Connection`.
1418

happybase/table.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,9 @@ def scan(self, row_start=None, row_stop=None, row_prefix=None,
389389
items = self.connection.client.scannerGetList(
390390
scan_id, how_many)
391391

392+
if not items:
393+
break # scan has finished
394+
392395
n_fetched += len(items)
393396

394397
for n_returned, item in enumerate(items, n_returned + 1):
@@ -401,11 +404,7 @@ def scan(self, row_start=None, row_stop=None, row_prefix=None,
401404
yield item.row, row
402405

403406
if limit is not None and n_returned == limit:
404-
return
405-
406-
# Avoid round-trip when exhausted
407-
if len(items) < how_many:
408-
break
407+
break # not interested in the remainder
409408
finally:
410409
self.connection.client.scannerClose(scan_id)
411410
logger.debug(

0 commit comments

Comments
 (0)