Skip to content

Commit 9f5d9a4

Browse files
committed
Merge pull request #1496 from dhermes/happybase-notimplemented
Implementing HappyBase methods that aren't functional in Bigtable.
2 parents 33b3bfd + a9e83d1 commit 9f5d9a4

File tree

4 files changed

+102
-0
lines changed

4 files changed

+102
-0
lines changed

gcloud/bigtable/happybase/connection.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,51 @@ def tables(self):
263263
if name.startswith(prefix)]
264264

265265
return table_names
266+
267+
def enable_table(self, name):
268+
"""Enable the specified table.
269+
270+
Cloud Bigtable has no concept of enabled / disabled tables so this
271+
method does not work. It is provided simply for compatibility.
272+
273+
:raises: :class:`NotImplementedError <exceptions.NotImplementedError>`
274+
always
275+
"""
276+
raise NotImplementedError('The Cloud Bigtable API has no concept of '
277+
'enabled or disabled tables.')
278+
279+
def disable_table(self, name):
280+
"""Disable the specified table.
281+
282+
Cloud Bigtable has no concept of enabled / disabled tables so this
283+
method does not work. It is provided simply for compatibility.
284+
285+
:raises: :class:`NotImplementedError <exceptions.NotImplementedError>`
286+
always
287+
"""
288+
raise NotImplementedError('The Cloud Bigtable API has no concept of '
289+
'enabled or disabled tables.')
290+
291+
def is_table_enabled(self, name):
292+
"""Return whether the specified table is enabled.
293+
294+
Cloud Bigtable has no concept of enabled / disabled tables so this
295+
method does not work. It is provided simply for compatibility.
296+
297+
:raises: :class:`NotImplementedError <exceptions.NotImplementedError>`
298+
always
299+
"""
300+
raise NotImplementedError('The Cloud Bigtable API has no concept of '
301+
'enabled or disabled tables.')
302+
303+
def compact_table(self, name, major=False):
304+
"""Compact the specified table.
305+
306+
Cloud Bigtable does not support compacting a table, so this
307+
method does not work. It is provided simply for compatibility.
308+
309+
:raises: :class:`NotImplementedError <exceptions.NotImplementedError>`
310+
always
311+
"""
312+
raise NotImplementedError('The Cloud Bigtable API does not support '
313+
'compacting a table.')

gcloud/bigtable/happybase/table.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,16 @@ def __init__(self, name, connection):
9191

9292
def __repr__(self):
9393
return '<table.Table name=%r>' % (self.name,)
94+
95+
def regions(self):
96+
"""Retrieve the regions for this table.
97+
98+
Cloud Bigtable does not give information about how a table is laid
99+
out in memory, so regions so this method does not work. It is
100+
provided simply for compatibility.
101+
102+
:raises: :class:`NotImplementedError <exceptions.NotImplementedError>`
103+
always
104+
"""
105+
raise NotImplementedError('The Cloud Bigtable API does not have a '
106+
'concept of splitting a table into regions.')

gcloud/bigtable/happybase/test_connection.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,39 @@ def test_tables_with_prefix(self):
311311
result = connection.tables()
312312
self.assertEqual(result, [unprefixed_table_name1])
313313

314+
def test_enable_table(self):
315+
cluster = _Cluster() # Avoid implicit environ check.
316+
connection = self._makeOne(autoconnect=False, cluster=cluster)
317+
318+
name = 'table-name'
319+
with self.assertRaises(NotImplementedError):
320+
connection.enable_table(name)
321+
322+
def test_disable_table(self):
323+
cluster = _Cluster() # Avoid implicit environ check.
324+
connection = self._makeOne(autoconnect=False, cluster=cluster)
325+
326+
name = 'table-name'
327+
with self.assertRaises(NotImplementedError):
328+
connection.disable_table(name)
329+
330+
def test_is_table_enabled(self):
331+
cluster = _Cluster() # Avoid implicit environ check.
332+
connection = self._makeOne(autoconnect=False, cluster=cluster)
333+
334+
name = 'table-name'
335+
with self.assertRaises(NotImplementedError):
336+
connection.is_table_enabled(name)
337+
338+
def test_compact_table(self):
339+
cluster = _Cluster() # Avoid implicit environ check.
340+
connection = self._makeOne(autoconnect=False, cluster=cluster)
341+
342+
name = 'table-name'
343+
major = True
344+
with self.assertRaises(NotImplementedError):
345+
connection.compact_table(name, major=major)
346+
314347

315348
class _Client(object):
316349

gcloud/bigtable/happybase/test_table.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ def test___repr__(self):
8383
table = self._makeOne(name, None)
8484
self.assertEqual(repr(table), '<table.Table name=\'table-name\'>')
8585

86+
def test_regions(self):
87+
name = 'table-name'
88+
connection = None
89+
table = self._makeOne(name, connection)
90+
91+
with self.assertRaises(NotImplementedError):
92+
table.regions()
93+
8694

8795
class _Connection(object):
8896

0 commit comments

Comments
 (0)