forked from SparksFly8/Tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHbase.py
7555 lines (6711 loc) · 235 KB
/
Hbase.py
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
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# Autogenerated by Thrift
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
from thrift.Thrift import *
from .ttypes import *
from thrift.Thrift import TProcessor
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
try:
from thrift.protocol import fastbinary
except:
fastbinary = None
class Iface(object):
def enableTable(self, tableName):
"""
Brings a table on-line (enables it)
@param tableName name of the table
Parameters:
- tableName
"""
pass
def disableTable(self, tableName):
"""
Disables a table (takes it off-line) If it is being served, the master
will tell the servers to stop serving it.
@param tableName name of the table
Parameters:
- tableName
"""
pass
def isTableEnabled(self, tableName):
"""
@param tableName name of table to check
@return true if table is on-line
Parameters:
- tableName
"""
pass
def compact(self, tableNameOrRegionName):
"""
Parameters:
- tableNameOrRegionName
"""
pass
def majorCompact(self, tableNameOrRegionName):
"""
Parameters:
- tableNameOrRegionName
"""
pass
def getTableNames(self, ):
"""
List all the userspace tables.
@return - returns a list of names
"""
pass
def getColumnDescriptors(self, tableName):
"""
List all the column families assoicated with a table.
@param tableName table name
@return list of column family descriptors
Parameters:
- tableName
"""
pass
def getTableRegions(self, tableName):
"""
List the regions associated with a table.
@param tableName table name
@return list of region descriptors
Parameters:
- tableName
"""
pass
def createTable(self, tableName, columnFamilies):
"""
Create a table with the specified column families. The name
field for each ColumnDescriptor must be set and must end in a
colon (:). All other fields are optional and will get default
values if not explicitly specified.
@param tableName name of table to create
@param columnFamilies list of column family descriptors
@throws IllegalArgument if an input parameter is invalid
@throws AlreadyExists if the table name already exists
Parameters:
- tableName
- columnFamilies
"""
pass
def deleteTable(self, tableName):
"""
Deletes a table
@param tableName name of table to delete
@throws IOError if table doesn't exist on server or there was some other
problem
Parameters:
- tableName
"""
pass
def get(self, tableName, row, column):
"""
Get a single TCell for the specified table, row, and column at the
latest timestamp. Returns an empty list if no such value exists.
@param tableName name of table
@param row row key
@param column column name
@return value for specified row/column
Parameters:
- tableName
- row
- column
"""
pass
def getVer(self, tableName, row, column, numVersions):
"""
Get the specified number of versions for the specified table,
row, and column.
@param tableName name of table
@param row row key
@param column column name
@param numVersions number of versions to retrieve
@return list of cells for specified row/column
Parameters:
- tableName
- row
- column
- numVersions
"""
pass
def getVerTs(self, tableName, row, column, timestamp, numVersions):
"""
Get the specified number of versions for the specified table,
row, and column. Only versions less than or equal to the specified
timestamp will be returned.
@param tableName name of table
@param row row key
@param column column name
@param timestamp timestamp
@param numVersions number of versions to retrieve
@return list of cells for specified row/column
Parameters:
- tableName
- row
- column
- timestamp
- numVersions
"""
pass
def getRow(self, tableName, row):
"""
Get all the data for the specified table and row at the latest
timestamp. Returns an empty list if the row does not exist.
@param tableName name of table
@param row row key
@return TRowResult containing the row and map of columns to TCells
Parameters:
- tableName
- row
"""
pass
def getRowWithColumns(self, tableName, row, columns):
"""
Get the specified columns for the specified table and row at the latest
timestamp. Returns an empty list if the row does not exist.
@param tableName name of table
@param row row key
@param columns List of columns to return, null for all columns
@return TRowResult containing the row and map of columns to TCells
Parameters:
- tableName
- row
- columns
"""
pass
def getRowTs(self, tableName, row, timestamp):
"""
Get all the data for the specified table and row at the specified
timestamp. Returns an empty list if the row does not exist.
@param tableName of table
@param row row key
@param timestamp timestamp
@return TRowResult containing the row and map of columns to TCells
Parameters:
- tableName
- row
- timestamp
"""
pass
def getRowWithColumnsTs(self, tableName, row, columns, timestamp):
"""
Get the specified columns for the specified table and row at the specified
timestamp. Returns an empty list if the row does not exist.
@param tableName name of table
@param row row key
@param columns List of columns to return, null for all columns
@return TRowResult containing the row and map of columns to TCells
Parameters:
- tableName
- row
- columns
- timestamp
"""
pass
def mutateRow(self, tableName, row, mutations):
"""
Apply a series of mutations (updates/deletes) to a row in a
single transaction. If an exception is thrown, then the
transaction is aborted. Default current timestamp is used, and
all entries will have an identical timestamp.
@param tableName name of table
@param row row key
@param mutations list of mutation commands
Parameters:
- tableName
- row
- mutations
"""
pass
def mutateRowTs(self, tableName, row, mutations, timestamp):
"""
Apply a series of mutations (updates/deletes) to a row in a
single transaction. If an exception is thrown, then the
transaction is aborted. The specified timestamp is used, and
all entries will have an identical timestamp.
@param tableName name of table
@param row row key
@param mutations list of mutation commands
@param timestamp timestamp
Parameters:
- tableName
- row
- mutations
- timestamp
"""
pass
def mutateRows(self, tableName, rowBatches):
"""
Apply a series of batches (each a series of mutations on a single row)
in a single transaction. If an exception is thrown, then the
transaction is aborted. Default current timestamp is used, and
all entries will have an identical timestamp.
@param tableName name of table
@param rowBatches list of row batches
Parameters:
- tableName
- rowBatches
"""
pass
def mutateRowsTs(self, tableName, rowBatches, timestamp):
"""
Apply a series of batches (each a series of mutations on a single row)
in a single transaction. If an exception is thrown, then the
transaction is aborted. The specified timestamp is used, and
all entries will have an identical timestamp.
@param tableName name of table
@param rowBatches list of row batches
@param timestamp timestamp
Parameters:
- tableName
- rowBatches
- timestamp
"""
pass
def atomicIncrement(self, tableName, row, column, value):
"""
Atomically increment the column value specified. Returns the next value post increment.
@param tableName name of table
@param row row to increment
@param column name of column
@param value amount to increment by
Parameters:
- tableName
- row
- column
- value
"""
pass
def deleteAll(self, tableName, row, column):
"""
Delete all cells that match the passed row and column.
@param tableName name of table
@param row Row to update
@param column name of column whose value is to be deleted
Parameters:
- tableName
- row
- column
"""
pass
def deleteAllTs(self, tableName, row, column, timestamp):
"""
Delete all cells that match the passed row and column and whose
timestamp is equal-to or older than the passed timestamp.
@param tableName name of table
@param row Row to update
@param column name of column whose value is to be deleted
@param timestamp timestamp
Parameters:
- tableName
- row
- column
- timestamp
"""
pass
def deleteAllRow(self, tableName, row):
"""
Completely delete the row's cells.
@param tableName name of table
@param row key of the row to be completely deleted.
Parameters:
- tableName
- row
"""
pass
def deleteAllRowTs(self, tableName, row, timestamp):
"""
Completely delete the row's cells marked with a timestamp
equal-to or older than the passed timestamp.
@param tableName name of table
@param row key of the row to be completely deleted.
@param timestamp timestamp
Parameters:
- tableName
- row
- timestamp
"""
pass
def scannerOpen(self, tableName, startRow, columns):
"""
Get a scanner on the current table starting at the specified row and
ending at the last row in the table. Return the specified columns.
@param columns columns to scan. If column name is a column family, all
columns of the specified column family are returned. Its also possible
to pass a regex in the column qualifier.
@param tableName name of table
@param startRow starting row in table to scan. send "" (empty string) to
start at the first row.
@return scanner id to be used with other scanner procedures
Parameters:
- tableName
- startRow
- columns
"""
pass
def scannerOpenWithStop(self, tableName, startRow, stopRow, columns):
"""
Get a scanner on the current table starting and stopping at the
specified rows. ending at the last row in the table. Return the
specified columns.
@param columns columns to scan. If column name is a column family, all
columns of the specified column family are returned. Its also possible
to pass a regex in the column qualifier.
@param tableName name of table
@param startRow starting row in table to scan. send "" (empty string) to
start at the first row.
@param stopRow row to stop scanning on. This row is *not* included in the
scanner's results
@return scanner id to be used with other scanner procedures
Parameters:
- tableName
- startRow
- stopRow
- columns
"""
pass
def scannerOpenWithPrefix(self, tableName, startAndPrefix, columns):
"""
Open a scanner for a given prefix. That is all rows will have the specified
prefix. No other rows will be returned.
@param tableName name of table
@param startAndPrefix the prefix (and thus start row) of the keys you want
@param columns the columns you want returned
@return scanner id to use with other scanner calls
Parameters:
- tableName
- startAndPrefix
- columns
"""
pass
def scannerOpenTs(self, tableName, startRow, columns, timestamp):
"""
Get a scanner on the current table starting at the specified row and
ending at the last row in the table. Return the specified columns.
Only values with the specified timestamp are returned.
@param columns columns to scan. If column name is a column family, all
columns of the specified column family are returned. Its also possible
to pass a regex in the column qualifier.
@param tableName name of table
@param startRow starting row in table to scan. send "" (empty string) to
start at the first row.
@param timestamp timestamp
@return scanner id to be used with other scanner procedures
Parameters:
- tableName
- startRow
- columns
- timestamp
"""
pass
def scannerOpenWithStopTs(self, tableName, startRow, stopRow, columns, timestamp):
"""
Get a scanner on the current table starting and stopping at the
specified rows. ending at the last row in the table. Return the
specified columns. Only values with the specified timestamp are
returned.
@param columns columns to scan. If column name is a column family, all
columns of the specified column family are returned. Its also possible
to pass a regex in the column qualifier.
@param tableName name of table
@param startRow starting row in table to scan. send "" (empty string) to
start at the first row.
@param stopRow row to stop scanning on. This row is *not* included
in the scanner's results
@param timestamp timestamp
@return scanner id to be used with other scanner procedures
Parameters:
- tableName
- startRow
- stopRow
- columns
- timestamp
"""
pass
def scannerGet(self, id):
"""
Returns the scanner's current row value and advances to the next
row in the table. When there are no more rows in the table, or a key
greater-than-or-equal-to the scanner's specified stopRow is reached,
an empty list is returned.
@param id id of a scanner returned by scannerOpen
@return a TRowResult containing the current row and a map of the columns to TCells.
@throws IllegalArgument if ScannerID is invalid
@throws NotFound when the scanner reaches the end
Parameters:
- id
"""
pass
def scannerGetList(self, id, nbRows):
"""
Returns, starting at the scanner's current row value nbRows worth of
rows and advances to the next row in the table. When there are no more
rows in the table, or a key greater-than-or-equal-to the scanner's
specified stopRow is reached, an empty list is returned.
@param id id of a scanner returned by scannerOpen
@param nbRows number of results to regturn
@return a TRowResult containing the current row and a map of the columns to TCells.
@throws IllegalArgument if ScannerID is invalid
@throws NotFound when the scanner reaches the end
Parameters:
- id
- nbRows
"""
pass
def scannerClose(self, id):
"""
Closes the server-state associated with an open scanner.
@param id id of a scanner returned by scannerOpen
@throws IllegalArgument if ScannerID is invalid
Parameters:
- id
"""
pass
class Client(Iface):
def __init__(self, iprot, oprot=None):
self._iprot = self._oprot = iprot
if oprot != None:
self._oprot = oprot
self._seqid = 0
def enableTable(self, tableName):
"""
Brings a table on-line (enables it)
@param tableName name of the table
Parameters:
- tableName
"""
self.send_enableTable(tableName)
self.recv_enableTable()
def send_enableTable(self, tableName):
self._oprot.writeMessageBegin('enableTable', TMessageType.CALL, self._seqid)
args = enableTable_args()
args.tableName = tableName
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def recv_enableTable(self, ):
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(self._iprot)
self._iprot.readMessageEnd()
raise x
result = enableTable_result()
result.read(self._iprot)
self._iprot.readMessageEnd()
if result.io != None:
raise result.io
return
def disableTable(self, tableName):
"""
Disables a table (takes it off-line) If it is being served, the master
will tell the servers to stop serving it.
@param tableName name of the table
Parameters:
- tableName
"""
self.send_disableTable(tableName)
self.recv_disableTable()
def send_disableTable(self, tableName):
self._oprot.writeMessageBegin('disableTable', TMessageType.CALL, self._seqid)
args = disableTable_args()
args.tableName = tableName
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def recv_disableTable(self, ):
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(self._iprot)
self._iprot.readMessageEnd()
raise x
result = disableTable_result()
result.read(self._iprot)
self._iprot.readMessageEnd()
if result.io != None:
raise result.io
return
def isTableEnabled(self, tableName):
"""
@param tableName name of table to check
@return true if table is on-line
Parameters:
- tableName
"""
self.send_isTableEnabled(tableName)
return self.recv_isTableEnabled()
def send_isTableEnabled(self, tableName):
self._oprot.writeMessageBegin('isTableEnabled', TMessageType.CALL, self._seqid)
args = isTableEnabled_args()
args.tableName = tableName
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def recv_isTableEnabled(self, ):
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(self._iprot)
self._iprot.readMessageEnd()
raise x
result = isTableEnabled_result()
result.read(self._iprot)
self._iprot.readMessageEnd()
if result.success != None:
return result.success
if result.io != None:
raise result.io
raise TApplicationException(TApplicationException.MISSING_RESULT, "isTableEnabled failed: unknown result");
def compact(self, tableNameOrRegionName):
"""
Parameters:
- tableNameOrRegionName
"""
self.send_compact(tableNameOrRegionName)
self.recv_compact()
def send_compact(self, tableNameOrRegionName):
self._oprot.writeMessageBegin('compact', TMessageType.CALL, self._seqid)
args = compact_args()
args.tableNameOrRegionName = tableNameOrRegionName
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def recv_compact(self, ):
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(self._iprot)
self._iprot.readMessageEnd()
raise x
result = compact_result()
result.read(self._iprot)
self._iprot.readMessageEnd()
if result.io != None:
raise result.io
return
def majorCompact(self, tableNameOrRegionName):
"""
Parameters:
- tableNameOrRegionName
"""
self.send_majorCompact(tableNameOrRegionName)
self.recv_majorCompact()
def send_majorCompact(self, tableNameOrRegionName):
self._oprot.writeMessageBegin('majorCompact', TMessageType.CALL, self._seqid)
args = majorCompact_args()
args.tableNameOrRegionName = tableNameOrRegionName
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def recv_majorCompact(self, ):
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(self._iprot)
self._iprot.readMessageEnd()
raise x
result = majorCompact_result()
result.read(self._iprot)
self._iprot.readMessageEnd()
if result.io != None:
raise result.io
return
def getTableNames(self, ):
"""
List all the userspace tables.
@return - returns a list of names
"""
self.send_getTableNames()
return self.recv_getTableNames()
def send_getTableNames(self, ):
self._oprot.writeMessageBegin('getTableNames', TMessageType.CALL, self._seqid)
args = getTableNames_args()
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def recv_getTableNames(self, ):
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(self._iprot)
self._iprot.readMessageEnd()
raise x
result = getTableNames_result()
result.read(self._iprot)
self._iprot.readMessageEnd()
if result.success != None:
return result.success
if result.io != None:
raise result.io
raise TApplicationException(TApplicationException.MISSING_RESULT, "getTableNames failed: unknown result");
def getColumnDescriptors(self, tableName):
"""
List all the column families assoicated with a table.
@param tableName table name
@return list of column family descriptors
Parameters:
- tableName
"""
self.send_getColumnDescriptors(tableName)
return self.recv_getColumnDescriptors()
def send_getColumnDescriptors(self, tableName):
self._oprot.writeMessageBegin('getColumnDescriptors', TMessageType.CALL, self._seqid)
args = getColumnDescriptors_args()
args.tableName = tableName
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def recv_getColumnDescriptors(self, ):
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(self._iprot)
self._iprot.readMessageEnd()
raise x
result = getColumnDescriptors_result()
result.read(self._iprot)
self._iprot.readMessageEnd()
if result.success != None:
return result.success
if result.io != None:
raise result.io
raise TApplicationException(TApplicationException.MISSING_RESULT, "getColumnDescriptors failed: unknown result");
def getTableRegions(self, tableName):
"""
List the regions associated with a table.
@param tableName table name
@return list of region descriptors
Parameters:
- tableName
"""
self.send_getTableRegions(tableName)
return self.recv_getTableRegions()
def send_getTableRegions(self, tableName):
self._oprot.writeMessageBegin('getTableRegions', TMessageType.CALL, self._seqid)
args = getTableRegions_args()
args.tableName = tableName
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def recv_getTableRegions(self, ):
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(self._iprot)
self._iprot.readMessageEnd()
raise x
result = getTableRegions_result()
result.read(self._iprot)
self._iprot.readMessageEnd()
if result.success != None:
return result.success
if result.io != None:
raise result.io
raise TApplicationException(TApplicationException.MISSING_RESULT, "getTableRegions failed: unknown result");
def createTable(self, tableName, columnFamilies):
"""
Create a table with the specified column families. The name
field for each ColumnDescriptor must be set and must end in a
colon (:). All other fields are optional and will get default
values if not explicitly specified.
@param tableName name of table to create
@param columnFamilies list of column family descriptors
@throws IllegalArgument if an input parameter is invalid
@throws AlreadyExists if the table name already exists
Parameters:
- tableName
- columnFamilies
"""
self.send_createTable(tableName, columnFamilies)
self.recv_createTable()
def send_createTable(self, tableName, columnFamilies):
self._oprot.writeMessageBegin('createTable', TMessageType.CALL, self._seqid)
args = createTable_args()
args.tableName = tableName
args.columnFamilies = columnFamilies
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def recv_createTable(self, ):
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(self._iprot)
self._iprot.readMessageEnd()
raise x
result = createTable_result()
result.read(self._iprot)
self._iprot.readMessageEnd()
if result.io != None:
raise result.io
if result.ia != None:
raise result.ia
if result.exist != None:
raise result.exist
return
def deleteTable(self, tableName):
"""
Deletes a table
@param tableName name of table to delete
@throws IOError if table doesn't exist on server or there was some other
problem
Parameters:
- tableName
"""
self.send_deleteTable(tableName)
self.recv_deleteTable()
def send_deleteTable(self, tableName):
self._oprot.writeMessageBegin('deleteTable', TMessageType.CALL, self._seqid)
args = deleteTable_args()
args.tableName = tableName
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def recv_deleteTable(self, ):
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(self._iprot)
self._iprot.readMessageEnd()
raise x
result = deleteTable_result()
result.read(self._iprot)
self._iprot.readMessageEnd()
if result.io != None:
raise result.io
return
def get(self, tableName, row, column):
"""
Get a single TCell for the specified table, row, and column at the
latest timestamp. Returns an empty list if no such value exists.
@param tableName name of table
@param row row key
@param column column name
@return value for specified row/column
Parameters:
- tableName
- row
- column
"""
self.send_get(tableName, row, column)
return self.recv_get()
def send_get(self, tableName, row, column):
self._oprot.writeMessageBegin('get', TMessageType.CALL, self._seqid)
args = get_args()
args.tableName = tableName
args.row = row
args.column = column
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def recv_get(self, ):
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(self._iprot)
self._iprot.readMessageEnd()
raise x
result = get_result()
result.read(self._iprot)
self._iprot.readMessageEnd()
if result.success != None:
return result.success
if result.io != None:
raise result.io
raise TApplicationException(TApplicationException.MISSING_RESULT, "get failed: unknown result");
def getVer(self, tableName, row, column, numVersions):
"""
Get the specified number of versions for the specified table,
row, and column.
@param tableName name of table
@param row row key
@param column column name
@param numVersions number of versions to retrieve
@return list of cells for specified row/column
Parameters:
- tableName
- row
- column
- numVersions
"""
self.send_getVer(tableName, row, column, numVersions)
return self.recv_getVer()
def send_getVer(self, tableName, row, column, numVersions):
self._oprot.writeMessageBegin('getVer', TMessageType.CALL, self._seqid)
args = getVer_args()
args.tableName = tableName
args.row = row
args.column = column
args.numVersions = numVersions
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def recv_getVer(self, ):
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(self._iprot)
self._iprot.readMessageEnd()
raise x
result = getVer_result()
result.read(self._iprot)