Skip to content

Commit

Permalink
Adding row()/rows()/cells() methods to HappyBase table.
Browse files Browse the repository at this point in the history
They are just interfaces for now.
  • Loading branch information
dhermes committed Sep 4, 2015
1 parent fce9338 commit 44adf05
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 0 deletions.
90 changes: 90 additions & 0 deletions gcloud_bigtable/happybase/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,93 @@ def regions(self):
"""
raise NotImplementedError('The Cloud Bigtable API does not have a '
'concept of splitting a table into regions.')

def row(self, row, columns=None, timestamp=None, include_timestamp=False):
"""Retrieve a single row of data.
Returns the latest cells in each column (or all columns if ``columns``
is not specified). If a ``timestamp`` is set, then **latest** becomes
**latest** up until ``timestamp``.
:type row: str
:param row: Row key for the row we are reading from.
:type columns: list
:param columns: (Optional) Iterable containing column names (as
strings). Each column name can be either
* an entire column family: ``fam`` or ``fam:``
* an single column: ``fam:col``
:type timestamp: int
:param timestamp: (Optional) Timestamp (in milliseconds since the
epoch). If specified, only cells returned before (or
at) the timestamp will be returned.
:type include_timestamp: bool
:param include_timestamp: Flag to indicate if cell timestamps should be
included with the output.
:raises: :class:`NotImplementedError <exceptions.NotImplementedError>`
temporarily until the method is implemented.
"""
raise NotImplementedError('Temporarily not implemented.')

def rows(self, rows, columns=None, timestamp=None,
include_timestamp=False):
"""Retrieve multiple rows of data.
All optional arguments behave the same in this method as they do in
:meth:`row`.
:type rows: list
:param rows: Iterable of the row keys for the rows we are reading from.
:type columns: list
:param columns: (Optional) Iterable containing column names (as
strings). Each column name can be either
* an entire column family: ``fam`` or ``fam:``
* an single column: ``fam:col``
:type timestamp: int
:param timestamp: (Optional) Timestamp (in milliseconds since the
epoch). If specified, only cells returned before (or
at) the timestamp will be returned.
:type include_timestamp: bool
:param include_timestamp: Flag to indicate if cell timestamps should be
included with the output.
:raises: :class:`NotImplementedError <exceptions.NotImplementedError>`
temporarily until the method is implemented.
"""
raise NotImplementedError('Temporarily not implemented.')

def cells(self, row, column, versions=None, timestamp=None,
include_timestamp=False):
"""Retrieve multiple versions of a single cell from the table.
:type row: str
:param row: Row key for the row we are reading from.
:type column: str
:param column: Column we are reading from; of the form ``fam:col``.
:type versions: int
:param versions: (Optional) The maximum number of cells to return. If
not set, returns all cells found.
:type timestamp: int
:param timestamp: (Optional) Timestamp (in milliseconds since the
epoch). If specified, only cells returned before (or
at) the timestamp will be returned.
:type include_timestamp: bool
:param include_timestamp: Flag to indicate if cell timestamps should be
included with the output.
:raises: :class:`NotImplementedError <exceptions.NotImplementedError>`
temporarily until the method is implemented.
"""
raise NotImplementedError('Temporarily not implemented.')
41 changes: 41 additions & 0 deletions gcloud_bigtable/happybase/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,44 @@ def test_regions(self):

with self.assertRaises(NotImplementedError):
table.regions()

def test_row(self):
name = 'table-name'
connection = object()
table = self._makeOne(name, connection)

row_key = 'row-key'
columns = ['fam:col1', 'fam:col2']
timestamp = None
include_timestamp = True
with self.assertRaises(NotImplementedError):
table.row(row_key, columns=columns, timestamp=timestamp,
include_timestamp=include_timestamp)

def test_rows(self):
name = 'table-name'
connection = object()
table = self._makeOne(name, connection)

row_keys = ['row-key']
columns = ['fam:col1', 'fam:col2']
timestamp = None
include_timestamp = True
with self.assertRaises(NotImplementedError):
table.rows(row_keys, columns=columns, timestamp=timestamp,
include_timestamp=include_timestamp)

def test_cells(self):
name = 'table-name'
connection = object()
table = self._makeOne(name, connection)

row_key = 'row-key'
column = 'fam:col1'
versions = 11
timestamp = None
include_timestamp = True
with self.assertRaises(NotImplementedError):
table.cells(row_key, column, versions=versions,
timestamp=timestamp,
include_timestamp=include_timestamp)

0 comments on commit 44adf05

Please sign in to comment.