patch 4.0
This commit is contained in:
@ -15,22 +15,24 @@
|
||||
#include "sql/monitor/ob_phy_operator_monitor_info.h"
|
||||
#include "sql/monitor/ob_phy_plan_monitor_info.h"
|
||||
#include "sql/engine/ob_exec_context.h"
|
||||
#include "sql/engine/ob_phy_operator.h"
|
||||
#include "sql/engine/ob_physical_plan.h"
|
||||
#include "observer/ob_inner_sql_result.h"
|
||||
#include "sql/ob_sql.h"
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::observer;
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
template <class T>
|
||||
int ObExecStatCollector::add_stat(const T* value)
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
template<class T>
|
||||
int ObExecStatCollector::add_stat(const T *value)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(value)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(value));
|
||||
} else if (OB_FAIL(serialization::encode_vi32(extend_buf_, MAX_STAT_BUF_COUNT, length_, value->get_type()))) {
|
||||
} else if (OB_FAIL(serialization::encode_vi32(
|
||||
extend_buf_, MAX_STAT_BUF_COUNT, length_, value->get_type()))) {
|
||||
LOG_WARN("fail to encode type", K(ret), K(value));
|
||||
} else if (OB_FAIL(value->serialize(extend_buf_, MAX_STAT_BUF_COUNT, length_))) {
|
||||
LOG_WARN("fail to serialize value", K(ret), K(value));
|
||||
@ -38,12 +40,12 @@ int ObExecStatCollector::add_stat(const T* value)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExecStatCollector::add_raw_stat(const common::ObString& str)
|
||||
int ObExecStatCollector::add_raw_stat(const common::ObString &str)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (length_ + str.length() >= MAX_STAT_BUF_COUNT) {
|
||||
ret = OB_BUF_NOT_ENOUGH;
|
||||
LOG_DEBUG("buffer size not enough", K(ret), K(length_), K(str.length()));
|
||||
LOG_DEBUG("buffer size not enough", K(ret),K(length_), K(str.length()));
|
||||
} else {
|
||||
MEMCPY(extend_buf_ + length_, str.ptr(), str.length());
|
||||
length_ += str.length();
|
||||
@ -51,7 +53,7 @@ int ObExecStatCollector::add_raw_stat(const common::ObString& str)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExecStatCollector::get_extend_info(ObIAllocator& allocator, ObString& str)
|
||||
int ObExecStatCollector::get_extend_info(ObIAllocator &allocator, ObString &str)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const ObString tmp_str(length_, extend_buf_);
|
||||
@ -65,15 +67,16 @@ void ObExecStatCollector::reset()
|
||||
length_ = 0;
|
||||
}
|
||||
|
||||
int ObExecStatCollector::collect_plan_monitor_info(
|
||||
uint64_t job_id, uint64_t task_id, ObPhyPlanMonitorInfo* monitor_info)
|
||||
int ObExecStatCollector::collect_plan_monitor_info(uint64_t job_id,
|
||||
uint64_t task_id,
|
||||
ObPhyPlanMonitorInfo *monitor_info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(monitor_info)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
SQL_MONITOR_LOG(WARN, "invalid argument", K(ret), K(monitor_info));
|
||||
} else {
|
||||
ObPhyOperatorMonitorInfo* op_info = NULL;
|
||||
ObPhyOperatorMonitorInfo *op_info = NULL;
|
||||
for (int64_t i = 0; i < monitor_info->get_operator_count() && OB_SUCC(ret); i++) {
|
||||
if (OB_FAIL(monitor_info->get_operator_info_by_index(i, op_info))) {
|
||||
SQL_MONITOR_LOG(WARN, "fail to get operator info by index", K(ret), K(i));
|
||||
@ -93,7 +96,9 @@ int ObExecStatCollector::collect_plan_monitor_info(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExecStatCollector::collect_monitor_info(uint64_t job_id, uint64_t task_id, ObPhyOperatorMonitorInfo& op_info)
|
||||
int ObExecStatCollector::collect_monitor_info(uint64_t job_id,
|
||||
uint64_t task_id,
|
||||
ObPhyOperatorMonitorInfo &op_info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(op_info.set_job_id(job_id))) {
|
||||
@ -108,34 +113,38 @@ int ObExecStatCollector::collect_monitor_info(uint64_t job_id, uint64_t task_id,
|
||||
return ret;
|
||||
}
|
||||
//////////////////////////////////////
|
||||
int ObExecStatDispatch::set_extend_info(const ObString& stat_buf)
|
||||
int ObExecStatDispatch::set_extend_info(const ObString &stat_buf)
|
||||
{
|
||||
stat_str_.assign_ptr(stat_buf.ptr(), stat_buf.length());
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObExecStatDispatch::dispatch(
|
||||
bool need_add_monitor, ObPhyPlanMonitorInfo* monitor_info, bool need_update_plan, ObPhysicalPlan* plan)
|
||||
int ObExecStatDispatch::dispatch(bool need_add_monitor,
|
||||
ObPhyPlanMonitorInfo *monitor_info,
|
||||
bool need_update_plan,
|
||||
ObPhysicalPlan *plan)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
StatType type = OB_INVALID_STAT_TYPE;
|
||||
if ((need_add_monitor && OB_ISNULL(monitor_info)) || OB_ISNULL(plan)) {
|
||||
if ((need_add_monitor && OB_ISNULL(monitor_info))
|
||||
|| OB_ISNULL(plan)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(ret), K(monitor_info), K(plan));
|
||||
}
|
||||
while (OB_SUCC(ret) && OB_SUCC(get_next_type(type))) {
|
||||
switch (type) {
|
||||
case PLAN_MONITOR_INFO: {
|
||||
ObPhyOperatorMonitorInfo op_info;
|
||||
if (OB_FAIL(get_value<ObPhyOperatorMonitorInfo>(&op_info))) {
|
||||
LOG_WARN("fail to get value", K(ret));
|
||||
} else if (need_add_monitor && OB_FAIL(monitor_info->add_operator_info(op_info))) {
|
||||
LOG_WARN("fail to add operator info", K(ret), K(op_info));
|
||||
} else if (need_update_plan && OB_FAIL(plan->op_stats_.add_op_stat(op_info))) {
|
||||
LOG_WARN("fail to add operatgor info", K(ret), K(op_info));
|
||||
case PLAN_MONITOR_INFO:
|
||||
{
|
||||
ObPhyOperatorMonitorInfo op_info;
|
||||
if (OB_FAIL(get_value<ObPhyOperatorMonitorInfo>(&op_info))) {
|
||||
LOG_WARN("fail to get value", K(ret));
|
||||
} else if (need_add_monitor && OB_FAIL(monitor_info->add_operator_info(op_info))) {
|
||||
LOG_WARN("fail to add operator info", K(ret), K(op_info));
|
||||
} else if (need_update_plan && OB_FAIL(plan->op_stats_.add_op_stat(op_info))) {
|
||||
LOG_WARN("fail to add operatgor info", K(ret), K(op_info));
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ret = OB_UNKNOWN_OBJ;
|
||||
LOG_WARN("unknown type", K(ret), K(type));
|
||||
@ -148,7 +157,7 @@ int ObExecStatDispatch::dispatch(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExecStatDispatch::get_next_type(StatType& type)
|
||||
int ObExecStatDispatch::get_next_type(StatType &type)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int32_t type_value = 0;
|
||||
@ -161,8 +170,8 @@ int ObExecStatDispatch::get_next_type(StatType& type)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
template <class T>
|
||||
int ObExecStatDispatch::get_value(T* value)
|
||||
template<class T>
|
||||
int ObExecStatDispatch::get_value(T *value)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(value)) {
|
||||
@ -174,5 +183,5 @@ int ObExecStatDispatch::get_value(T* value)
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
}/* ns sql*/
|
||||
}/* ns oceanbase */
|
||||
|
||||
Reference in New Issue
Block a user