Skip to content

Commit

Permalink
Checking for sorted_columns (unused) in HappyBase Table.scan().
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Sep 18, 2015
1 parent 19d8bc6 commit efc7ac5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions gcloud_bigtable/happybase/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
_UNPACK_I64 = struct.Struct('>q').unpack
_DEFAULT_BATCH_SIZE = object()
_DEFAULT_SCAN_BATCHING = object()
_DEFAULT_SORTED_COLUMNS = object()


def make_row(cell_map, include_timestamp):
Expand Down Expand Up @@ -522,7 +523,7 @@ def scan(self, row_start=None, row_stop=None, row_prefix=None,
columns=None, filter=None, timestamp=None,
include_timestamp=False, batch_size=_DEFAULT_BATCH_SIZE,
scan_batching=_DEFAULT_SCAN_BATCHING,
limit=None, sorted_columns=False):
limit=None, sorted_columns=_DEFAULT_SORTED_COLUMNS):
"""Create a scanner for data in this table.
This method returns a generator that can be used for looping over the
Expand Down Expand Up @@ -593,8 +594,9 @@ def scan(self, row_start=None, row_stop=None, row_prefix=None,
:param limit: (Optional) Maximum number of rows to return.
:type sorted_columns: bool
:param sorted_columns: Flag to indicate if the returned columns need
to be sorted.
:param sorted_columns: Unused parameter. Provided compatibility with
HappyBase, but irrelevant for Cloud Bigtable
since it cannot return sorted columns.
:raises: :class:`ValueError <exceptions.ValueError>` if ``batch_size``
or ``scan_batching`` are used, or if ``limit`` is set but
Expand All @@ -608,6 +610,9 @@ def scan(self, row_start=None, row_stop=None, row_prefix=None,
if scan_batching is not _DEFAULT_SCAN_BATCHING:
raise ValueError('Scan batching cannot be set for gcloud '
'HappyBase module')
if sorted_columns is not _DEFAULT_SORTED_COLUMNS:
raise ValueError('Sorted columns cannot be set for gcloud '
'HappyBase module')
if limit is not None and limit < 1:
raise ValueError('limit must be positive')
if row_prefix is not None:
Expand Down
11 changes: 8 additions & 3 deletions gcloud_bigtable/happybase/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,13 @@ def test_scan_with_scan_batching(self):
with self.assertRaises(ValueError):
table.scan(scan_batching=object())

def test_scan_with_sorted_columns(self):
name = 'table-name'
connection = None
table = self._makeOne(name, connection)
with self.assertRaises(ValueError):
table.scan(sorted_columns=object())

def test_scan_with_invalid_limit(self):
name = 'table-name'
connection = None
Expand All @@ -822,13 +829,11 @@ def test_scan(self):
timestamp = None
include_timestamp = True
limit = 123
sorted_columns = True
with self.assertRaises(NotImplementedError):
table.scan(row_start=row_start, row_stop=row_stop,
columns=columns, filter=filter_,
timestamp=timestamp,
include_timestamp=include_timestamp,
limit=limit, sorted_columns=sorted_columns)
include_timestamp=include_timestamp, limit=limit)

def test_put(self):
from gcloud_bigtable._testing import _Monkey
Expand Down

0 comments on commit efc7ac5

Please sign in to comment.