forked from sunmi-OS/gocore
/
thbaseservice.go
9436 lines (8712 loc) · 271 KB
/
thbaseservice.go
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 Compiler (0.9.3)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
package hbase
import (
"bytes"
"fmt"
"git.apache.org/thrift.git/lib/go/thrift"
)
// (needed to ensure safety because of naive import list construction.)
var _ = thrift.ZERO
var _ = fmt.Printf
var _ = bytes.Equal
type THBaseService interface {
// Test for the existence of columns in the table, as specified in the TGet.
//
// @return true if the specified TGet matches one or more keys, false if not
//
// Parameters:
// - Table: the table to check on
// - Tget: the TGet to check for
Exists(table []byte, tget *TGet) (r bool, err error)
// Test for the existence of columns in the table, as specified by the TGets.
//
// This will return an array of booleans. Each value will be true if the related Get matches
// one or more keys, false if not.
//
// Parameters:
// - Table: the table to check on
// - Tgets: a list of TGets to check for
ExistsAll(table []byte, tgets []*TGet) (r []bool, err error)
// Method for getting data from a row.
//
// If the row cannot be found an empty Result is returned.
// This can be checked by the empty field of the TResult
//
// @return the result
//
// Parameters:
// - Table: the table to get from
// - Tget: the TGet to fetch
Get(table []byte, tget *TGet) (r *TResult_, err error)
// Method for getting multiple rows.
//
// If a row cannot be found there will be a null
// value in the result list for that TGet at the
// same position.
//
// So the Results are in the same order as the TGets.
//
// Parameters:
// - Table: the table to get from
// - Tgets: a list of TGets to fetch, the Result list
// will have the Results at corresponding positions
// or null if there was an error
GetMultiple(table []byte, tgets []*TGet) (r []*TResult_, err error)
// Commit a TPut to a table.
//
// Parameters:
// - Table: the table to put data in
// - Tput: the TPut to put
Put(table []byte, tput *TPut) (err error)
// Atomically checks if a row/family/qualifier value matches the expected
// value. If it does, it adds the TPut.
//
// @return true if the new put was executed, false otherwise
//
// Parameters:
// - Table: to check in and put to
// - Row: row to check
// - Family: column family to check
// - Qualifier: column qualifier to check
// - Value: the expected value, if not provided the
// check is for the non-existence of the
// column in question
// - Tput: the TPut to put if the check succeeds
CheckAndPut(table []byte, row []byte, family []byte, qualifier []byte, value []byte, tput *TPut) (r bool, err error)
// Commit a List of Puts to the table.
//
// Parameters:
// - Table: the table to put data in
// - Tputs: a list of TPuts to commit
PutMultiple(table []byte, tputs []*TPut) (err error)
// Deletes as specified by the TDelete.
//
// Note: "delete" is a reserved keyword and cannot be used in Thrift
// thus the inconsistent naming scheme from the other functions.
//
// Parameters:
// - Table: the table to delete from
// - Tdelete: the TDelete to delete
DeleteSingle(table []byte, tdelete *TDelete) (err error)
// Bulk commit a List of TDeletes to the table.
//
// Throws a TIOError if any of the deletes fail.
//
// Always returns an empty list for backwards compatibility.
//
// Parameters:
// - Table: the table to delete from
// - Tdeletes: list of TDeletes to delete
DeleteMultiple(table []byte, tdeletes []*TDelete) (r []*TDelete, err error)
// Atomically checks if a row/family/qualifier value matches the expected
// value. If it does, it adds the delete.
//
// @return true if the new delete was executed, false otherwise
//
// Parameters:
// - Table: to check in and delete from
// - Row: row to check
// - Family: column family to check
// - Qualifier: column qualifier to check
// - Value: the expected value, if not provided the
// check is for the non-existence of the
// column in question
// - Tdelete: the TDelete to execute if the check succeeds
CheckAndDelete(table []byte, row []byte, family []byte, qualifier []byte, value []byte, tdelete *TDelete) (r bool, err error)
// Parameters:
// - Table: the table to increment the value on
// - Tincrement: the TIncrement to increment
Increment(table []byte, tincrement *TIncrement) (r *TResult_, err error)
// Parameters:
// - Table: the table to append the value on
// - Tappend: the TAppend to append
Append(table []byte, tappend *TAppend) (r *TResult_, err error)
// Get a Scanner for the provided TScan object.
//
// @return Scanner Id to be used with other scanner procedures
//
// Parameters:
// - Table: the table to get the Scanner for
// - Tscan: the scan object to get a Scanner for
OpenScanner(table []byte, tscan *TScan) (r int32, err error)
// Grabs multiple rows from a Scanner.
//
// @return Between zero and numRows TResults
//
// Parameters:
// - ScannerId: the Id of the Scanner to return rows from. This is an Id returned from the openScanner function.
// - NumRows: number of rows to return
GetScannerRows(scannerId int32, numRows int32) (r []*TResult_, err error)
// Closes the scanner. Should be called to free server side resources timely.
// Typically close once the scanner is not needed anymore, i.e. after looping
// over it to get all the required rows.
//
// Parameters:
// - ScannerId: the Id of the Scanner to close *
CloseScanner(scannerId int32) (err error)
// mutateRow performs multiple mutations atomically on a single row.
//
// Parameters:
// - Table: table to apply the mutations
// - TrowMutations: mutations to apply
MutateRow(table []byte, trowMutations *TRowMutations) (err error)
// Get results for the provided TScan object.
// This helper function opens a scanner, get the results and close the scanner.
//
// @return between zero and numRows TResults
//
// Parameters:
// - Table: the table to get the Scanner for
// - Tscan: the scan object to get a Scanner for
// - NumRows: number of rows to return
GetScannerResults(table []byte, tscan *TScan, numRows int32) (r []*TResult_, err error)
// Given a table and a row get the location of the region that
// would contain the given row key.
//
// reload = true means the cache will be cleared and the location
// will be fetched from meta.
//
// Parameters:
// - Table
// - Row
// - Reload
GetRegionLocation(table []byte, row []byte, reload bool) (r *THRegionLocation, err error)
// Get all of the region locations for a given table.
//
//
// Parameters:
// - Table
GetAllRegionLocations(table []byte) (r []*THRegionLocation, err error)
// Atomically checks if a row/family/qualifier value matches the expected
// value. If it does, it mutates the row.
//
// @return true if the row was mutated, false otherwise
//
// Parameters:
// - Table: to check in and delete from
// - Row: row to check
// - Family: column family to check
// - Qualifier: column qualifier to check
// - CompareOp: comparison to make on the value
// - Value: the expected value to be compared against, if not provided the
// check is for the non-existence of the column in question
// - RowMutations: row mutations to execute if the value matches
CheckAndMutate(table []byte, row []byte, family []byte, qualifier []byte, compareOp TCompareOp, value []byte, rowMutations *TRowMutations) (r bool, err error)
}
type THBaseServiceClient struct {
Transport thrift.TTransport
ProtocolFactory thrift.TProtocolFactory
InputProtocol thrift.TProtocol
OutputProtocol thrift.TProtocol
SeqId int32
}
func NewTHBaseServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *THBaseServiceClient {
return &THBaseServiceClient{Transport: t,
ProtocolFactory: f,
InputProtocol: f.GetProtocol(t),
OutputProtocol: f.GetProtocol(t),
SeqId: 0,
}
}
func NewTHBaseServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *THBaseServiceClient {
return &THBaseServiceClient{Transport: t,
ProtocolFactory: nil,
InputProtocol: iprot,
OutputProtocol: oprot,
SeqId: 0,
}
}
// Test for the existence of columns in the table, as specified in the TGet.
//
// @return true if the specified TGet matches one or more keys, false if not
//
// Parameters:
// - Table: the table to check on
// - Tget: the TGet to check for
func (p *THBaseServiceClient) Exists(table []byte, tget *TGet) (r bool, err error) {
if err = p.sendExists(table, tget); err != nil {
return
}
return p.recvExists()
}
func (p *THBaseServiceClient) sendExists(table []byte, tget *TGet) (err error) {
oprot := p.OutputProtocol
if oprot == nil {
oprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.OutputProtocol = oprot
}
p.SeqId++
if err = oprot.WriteMessageBegin("exists", thrift.CALL, p.SeqId); err != nil {
return
}
args := THBaseServiceExistsArgs{
Table: table,
Tget: tget,
}
if err = args.Write(oprot); err != nil {
return
}
if err = oprot.WriteMessageEnd(); err != nil {
return
}
return oprot.Flush()
}
func (p *THBaseServiceClient) recvExists() (value bool, err error) {
iprot := p.InputProtocol
if iprot == nil {
iprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.InputProtocol = iprot
}
method, mTypeId, seqId, err := iprot.ReadMessageBegin()
if err != nil {
return
}
if method != "exists" {
err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "exists failed: wrong method name")
return
}
if p.SeqId != seqId {
err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "exists failed: out of sequence response")
return
}
if mTypeId == thrift.EXCEPTION {
error23 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
var error24 error
error24, err = error23.Read(iprot)
if err != nil {
return
}
if err = iprot.ReadMessageEnd(); err != nil {
return
}
err = error24
return
}
if mTypeId != thrift.REPLY {
err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "exists failed: invalid message type")
return
}
result := THBaseServiceExistsResult{}
if err = result.Read(iprot); err != nil {
return
}
if err = iprot.ReadMessageEnd(); err != nil {
return
}
if result.Io != nil {
err = result.Io
return
}
value = result.GetSuccess()
return
}
// Test for the existence of columns in the table, as specified by the TGets.
//
// This will return an array of booleans. Each value will be true if the related Get matches
// one or more keys, false if not.
//
// Parameters:
// - Table: the table to check on
// - Tgets: a list of TGets to check for
func (p *THBaseServiceClient) ExistsAll(table []byte, tgets []*TGet) (r []bool, err error) {
if err = p.sendExistsAll(table, tgets); err != nil {
return
}
return p.recvExistsAll()
}
func (p *THBaseServiceClient) sendExistsAll(table []byte, tgets []*TGet) (err error) {
oprot := p.OutputProtocol
if oprot == nil {
oprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.OutputProtocol = oprot
}
p.SeqId++
if err = oprot.WriteMessageBegin("existsAll", thrift.CALL, p.SeqId); err != nil {
return
}
args := THBaseServiceExistsAllArgs{
Table: table,
Tgets: tgets,
}
if err = args.Write(oprot); err != nil {
return
}
if err = oprot.WriteMessageEnd(); err != nil {
return
}
return oprot.Flush()
}
func (p *THBaseServiceClient) recvExistsAll() (value []bool, err error) {
iprot := p.InputProtocol
if iprot == nil {
iprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.InputProtocol = iprot
}
method, mTypeId, seqId, err := iprot.ReadMessageBegin()
if err != nil {
return
}
if method != "existsAll" {
err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "existsAll failed: wrong method name")
return
}
if p.SeqId != seqId {
err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "existsAll failed: out of sequence response")
return
}
if mTypeId == thrift.EXCEPTION {
error25 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
var error26 error
error26, err = error25.Read(iprot)
if err != nil {
return
}
if err = iprot.ReadMessageEnd(); err != nil {
return
}
err = error26
return
}
if mTypeId != thrift.REPLY {
err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "existsAll failed: invalid message type")
return
}
result := THBaseServiceExistsAllResult{}
if err = result.Read(iprot); err != nil {
return
}
if err = iprot.ReadMessageEnd(); err != nil {
return
}
if result.Io != nil {
err = result.Io
return
}
value = result.GetSuccess()
return
}
// Method for getting data from a row.
//
// If the row cannot be found an empty Result is returned.
// This can be checked by the empty field of the TResult
//
// @return the result
//
// Parameters:
// - Table: the table to get from
// - Tget: the TGet to fetch
func (p *THBaseServiceClient) Get(table []byte, tget *TGet) (r *TResult_, err error) {
if err = p.sendGet(table, tget); err != nil {
return
}
return p.recvGet()
}
func (p *THBaseServiceClient) sendGet(table []byte, tget *TGet) (err error) {
oprot := p.OutputProtocol
if oprot == nil {
oprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.OutputProtocol = oprot
}
p.SeqId++
if err = oprot.WriteMessageBegin("get", thrift.CALL, p.SeqId); err != nil {
return
}
args := THBaseServiceGetArgs{
Table: table,
Tget: tget,
}
if err = args.Write(oprot); err != nil {
return
}
if err = oprot.WriteMessageEnd(); err != nil {
return
}
return oprot.Flush()
}
func (p *THBaseServiceClient) recvGet() (value *TResult_, err error) {
iprot := p.InputProtocol
if iprot == nil {
iprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.InputProtocol = iprot
}
method, mTypeId, seqId, err := iprot.ReadMessageBegin()
if err != nil {
return
}
if method != "get" {
err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "get failed: wrong method name")
return
}
if p.SeqId != seqId {
err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "get failed: out of sequence response")
return
}
if mTypeId == thrift.EXCEPTION {
error27 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
var error28 error
error28, err = error27.Read(iprot)
if err != nil {
return
}
if err = iprot.ReadMessageEnd(); err != nil {
return
}
err = error28
return
}
if mTypeId != thrift.REPLY {
err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "get failed: invalid message type")
return
}
result := THBaseServiceGetResult{}
if err = result.Read(iprot); err != nil {
return
}
if err = iprot.ReadMessageEnd(); err != nil {
return
}
if result.Io != nil {
err = result.Io
return
}
value = result.GetSuccess()
return
}
// Method for getting multiple rows.
//
// If a row cannot be found there will be a null
// value in the result list for that TGet at the
// same position.
//
// So the Results are in the same order as the TGets.
//
// Parameters:
// - Table: the table to get from
// - Tgets: a list of TGets to fetch, the Result list
// will have the Results at corresponding positions
// or null if there was an error
func (p *THBaseServiceClient) GetMultiple(table []byte, tgets []*TGet) (r []*TResult_, err error) {
if err = p.sendGetMultiple(table, tgets); err != nil {
return
}
return p.recvGetMultiple()
}
func (p *THBaseServiceClient) sendGetMultiple(table []byte, tgets []*TGet) (err error) {
oprot := p.OutputProtocol
if oprot == nil {
oprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.OutputProtocol = oprot
}
p.SeqId++
if err = oprot.WriteMessageBegin("getMultiple", thrift.CALL, p.SeqId); err != nil {
return
}
args := THBaseServiceGetMultipleArgs{
Table: table,
Tgets: tgets,
}
if err = args.Write(oprot); err != nil {
return
}
if err = oprot.WriteMessageEnd(); err != nil {
return
}
return oprot.Flush()
}
func (p *THBaseServiceClient) recvGetMultiple() (value []*TResult_, err error) {
iprot := p.InputProtocol
if iprot == nil {
iprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.InputProtocol = iprot
}
method, mTypeId, seqId, err := iprot.ReadMessageBegin()
if err != nil {
return
}
if method != "getMultiple" {
err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "getMultiple failed: wrong method name")
return
}
if p.SeqId != seqId {
err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getMultiple failed: out of sequence response")
return
}
if mTypeId == thrift.EXCEPTION {
error29 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
var error30 error
error30, err = error29.Read(iprot)
if err != nil {
return
}
if err = iprot.ReadMessageEnd(); err != nil {
return
}
err = error30
return
}
if mTypeId != thrift.REPLY {
err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "getMultiple failed: invalid message type")
return
}
result := THBaseServiceGetMultipleResult{}
if err = result.Read(iprot); err != nil {
return
}
if err = iprot.ReadMessageEnd(); err != nil {
return
}
if result.Io != nil {
err = result.Io
return
}
value = result.GetSuccess()
return
}
// Commit a TPut to a table.
//
// Parameters:
// - Table: the table to put data in
// - Tput: the TPut to put
func (p *THBaseServiceClient) Put(table []byte, tput *TPut) (err error) {
if err = p.sendPut(table, tput); err != nil {
return
}
return p.recvPut()
}
func (p *THBaseServiceClient) sendPut(table []byte, tput *TPut) (err error) {
oprot := p.OutputProtocol
if oprot == nil {
oprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.OutputProtocol = oprot
}
p.SeqId++
if err = oprot.WriteMessageBegin("put", thrift.CALL, p.SeqId); err != nil {
return
}
args := THBaseServicePutArgs{
Table: table,
Tput: tput,
}
if err = args.Write(oprot); err != nil {
return
}
if err = oprot.WriteMessageEnd(); err != nil {
return
}
return oprot.Flush()
}
func (p *THBaseServiceClient) recvPut() (err error) {
iprot := p.InputProtocol
if iprot == nil {
iprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.InputProtocol = iprot
}
method, mTypeId, seqId, err := iprot.ReadMessageBegin()
if err != nil {
return
}
if method != "put" {
err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "put failed: wrong method name")
return
}
if p.SeqId != seqId {
err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "put failed: out of sequence response")
return
}
if mTypeId == thrift.EXCEPTION {
error31 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
var error32 error
error32, err = error31.Read(iprot)
if err != nil {
return
}
if err = iprot.ReadMessageEnd(); err != nil {
return
}
err = error32
return
}
if mTypeId != thrift.REPLY {
err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "put failed: invalid message type")
return
}
result := THBaseServicePutResult{}
if err = result.Read(iprot); err != nil {
return
}
if err = iprot.ReadMessageEnd(); err != nil {
return
}
if result.Io != nil {
err = result.Io
return
}
return
}
// Atomically checks if a row/family/qualifier value matches the expected
// value. If it does, it adds the TPut.
//
// @return true if the new put was executed, false otherwise
//
// Parameters:
// - Table: to check in and put to
// - Row: row to check
// - Family: column family to check
// - Qualifier: column qualifier to check
// - Value: the expected value, if not provided the
// check is for the non-existence of the
// column in question
// - Tput: the TPut to put if the check succeeds
func (p *THBaseServiceClient) CheckAndPut(table []byte, row []byte, family []byte, qualifier []byte, value []byte, tput *TPut) (r bool, err error) {
if err = p.sendCheckAndPut(table, row, family, qualifier, value, tput); err != nil {
return
}
return p.recvCheckAndPut()
}
func (p *THBaseServiceClient) sendCheckAndPut(table []byte, row []byte, family []byte, qualifier []byte, value []byte, tput *TPut) (err error) {
oprot := p.OutputProtocol
if oprot == nil {
oprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.OutputProtocol = oprot
}
p.SeqId++
if err = oprot.WriteMessageBegin("checkAndPut", thrift.CALL, p.SeqId); err != nil {
return
}
args := THBaseServiceCheckAndPutArgs{
Table: table,
Row: row,
Family: family,
Qualifier: qualifier,
Value: value,
Tput: tput,
}
if err = args.Write(oprot); err != nil {
return
}
if err = oprot.WriteMessageEnd(); err != nil {
return
}
return oprot.Flush()
}
func (p *THBaseServiceClient) recvCheckAndPut() (value bool, err error) {
iprot := p.InputProtocol
if iprot == nil {
iprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.InputProtocol = iprot
}
method, mTypeId, seqId, err := iprot.ReadMessageBegin()
if err != nil {
return
}
if method != "checkAndPut" {
err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "checkAndPut failed: wrong method name")
return
}
if p.SeqId != seqId {
err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "checkAndPut failed: out of sequence response")
return
}
if mTypeId == thrift.EXCEPTION {
error33 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
var error34 error
error34, err = error33.Read(iprot)
if err != nil {
return
}
if err = iprot.ReadMessageEnd(); err != nil {
return
}
err = error34
return
}
if mTypeId != thrift.REPLY {
err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "checkAndPut failed: invalid message type")
return
}
result := THBaseServiceCheckAndPutResult{}
if err = result.Read(iprot); err != nil {
return
}
if err = iprot.ReadMessageEnd(); err != nil {
return
}
if result.Io != nil {
err = result.Io
return
}
value = result.GetSuccess()
return
}
// Commit a List of Puts to the table.
//
// Parameters:
// - Table: the table to put data in
// - Tputs: a list of TPuts to commit
func (p *THBaseServiceClient) PutMultiple(table []byte, tputs []*TPut) (err error) {
if err = p.sendPutMultiple(table, tputs); err != nil {
return
}
return p.recvPutMultiple()
}
func (p *THBaseServiceClient) sendPutMultiple(table []byte, tputs []*TPut) (err error) {
oprot := p.OutputProtocol
if oprot == nil {
oprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.OutputProtocol = oprot
}
p.SeqId++
if err = oprot.WriteMessageBegin("putMultiple", thrift.CALL, p.SeqId); err != nil {
return
}
args := THBaseServicePutMultipleArgs{
Table: table,
Tputs: tputs,
}
if err = args.Write(oprot); err != nil {
return
}
if err = oprot.WriteMessageEnd(); err != nil {
return
}
return oprot.Flush()
}
func (p *THBaseServiceClient) recvPutMultiple() (err error) {
iprot := p.InputProtocol
if iprot == nil {
iprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.InputProtocol = iprot
}
method, mTypeId, seqId, err := iprot.ReadMessageBegin()
if err != nil {
return
}
if method != "putMultiple" {
err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "putMultiple failed: wrong method name")
return
}
if p.SeqId != seqId {
err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "putMultiple failed: out of sequence response")
return
}
if mTypeId == thrift.EXCEPTION {
error35 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
var error36 error
error36, err = error35.Read(iprot)
if err != nil {
return
}
if err = iprot.ReadMessageEnd(); err != nil {
return
}
err = error36
return
}
if mTypeId != thrift.REPLY {
err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "putMultiple failed: invalid message type")
return
}
result := THBaseServicePutMultipleResult{}
if err = result.Read(iprot); err != nil {
return
}
if err = iprot.ReadMessageEnd(); err != nil {
return
}
if result.Io != nil {
err = result.Io
return
}
return
}
// Deletes as specified by the TDelete.
//
// Note: "delete" is a reserved keyword and cannot be used in Thrift
// thus the inconsistent naming scheme from the other functions.
//
// Parameters:
// - Table: the table to delete from
// - Tdelete: the TDelete to delete
func (p *THBaseServiceClient) DeleteSingle(table []byte, tdelete *TDelete) (err error) {
if err = p.sendDeleteSingle(table, tdelete); err != nil {
return
}
return p.recvDeleteSingle()
}
func (p *THBaseServiceClient) sendDeleteSingle(table []byte, tdelete *TDelete) (err error) {
oprot := p.OutputProtocol
if oprot == nil {
oprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.OutputProtocol = oprot
}
p.SeqId++
if err = oprot.WriteMessageBegin("deleteSingle", thrift.CALL, p.SeqId); err != nil {
return
}
args := THBaseServiceDeleteSingleArgs{
Table: table,
Tdelete: tdelete,
}
if err = args.Write(oprot); err != nil {
return
}
if err = oprot.WriteMessageEnd(); err != nil {
return
}
return oprot.Flush()
}
func (p *THBaseServiceClient) recvDeleteSingle() (err error) {
iprot := p.InputProtocol
if iprot == nil {
iprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.InputProtocol = iprot
}
method, mTypeId, seqId, err := iprot.ReadMessageBegin()
if err != nil {
return
}
if method != "deleteSingle" {
err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "deleteSingle failed: wrong method name")
return
}
if p.SeqId != seqId {
err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "deleteSingle failed: out of sequence response")
return
}
if mTypeId == thrift.EXCEPTION {
error37 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
var error38 error
error38, err = error37.Read(iprot)
if err != nil {
return
}
if err = iprot.ReadMessageEnd(); err != nil {
return
}
err = error38
return
}
if mTypeId != thrift.REPLY {
err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "deleteSingle failed: invalid message type")
return
}
result := THBaseServiceDeleteSingleResult{}
if err = result.Read(iprot); err != nil {
return
}
if err = iprot.ReadMessageEnd(); err != nil {
return
}
if result.Io != nil {
err = result.Io
return
}
return
}
// Bulk commit a List of TDeletes to the table.
//
// Throws a TIOError if any of the deletes fail.
//
// Always returns an empty list for backwards compatibility.
//
// Parameters:
// - Table: the table to delete from
// - Tdeletes: list of TDeletes to delete
func (p *THBaseServiceClient) DeleteMultiple(table []byte, tdeletes []*TDelete) (r []*TDelete, err error) {
if err = p.sendDeleteMultiple(table, tdeletes); err != nil {
return
}
return p.recvDeleteMultiple()
}
func (p *THBaseServiceClient) sendDeleteMultiple(table []byte, tdeletes []*TDelete) (err error) {
oprot := p.OutputProtocol
if oprot == nil {
oprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.OutputProtocol = oprot
}
p.SeqId++
if err = oprot.WriteMessageBegin("deleteMultiple", thrift.CALL, p.SeqId); err != nil {
return
}
args := THBaseServiceDeleteMultipleArgs{
Table: table,
Tdeletes: tdeletes,
}
if err = args.Write(oprot); err != nil {
return
}
if err = oprot.WriteMessageEnd(); err != nil {
return
}
return oprot.Flush()
}
func (p *THBaseServiceClient) recvDeleteMultiple() (value []*TDelete, err error) {
iprot := p.InputProtocol
if iprot == nil {
iprot = p.ProtocolFactory.GetProtocol(p.Transport)
p.InputProtocol = iprot
}
method, mTypeId, seqId, err := iprot.ReadMessageBegin()
if err != nil {
return
}
if method != "deleteMultiple" {
err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "deleteMultiple failed: wrong method name")
return
}
if p.SeqId != seqId {
err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "deleteMultiple failed: out of sequence response")
return
}
if mTypeId == thrift.EXCEPTION {
error39 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
var error40 error
error40, err = error39.Read(iprot)
if err != nil {