forked from googleapis/google-cloud-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_table.py
More file actions
759 lines (588 loc) · 25.4 KB
/
test_table.py
File metadata and controls
759 lines (588 loc) · 25.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
# Copyright 2015 Google Inc.
#
# 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 unittest
import mock
class Test___mutate_rows_request(unittest.TestCase):
def _call_fut(self, table_name, rows):
from google.cloud.bigtable.table import _mutate_rows_request
return _mutate_rows_request(table_name, rows)
@mock.patch('google.cloud.bigtable.table._MAX_BULK_MUTATIONS', new=3)
def test__mutate_rows_too_many_mutations(self):
from google.cloud.bigtable.row import DirectRow
from google.cloud.bigtable.table import TooManyMutationsError
table = mock.Mock(name='table', spec=['name'])
table.name = 'table'
rows = [DirectRow(row_key=b'row_key', table=table),
DirectRow(row_key=b'row_key_2', table=table)]
rows[0].set_cell('cf1', b'c1', 1)
rows[0].set_cell('cf1', b'c1', 2)
rows[1].set_cell('cf1', b'c1', 3)
rows[1].set_cell('cf1', b'c1', 4)
with self.assertRaises(TooManyMutationsError):
self._call_fut('table', rows)
def test__mutate_rows_request(self):
from google.cloud.bigtable.row import DirectRow
table = mock.Mock(name='table', spec=['name'])
table.name = 'table'
rows = [DirectRow(row_key=b'row_key', table=table),
DirectRow(row_key=b'row_key_2', table=table)]
rows[0].set_cell('cf1', b'c1', b'1')
rows[1].set_cell('cf1', b'c1', b'2')
result = self._call_fut('table', rows)
expected_result = _mutate_rows_request_pb(table_name='table')
entry1 = expected_result.entries.add()
entry1.row_key = b'row_key'
mutations1 = entry1.mutations.add()
mutations1.set_cell.family_name = 'cf1'
mutations1.set_cell.column_qualifier = b'c1'
mutations1.set_cell.timestamp_micros = -1
mutations1.set_cell.value = b'1'
entry2 = expected_result.entries.add()
entry2.row_key = b'row_key_2'
mutations2 = entry2.mutations.add()
mutations2.set_cell.family_name = 'cf1'
mutations2.set_cell.column_qualifier = b'c1'
mutations2.set_cell.timestamp_micros = -1
mutations2.set_cell.value = b'2'
self.assertEqual(result, expected_result)
class Test__check_row_table_name(unittest.TestCase):
def _call_fut(self, table_name, row):
from google.cloud.bigtable.table import _check_row_table_name
return _check_row_table_name(table_name, row)
def test_wrong_table_name(self):
from google.cloud.bigtable.table import TableMismatchError
from google.cloud.bigtable.row import DirectRow
table = mock.Mock(name='table', spec=['name'])
table.name = 'table'
row = DirectRow(row_key=b'row_key', table=table)
with self.assertRaises(TableMismatchError):
self._call_fut('other_table', row)
def test_right_table_name(self):
from google.cloud.bigtable.row import DirectRow
table = mock.Mock(name='table', spec=['name'])
table.name = 'table'
row = DirectRow(row_key=b'row_key', table=table)
result = self._call_fut('table', row)
self.assertFalse(result)
class Test__check_row_type(unittest.TestCase):
def _call_fut(self, row):
from google.cloud.bigtable.table import _check_row_type
return _check_row_type(row)
def test_test_wrong_row_type(self):
from google.cloud.bigtable.row import ConditionalRow
row = ConditionalRow(row_key=b'row_key', table='table', filter_=None)
with self.assertRaises(TypeError):
self._call_fut(row)
def test_right_row_type(self):
from google.cloud.bigtable.row import DirectRow
row = DirectRow(row_key=b'row_key', table='table')
result = self._call_fut(row)
self.assertFalse(result)
class TestTable(unittest.TestCase):
PROJECT_ID = 'project-id'
INSTANCE_ID = 'instance-id'
INSTANCE_NAME = ('projects/' + PROJECT_ID + '/instances/' + INSTANCE_ID)
TABLE_ID = 'table-id'
TABLE_NAME = INSTANCE_NAME + '/tables/' + TABLE_ID
ROW_KEY = b'row-key'
FAMILY_NAME = u'family'
QUALIFIER = b'qualifier'
TIMESTAMP_MICROS = 100
VALUE = b'value'
@staticmethod
def _get_target_class():
from google.cloud.bigtable.table import Table
return Table
def _make_one(self, *args, **kwargs):
return self._get_target_class()(*args, **kwargs)
def test_constructor(self):
table_id = 'table-id'
instance = object()
table = self._make_one(table_id, instance)
self.assertEqual(table.table_id, table_id)
self.assertIs(table._instance, instance)
def test_name_property(self):
table_id = 'table-id'
instance_name = 'instance_name'
instance = _Instance(instance_name)
table = self._make_one(table_id, instance)
expected_name = instance_name + '/tables/' + table_id
self.assertEqual(table.name, expected_name)
def test_column_family_factory(self):
from google.cloud.bigtable.column_family import ColumnFamily
table_id = 'table-id'
gc_rule = object()
table = self._make_one(table_id, None)
column_family_id = 'column_family_id'
column_family = table.column_family(column_family_id, gc_rule=gc_rule)
self.assertIsInstance(column_family, ColumnFamily)
self.assertEqual(column_family.column_family_id, column_family_id)
self.assertIs(column_family.gc_rule, gc_rule)
self.assertEqual(column_family._table, table)
def test_row_factory_direct(self):
from google.cloud.bigtable.row import DirectRow
table_id = 'table-id'
table = self._make_one(table_id, None)
row_key = b'row_key'
row = table.row(row_key)
self.assertIsInstance(row, DirectRow)
self.assertEqual(row._row_key, row_key)
self.assertEqual(row._table, table)
def test_row_factory_conditional(self):
from google.cloud.bigtable.row import ConditionalRow
table_id = 'table-id'
table = self._make_one(table_id, None)
row_key = b'row_key'
filter_ = object()
row = table.row(row_key, filter_=filter_)
self.assertIsInstance(row, ConditionalRow)
self.assertEqual(row._row_key, row_key)
self.assertEqual(row._table, table)
def test_row_factory_append(self):
from google.cloud.bigtable.row import AppendRow
table_id = 'table-id'
table = self._make_one(table_id, None)
row_key = b'row_key'
row = table.row(row_key, append=True)
self.assertIsInstance(row, AppendRow)
self.assertEqual(row._row_key, row_key)
self.assertEqual(row._table, table)
def test_row_factory_failure(self):
table = self._make_one(self.TABLE_ID, None)
with self.assertRaises(ValueError):
table.row(b'row_key', filter_=object(), append=True)
def test___eq__(self):
instance = object()
table1 = self._make_one(self.TABLE_ID, instance)
table2 = self._make_one(self.TABLE_ID, instance)
self.assertEqual(table1, table2)
def test___eq__type_differ(self):
table1 = self._make_one(self.TABLE_ID, None)
table2 = object()
self.assertNotEqual(table1, table2)
def test___ne__same_value(self):
instance = object()
table1 = self._make_one(self.TABLE_ID, instance)
table2 = self._make_one(self.TABLE_ID, instance)
comparison_val = (table1 != table2)
self.assertFalse(comparison_val)
def test___ne__(self):
table1 = self._make_one('table_id1', 'instance1')
table2 = self._make_one('table_id2', 'instance2')
self.assertNotEqual(table1, table2)
def _create_test_helper(self, initial_split_keys, column_families=()):
from google.cloud._helpers import _to_bytes
from tests.unit._testing import _FakeStub
client = _Client()
instance = _Instance(self.INSTANCE_NAME, client=client)
table = self._make_one(self.TABLE_ID, instance)
# Create request_pb
splits_pb = [
_CreateTableRequestSplitPB(key=_to_bytes(key))
for key in initial_split_keys or ()]
table_pb = None
if column_families:
table_pb = _TablePB()
for cf in column_families:
cf_pb = table_pb.column_families[cf.column_family_id]
if cf.gc_rule is not None:
cf_pb.gc_rule.CopyFrom(cf.gc_rule.to_pb())
request_pb = _CreateTableRequestPB(
initial_splits=splits_pb,
parent=self.INSTANCE_NAME,
table_id=self.TABLE_ID,
table=table_pb,
)
# Create response_pb
response_pb = _TablePB()
# Patch the stub used by the API method.
client._table_stub = stub = _FakeStub(response_pb)
# Create expected_result.
expected_result = None # create() has no return value.
# Perform the method and check the result.
result = table.create(initial_split_keys=initial_split_keys,
column_families=column_families)
self.assertEqual(result, expected_result)
self.assertEqual(stub.method_calls, [(
'CreateTable',
(request_pb,),
{},
)])
def test_create(self):
initial_split_keys = None
self._create_test_helper(initial_split_keys)
def test_create_with_split_keys(self):
initial_split_keys = [b's1', b's2']
self._create_test_helper(initial_split_keys)
def test_create_with_column_families(self):
from google.cloud.bigtable.column_family import ColumnFamily
from google.cloud.bigtable.column_family import MaxVersionsGCRule
cf_id1 = 'col-fam-id1'
cf1 = ColumnFamily(cf_id1, None)
cf_id2 = 'col-fam-id2'
gc_rule = MaxVersionsGCRule(42)
cf2 = ColumnFamily(cf_id2, None, gc_rule=gc_rule)
initial_split_keys = None
column_families = [cf1, cf2]
self._create_test_helper(initial_split_keys,
column_families=column_families)
def _list_column_families_helper(self):
from tests.unit._testing import _FakeStub
client = _Client()
instance = _Instance(self.INSTANCE_NAME, client=client)
table = self._make_one(self.TABLE_ID, instance)
# Create request_pb
request_pb = _GetTableRequestPB(name=self.TABLE_NAME)
# Create response_pb
COLUMN_FAMILY_ID = 'foo'
column_family = _ColumnFamilyPB()
response_pb = _TablePB(
column_families={COLUMN_FAMILY_ID: column_family},
)
# Patch the stub used by the API method.
client._table_stub = stub = _FakeStub(response_pb)
# Create expected_result.
expected_result = {
COLUMN_FAMILY_ID: table.column_family(COLUMN_FAMILY_ID),
}
# Perform the method and check the result.
result = table.list_column_families()
self.assertEqual(result, expected_result)
self.assertEqual(stub.method_calls, [(
'GetTable',
(request_pb,),
{},
)])
def test_list_column_families(self):
self._list_column_families_helper()
def test_delete(self):
from google.protobuf import empty_pb2
from tests.unit._testing import _FakeStub
client = _Client()
instance = _Instance(self.INSTANCE_NAME, client=client)
table = self._make_one(self.TABLE_ID, instance)
# Create request_pb
request_pb = _DeleteTableRequestPB(name=self.TABLE_NAME)
# Create response_pb
response_pb = empty_pb2.Empty()
# Patch the stub used by the API method.
client._table_stub = stub = _FakeStub(response_pb)
# Create expected_result.
expected_result = None # delete() has no return value.
# Perform the method and check the result.
result = table.delete()
self.assertEqual(result, expected_result)
self.assertEqual(stub.method_calls, [(
'DeleteTable',
(request_pb,),
{},
)])
def _read_row_helper(self, chunks, expected_result):
from google.cloud._testing import _Monkey
from tests.unit._testing import _FakeStub
from google.cloud.bigtable import table as MUT
client = _Client()
instance = _Instance(self.INSTANCE_NAME, client=client)
table = self._make_one(self.TABLE_ID, instance)
# Create request_pb
request_pb = object() # Returned by our mock.
mock_created = []
def mock_create_row_request(table_name, row_key, filter_):
mock_created.append((table_name, row_key, filter_))
return request_pb
# Create response_iterator
if chunks is None:
response_iterator = iter(()) # no responses at all
else:
response_pb = _ReadRowsResponsePB(chunks=chunks)
response_iterator = iter([response_pb])
# Patch the stub used by the API method.
client._data_stub = stub = _FakeStub(response_iterator)
# Perform the method and check the result.
filter_obj = object()
with _Monkey(MUT, _create_row_request=mock_create_row_request):
result = table.read_row(self.ROW_KEY, filter_=filter_obj)
self.assertEqual(result, expected_result)
self.assertEqual(stub.method_calls, [(
'ReadRows',
(request_pb,),
{},
)])
self.assertEqual(mock_created,
[(table.name, self.ROW_KEY, filter_obj)])
def test_read_row_miss_no__responses(self):
self._read_row_helper(None, None)
def test_read_row_miss_no_chunks_in_response(self):
chunks = []
self._read_row_helper(chunks, None)
def test_read_row_complete(self):
from google.cloud.bigtable.row_data import Cell
from google.cloud.bigtable.row_data import PartialRowData
chunk = _ReadRowsResponseCellChunkPB(
row_key=self.ROW_KEY,
family_name=self.FAMILY_NAME,
qualifier=self.QUALIFIER,
timestamp_micros=self.TIMESTAMP_MICROS,
value=self.VALUE,
commit_row=True,
)
chunks = [chunk]
expected_result = PartialRowData(row_key=self.ROW_KEY)
family = expected_result._cells.setdefault(self.FAMILY_NAME, {})
column = family.setdefault(self.QUALIFIER, [])
column.append(Cell.from_pb(chunk))
self._read_row_helper(chunks, expected_result)
def test_read_row_still_partial(self):
chunk = _ReadRowsResponseCellChunkPB(
row_key=self.ROW_KEY,
family_name=self.FAMILY_NAME,
qualifier=self.QUALIFIER,
timestamp_micros=self.TIMESTAMP_MICROS,
value=self.VALUE,
)
# No "commit row".
chunks = [chunk]
with self.assertRaises(ValueError):
self._read_row_helper(chunks, None)
def test_mutate_rows(self):
from google.cloud.bigtable._generated.bigtable_pb2 import (
MutateRowsResponse)
from google.cloud.bigtable.row import DirectRow
from google.rpc.status_pb2 import Status
from tests.unit._testing import _FakeStub
client = _Client()
instance = _Instance(self.INSTANCE_NAME, client=client)
table = self._make_one(self.TABLE_ID, instance)
row_1 = DirectRow(row_key=b'row_key', table=table)
row_1.set_cell('cf', b'col', b'value1')
row_2 = DirectRow(row_key=b'row_key_2', table=table)
row_2.set_cell('cf', b'col', b'value2')
response = MutateRowsResponse(
entries=[
MutateRowsResponse.Entry(
index=0,
status=Status(code=0),
),
MutateRowsResponse.Entry(
index=1,
status=Status(code=1),
),
],
)
# Patch the stub used by the API method.
client._data_stub = _FakeStub([response])
statuses = table.mutate_rows([row_1, row_2])
result = [status.code for status in statuses]
expected_result = [0, 1]
self.assertEqual(result, expected_result)
def test_read_rows(self):
from google.cloud._testing import _Monkey
from tests.unit._testing import _FakeStub
from google.cloud.bigtable.row_data import PartialRowsData
from google.cloud.bigtable import table as MUT
client = _Client()
instance = _Instance(self.INSTANCE_NAME, client=client)
table = self._make_one(self.TABLE_ID, instance)
# Create request_pb
request_pb = object() # Returned by our mock.
mock_created = []
def mock_create_row_request(table_name, **kwargs):
mock_created.append((table_name, kwargs))
return request_pb
# Create response_iterator
response_iterator = object()
# Patch the stub used by the API method.
client._data_stub = stub = _FakeStub(response_iterator)
# Create expected_result.
expected_result = PartialRowsData(response_iterator)
# Perform the method and check the result.
start_key = b'start-key'
end_key = b'end-key'
filter_obj = object()
limit = 22
with _Monkey(MUT, _create_row_request=mock_create_row_request):
result = table.read_rows(
start_key=start_key, end_key=end_key, filter_=filter_obj,
limit=limit)
self.assertEqual(result, expected_result)
self.assertEqual(stub.method_calls, [(
'ReadRows',
(request_pb,),
{},
)])
created_kwargs = {
'start_key': start_key,
'end_key': end_key,
'filter_': filter_obj,
'limit': limit,
'end_inclusive': False,
}
self.assertEqual(mock_created, [(table.name, created_kwargs)])
def test_sample_row_keys(self):
from tests.unit._testing import _FakeStub
client = _Client()
instance = _Instance(self.INSTANCE_NAME, client=client)
table = self._make_one(self.TABLE_ID, instance)
# Create request_pb
request_pb = _SampleRowKeysRequestPB(table_name=self.TABLE_NAME)
# Create response_iterator
response_iterator = object() # Just passed to a mock.
# Patch the stub used by the API method.
client._data_stub = stub = _FakeStub(response_iterator)
# Create expected_result.
expected_result = response_iterator
# Perform the method and check the result.
result = table.sample_row_keys()
self.assertEqual(result, expected_result)
self.assertEqual(stub.method_calls, [(
'SampleRowKeys',
(request_pb,),
{},
)])
class Test__create_row_request(unittest.TestCase):
def _call_fut(self, table_name, row_key=None, start_key=None, end_key=None,
filter_=None, limit=None, end_inclusive=False):
from google.cloud.bigtable.table import _create_row_request
return _create_row_request(
table_name, row_key=row_key, start_key=start_key, end_key=end_key,
filter_=filter_, limit=limit, end_inclusive=end_inclusive)
def test_table_name_only(self):
table_name = 'table_name'
result = self._call_fut(table_name)
expected_result = _ReadRowsRequestPB(
table_name=table_name)
self.assertEqual(result, expected_result)
def test_row_key_row_range_conflict(self):
with self.assertRaises(ValueError):
self._call_fut(None, row_key=object(), end_key=object())
def test_row_key(self):
table_name = 'table_name'
row_key = b'row_key'
result = self._call_fut(table_name, row_key=row_key)
expected_result = _ReadRowsRequestPB(
table_name=table_name,
)
expected_result.rows.row_keys.append(row_key)
self.assertEqual(result, expected_result)
def test_row_range_start_key(self):
table_name = 'table_name'
start_key = b'start_key'
result = self._call_fut(table_name, start_key=start_key)
expected_result = _ReadRowsRequestPB(table_name=table_name)
expected_result.rows.row_ranges.add(start_key_closed=start_key)
self.assertEqual(result, expected_result)
def test_row_range_end_key(self):
table_name = 'table_name'
end_key = b'end_key'
result = self._call_fut(table_name, end_key=end_key)
expected_result = _ReadRowsRequestPB(table_name=table_name)
expected_result.rows.row_ranges.add(end_key_open=end_key)
self.assertEqual(result, expected_result)
def test_row_range_both_keys(self):
table_name = 'table_name'
start_key = b'start_key'
end_key = b'end_key'
result = self._call_fut(table_name, start_key=start_key,
end_key=end_key)
expected_result = _ReadRowsRequestPB(table_name=table_name)
expected_result.rows.row_ranges.add(
start_key_closed=start_key, end_key_open=end_key)
self.assertEqual(result, expected_result)
def test_row_range_both_keys_inclusive(self):
table_name = 'table_name'
start_key = b'start_key'
end_key = b'end_key'
result = self._call_fut(table_name, start_key=start_key,
end_key=end_key, end_inclusive=True)
expected_result = _ReadRowsRequestPB(table_name=table_name)
expected_result.rows.row_ranges.add(
start_key_closed=start_key, end_key_closed=end_key)
self.assertEqual(result, expected_result)
def test_with_filter(self):
from google.cloud.bigtable.row_filters import RowSampleFilter
table_name = 'table_name'
row_filter = RowSampleFilter(0.33)
result = self._call_fut(table_name, filter_=row_filter)
expected_result = _ReadRowsRequestPB(
table_name=table_name,
filter=row_filter.to_pb(),
)
self.assertEqual(result, expected_result)
def test_with_limit(self):
table_name = 'table_name'
limit = 1337
result = self._call_fut(table_name, limit=limit)
expected_result = _ReadRowsRequestPB(
table_name=table_name,
rows_limit=limit,
)
self.assertEqual(result, expected_result)
def _CreateTableRequestPB(*args, **kw):
from google.cloud.bigtable._generated import (
bigtable_table_admin_pb2 as table_admin_v2_pb2)
return table_admin_v2_pb2.CreateTableRequest(*args, **kw)
def _CreateTableRequestSplitPB(*args, **kw):
from google.cloud.bigtable._generated import (
bigtable_table_admin_pb2 as table_admin_v2_pb2)
return table_admin_v2_pb2.CreateTableRequest.Split(*args, **kw)
def _DeleteTableRequestPB(*args, **kw):
from google.cloud.bigtable._generated import (
bigtable_table_admin_pb2 as table_admin_v2_pb2)
return table_admin_v2_pb2.DeleteTableRequest(*args, **kw)
def _GetTableRequestPB(*args, **kw):
from google.cloud.bigtable._generated import (
bigtable_table_admin_pb2 as table_admin_v2_pb2)
return table_admin_v2_pb2.GetTableRequest(*args, **kw)
def _ReadRowsRequestPB(*args, **kw):
from google.cloud.bigtable._generated import (
bigtable_pb2 as messages_v2_pb2)
return messages_v2_pb2.ReadRowsRequest(*args, **kw)
def _ReadRowsResponseCellChunkPB(*args, **kw):
from google.cloud.bigtable._generated import (
bigtable_pb2 as messages_v2_pb2)
family_name = kw.pop('family_name')
qualifier = kw.pop('qualifier')
message = messages_v2_pb2.ReadRowsResponse.CellChunk(*args, **kw)
message.family_name.value = family_name
message.qualifier.value = qualifier
return message
def _ReadRowsResponsePB(*args, **kw):
from google.cloud.bigtable._generated import (
bigtable_pb2 as messages_v2_pb2)
return messages_v2_pb2.ReadRowsResponse(*args, **kw)
def _SampleRowKeysRequestPB(*args, **kw):
from google.cloud.bigtable._generated import (
bigtable_pb2 as messages_v2_pb2)
return messages_v2_pb2.SampleRowKeysRequest(*args, **kw)
def _mutate_rows_request_pb(*args, **kw):
from google.cloud.bigtable._generated import (
bigtable_pb2 as data_messages_v2_pb2)
return data_messages_v2_pb2.MutateRowsRequest(*args, **kw)
def _TablePB(*args, **kw):
from google.cloud.bigtable._generated import (
table_pb2 as table_v2_pb2)
return table_v2_pb2.Table(*args, **kw)
def _ColumnFamilyPB(*args, **kw):
from google.cloud.bigtable._generated import (
table_pb2 as table_v2_pb2)
return table_v2_pb2.ColumnFamily(*args, **kw)
class _Client(object):
data_stub = None
instance_stub = None
operations_stub = None
table_stub = None
class _Instance(object):
def __init__(self, name, client=None):
self.name = name
self._client = client