Skip to content

Commit

Permalink
Implementing make_row/make_ordered_row in HappyBase table module.
Browse files Browse the repository at this point in the history
These are just provided since they are public on the module,
but we do not intend to implement them (they rely on the types
returned from an HBase client).
  • Loading branch information
dhermes committed Sep 4, 2015
1 parent 480d5d1 commit 8e09214
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/happybase-table.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
HappyBase Table
~~~~~~~~~~~~~~~

.. automodule:: gcloud_bigtable.happybase.table
:members:
:undoc-members:
:show-inheritance:
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
:hidden:
:caption: HappyBase Compatibility Sub-Package

happybase-table
happybase-connection
happybase-batch
happybase-pool
Expand Down
64 changes: 64 additions & 0 deletions gcloud_bigtable/happybase/table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Google Cloud Bigtable HappyBase table module."""


def make_row(cell_map, include_timestamp):
"""Make a row dict for a Thrift cell mapping.
.. note::
This method is only provided for HappyBase compatibility, but does not
actually work.
:type cell_map: dict
:param cell_map: Dictionary with ``fam:col`` strings as keys and ``TCell``
instances as values.
:type include_timestamp: bool
:param include_timestamp: Flag to indicate if cell timestamps should be
included with the output.
:raises: :class:`NotImplementedError <exceptions.NotImplementedError>`
always
"""
raise NotImplementedError('The Cloud Bigtable API output is not the same '
'as the output from the Thrift server, so this '
'helper can not be implemented.', 'Called with',
cell_map, include_timestamp)


def make_ordered_row(sorted_columns, include_timestamp):
"""Make a row dict for sorted Thrift column results from scans.
.. note::
This method is only provided for HappyBase compatibility, but does not
actually work.
:type sorted_columns: list
:param sorted_columns: List of ``TColumn`` instances from Thrift.
:type include_timestamp: bool
:param include_timestamp: Flag to indicate if cell timestamps should be
included with the output.
:raises: :class:`NotImplementedError <exceptions.NotImplementedError>`
always
"""
raise NotImplementedError('The Cloud Bigtable API output is not the same '
'as the output from the Thrift server, so this '
'helper can not be implemented.', 'Called with',
sorted_columns, include_timestamp)
38 changes: 38 additions & 0 deletions gcloud_bigtable/happybase/test_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


import unittest2


class Test_make_row(unittest2.TestCase):

def _callFUT(self, *args, **kwargs):
from gcloud_bigtable.happybase.table import make_row
return make_row(*args, **kwargs)

def test_it(self):
with self.assertRaises(NotImplementedError):
self._callFUT({}, False)


class Test_make_ordered_row(unittest2.TestCase):

def _callFUT(self, *args, **kwargs):
from gcloud_bigtable.happybase.table import make_ordered_row
return make_ordered_row(*args, **kwargs)

def test_it(self):
with self.assertRaises(NotImplementedError):
self._callFUT([], False)

0 comments on commit 8e09214

Please sign in to comment.