summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWouter Bolsterlee <uws@xs4all.nl>2014-11-24 23:16:46 +0100
committerWouter Bolsterlee <uws@xs4all.nl>2014-11-24 23:16:46 +0100
commit8a27521bf9a80411f46a600751329e92e43fccf9 (patch)
treebca91ba440b41dd18bac57ca47401bc5ffee1942
parent15b5311f0011a3c29d606a2b5fbedbcd828dbef0 (diff)
downloadhappybase-8a27521bf9a80411f46a600751329e92e43fccf9.tar.gz
Correctly handle scanner that are smaller than expected
Fixes #72.
-rw-r--r--NEWS.rst4
-rw-r--r--happybase/table.py9
2 files changed, 8 insertions, 5 deletions
diff --git a/NEWS.rst b/NEWS.rst
index 5875e50..9fb31b5 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -9,6 +9,10 @@ HappyBase 0.9
Release date: *not yet released*
+* Fix an issue where scanners would return fewer results than expected due to
+ HBase not always behaving as its documentation suggests. (`issue #72
+ <https://github.com/wbolster/happybase/issues/72>`_).
+
* Add support for the Thrift compact protocol (``TCompactProtocol``) in
:py:class:`Connection`.
diff --git a/happybase/table.py b/happybase/table.py
index 60e74be..ac897d2 100644
--- a/happybase/table.py
+++ b/happybase/table.py
@@ -389,6 +389,9 @@ class Table(object):
items = self.connection.client.scannerGetList(
scan_id, how_many)
+ if not items:
+ break # scan has finished
+
n_fetched += len(items)
for n_returned, item in enumerate(items, n_returned + 1):
@@ -401,11 +404,7 @@ class Table(object):
yield item.row, row
if limit is not None and n_returned == limit:
- return
-
- # Avoid round-trip when exhausted
- if len(items) < how_many:
- break
+ break # not interested in the remainder
finally:
self.connection.client.scannerClose(scan_id)
logger.debug(