forked from oceanbase/seekdb
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathob_task_event.cpp
More file actions
202 lines (176 loc) · 4.78 KB
/
Copy pathob_task_event.cpp
File metadata and controls
202 lines (176 loc) · 4.78 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
/*
* Copyright (c) 2025 OceanBase.
*
* 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.
*/
#define USING_LOG_PREFIX SQL_EXE
#include "sql/executor/ob_task_event.h"
using namespace oceanbase::common;
namespace oceanbase
{
namespace sql
{
ObTaskSmallResult::ObTaskSmallResult()
: has_data_(false),
data_len_(0),
data_buf_(),
affected_rows_(0),
found_rows_(0),
last_insert_id_(0),
matched_rows_(0),
duplicated_rows_(0)
{
}
ObTaskSmallResult::~ObTaskSmallResult()
{
}
void ObTaskSmallResult::reset()
{
has_data_ = false;
data_len_ = 0;
affected_rows_ = 0;
found_rows_ = 0;
last_insert_id_ = 0;
matched_rows_ = 0;
duplicated_rows_ = 0;
}
bool ObTaskSmallResult::equal(const ObTaskSmallResult &other) const
{
bool is_eq = (has_data_ == other.has_data_ && data_len_ == other.data_len_);
for (int64_t i = 0; is_eq && i < data_len_ && i < MAX_DATA_BUF_LEN; ++i) {
if (data_buf_[i] != other.data_buf_[i]) {
is_eq = false;
}
}
return is_eq;
}
int ObTaskSmallResult::assign(const ObTaskSmallResult &other)
{
int ret = OB_SUCCESS;
has_data_ = other.has_data_;
if (OB_UNLIKELY(other.data_len_ > MAX_DATA_BUF_LEN)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("data len is too long", K(ret), K(other.data_len_), LITERAL_K(MAX_DATA_BUF_LEN));
} else {
data_len_ = other.data_len_;
MEMCPY(data_buf_, other.data_buf_, other.data_len_);
affected_rows_ = other.affected_rows_;
found_rows_ = other.found_rows_;
last_insert_id_ = other.last_insert_id_;
matched_rows_ = other.matched_rows_;
duplicated_rows_ = other.duplicated_rows_;
}
return ret;
}
int ObSliceEvent::assign(const ObSliceEvent &other)
{
int ret = OB_SUCCESS;
ob_slice_id_ = other.ob_slice_id_;
if (OB_FAIL(small_result_.assign(other.small_result_))) {
LOG_WARN("fail to assign slice small result", K(ret), K(other));
}
return ret;
}
ObTaskEvent::ObTaskEvent()
: task_loc_(),
err_code_(static_cast<const int64_t>(OB_ERR_UNEXPECTED)),
inited_(false),
ts_task_recv_done_(0),
ts_result_send_begin_(0)
{
}
ObTaskEvent::~ObTaskEvent()
{
}
void ObTaskEvent::reset()
{
task_loc_.reset();
err_code_ = static_cast<const int64_t>(OB_ERR_UNEXPECTED);
inited_ = false;
}
OB_DEF_SERIALIZE(ObTaskSmallResult)
{
int ret = OB_SUCCESS;
LST_DO_CODE(OB_UNIS_ENCODE,
has_data_,
data_len_);
if (OB_SUCC(ret)) {
if (has_data_ && data_len_ > 0) {
MEMCPY(buf + pos, data_buf_, data_len_);
pos += data_len_;
}
}
LST_DO_CODE(OB_UNIS_ENCODE,
affected_rows_,
found_rows_,
last_insert_id_,
matched_rows_,
duplicated_rows_);
return ret;
}
OB_DEF_DESERIALIZE(ObTaskSmallResult)
{
int ret = OB_SUCCESS;
LST_DO_CODE(OB_UNIS_DECODE,
has_data_,
data_len_);
if (OB_SUCC(ret)) {
if (has_data_ && data_len_ > 0) {
MEMCPY(data_buf_, buf + pos, data_len_);
pos += data_len_;
}
}
LST_DO_CODE(OB_UNIS_DECODE,
affected_rows_,
found_rows_,
last_insert_id_,
matched_rows_,
duplicated_rows_);
return ret;
}
OB_DEF_SERIALIZE_SIZE(ObTaskSmallResult)
{
int64_t len = 0;
int ret = OB_SUCCESS;
LST_DO_CODE(OB_UNIS_ADD_LEN,
has_data_,
data_len_);
if (OB_SUCC(ret)) {
if (has_data_ && data_len_ > 0) {
len += data_len_;
}
}
LST_DO_CODE(OB_UNIS_ADD_LEN,
affected_rows_,
found_rows_,
last_insert_id_,
matched_rows_,
duplicated_rows_);
return len;
}
OB_SERIALIZE_MEMBER(ObSliceEvent, ob_slice_id_, small_result_);
OB_SERIALIZE_MEMBER(ObTaskEvent, task_loc_, err_code_, inited_, ts_task_recv_done_, ts_result_send_begin_);
int ObMiniTaskResult::assign(const ObMiniTaskResult &other)
{
int ret = OB_SUCCESS;
if (OB_FAIL(task_result_.assign(other.task_result_))) {
LOG_WARN("assign task result failed", K(ret), K(other));
} else if (OB_FAIL(extend_result_.assign(other.extend_result_))) {
LOG_WARN("assign extend result failed", K(ret), K(other));
}
return ret;
}
OB_SERIALIZE_MEMBER(ObMiniTaskResult, task_result_, extend_result_);
OB_SERIALIZE_MEMBER(ObRemoteResult, task_id_, result_, has_more_);
}/* ns sql*/
}/* ns oceanbase */