-
Notifications
You must be signed in to change notification settings - Fork 0
/
Status.go
212 lines (195 loc) · 5.7 KB
/
Status.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
// Code generated by Thrift Compiler (0.17.0). DO NOT EDIT.
package status
import (
"bytes"
"context"
"errors"
"fmt"
thrift "github.com/apache/thrift/lib/go/thrift"
"github.com/believems/impala-thrift/errorcodes"
"time"
)
// (needed to ensure safety because of naive import list construction.)
var _ = thrift.ZERO
var _ = fmt.Printf
var _ = errors.New
var _ = context.Background
var _ = time.Now
var _ = bytes.Equal
var _ = errorcodes.GoUnusedProtection__
// Attributes:
// - StatusCode
// - ErrorMsgs
type TStatus struct {
StatusCode errorcodes.TErrorCode `thrift:"status_code,1,required" db:"status_code" json:"status_code"`
ErrorMsgs []string `thrift:"error_msgs,2" db:"error_msgs" json:"error_msgs"`
}
func NewTStatus() *TStatus {
return &TStatus{}
}
func (p *TStatus) GetStatusCode() errorcodes.TErrorCode {
return p.StatusCode
}
func (p *TStatus) GetErrorMsgs() []string {
return p.ErrorMsgs
}
func (p *TStatus) Read(ctx context.Context, iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(ctx); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
var issetStatusCode bool = false
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP {
break
}
switch fieldId {
case 1:
if fieldTypeId == thrift.I32 {
if err := p.ReadField1(ctx, iprot); err != nil {
return err
}
issetStatusCode = true
} else {
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
return err
}
}
case 2:
if fieldTypeId == thrift.LIST {
if err := p.ReadField2(ctx, iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(ctx); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(ctx); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
if !issetStatusCode {
return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field StatusCode is not set"))
}
return nil
}
func (p *TStatus) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
if v, err := iprot.ReadI32(ctx); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
temp := errorcodes.TErrorCode(v)
p.StatusCode = temp
}
return nil
}
func (p *TStatus) ReadField2(ctx context.Context, iprot thrift.TProtocol) error {
_, size, err := iprot.ReadListBegin(ctx)
if err != nil {
return thrift.PrependError("error reading list begin: ", err)
}
tSlice := make([]string, 0, size)
p.ErrorMsgs = tSlice
for i := 0; i < size; i++ {
var _elem0 string
if v, err := iprot.ReadString(ctx); err != nil {
return thrift.PrependError("error reading field 0: ", err)
} else {
_elem0 = v
}
p.ErrorMsgs = append(p.ErrorMsgs, _elem0)
}
if err := iprot.ReadListEnd(ctx); err != nil {
return thrift.PrependError("error reading list end: ", err)
}
return nil
}
func (p *TStatus) Write(ctx context.Context, oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin(ctx, "TStatus"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
}
if p != nil {
if err := p.writeField1(ctx, oprot); err != nil {
return err
}
if err := p.writeField2(ctx, oprot); err != nil {
return err
}
}
if err := oprot.WriteFieldStop(ctx); err != nil {
return thrift.PrependError("write field stop error: ", err)
}
if err := oprot.WriteStructEnd(ctx); err != nil {
return thrift.PrependError("write struct stop error: ", err)
}
return nil
}
func (p *TStatus) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin(ctx, "status_code", thrift.I32, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:status_code: ", p), err)
}
if err := oprot.WriteI32(ctx, int32(p.StatusCode)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.status_code (1) field write error: ", p), err)
}
if err := oprot.WriteFieldEnd(ctx); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:status_code: ", p), err)
}
return err
}
func (p *TStatus) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin(ctx, "error_msgs", thrift.LIST, 2); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:error_msgs: ", p), err)
}
if err := oprot.WriteListBegin(ctx, thrift.STRING, len(p.ErrorMsgs)); err != nil {
return thrift.PrependError("error writing list begin: ", err)
}
for _, v := range p.ErrorMsgs {
if err := oprot.WriteString(ctx, string(v)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err)
}
}
if err := oprot.WriteListEnd(ctx); err != nil {
return thrift.PrependError("error writing list end: ", err)
}
if err := oprot.WriteFieldEnd(ctx); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 2:error_msgs: ", p), err)
}
return err
}
func (p *TStatus) Equals(other *TStatus) bool {
if p == other {
return true
} else if p == nil || other == nil {
return false
}
if p.StatusCode != other.StatusCode {
return false
}
if len(p.ErrorMsgs) != len(other.ErrorMsgs) {
return false
}
for i, _tgt := range p.ErrorMsgs {
_src1 := other.ErrorMsgs[i]
if _tgt != _src1 {
return false
}
}
return true
}
func (p *TStatus) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("TStatus(%+v)", *p)
}