forked from oceanbase/seekdb
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathob_exec_feedback_info.cpp
More file actions
97 lines (90 loc) · 3.7 KB
/
Copy pathob_exec_feedback_info.cpp
File metadata and controls
97 lines (90 loc) · 3.7 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
/*
* 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_ENG
#include "sql/engine/ob_exec_feedback_info.h"
using namespace oceanbase::common;
using namespace oceanbase::sql;
OB_SERIALIZE_MEMBER(ObExecFeedbackNode,
op_id_,
output_row_count_,
op_open_time_,
op_close_time_,
op_first_row_time_,
op_last_row_time_,
db_time_,
block_time_,
worker_count_,
pdml_op_write_rows_);
OB_SERIALIZE_MEMBER(ObExecFeedbackInfo,
nodes_,
total_db_time_);
int ObExecFeedbackInfo::merge_feedback_info(const ObExecFeedbackInfo &feedback_info)
{
int ret = OB_SUCCESS;
if (!is_valid() || !feedback_info.is_valid()) {
LOG_TRACE("feedback info is not valid", K(ret), K(is_valid_), K(feedback_info.is_valid_));
} else if (nodes_.count() < feedback_info.get_feedback_nodes().count()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("the count of feedback info is unexpected", K(nodes_.count()), K(feedback_info.get_feedback_nodes().count()));
} else {
const common::ObIArray<ObExecFeedbackNode> &fb_nodes = feedback_info.get_feedback_nodes();
int left = 0, right = 0;
while (left < nodes_.count() && right < fb_nodes.count() && OB_SUCC(ret)) {
if (nodes_.at(left).op_id_ == fb_nodes.at(right).op_id_) {
nodes_.at(left).op_open_time_ =
min(fb_nodes.at(right).op_open_time_, nodes_.at(left).op_open_time_);
nodes_.at(left).op_first_row_time_ =
min(fb_nodes.at(right).op_first_row_time_, nodes_.at(left).op_first_row_time_);
nodes_.at(left).block_time_ =
max(fb_nodes.at(right).block_time_, nodes_.at(left).block_time_);
nodes_.at(left).op_last_row_time_ =
max(fb_nodes.at(right).op_last_row_time_, nodes_.at(left).op_last_row_time_);
nodes_.at(left).op_close_time_ =
max(fb_nodes.at(right).op_close_time_, nodes_.at(left).op_close_time_);
nodes_.at(left).db_time_ = max(fb_nodes.at(right).db_time_, nodes_.at(left).db_time_);
nodes_.at(left).output_row_count_ += fb_nodes.at(right).output_row_count_;
nodes_.at(left).pdml_op_write_rows_ += fb_nodes.at(right).pdml_op_write_rows_;
nodes_.at(left).worker_count_ += fb_nodes.at(right).worker_count_;
left++;
right++;
continue;
} else if (nodes_.at(left).op_id_ < fb_nodes.at(right).op_id_) {
left++;
continue;
} else if (nodes_.at(left).op_id_ > fb_nodes.at(right).op_id_) {
is_valid_ = false;
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected id node", K(ret));
break;
}
}
}
if (OB_FAIL(ret)) {
is_valid_ = false;
LOG_WARN("mark the feedback info is invalid", K(ret));
} else {
total_db_time_ += feedback_info.get_total_db_time();
}
return ret;
}
int ObExecFeedbackInfo::assign(const ObExecFeedbackInfo &other)
{
int ret = OB_SUCCESS;
total_db_time_ = other.get_total_db_time();
is_valid_ = other.is_valid();
OZ(nodes_.assign(other.get_feedback_nodes()));
return ret;
}