to issue<48907696>:fix udf containing complex type execute slow issue
This commit is contained in:
parent
7fca017f19
commit
b14bad1f09
@ -200,6 +200,19 @@ void ObPLCtx::reset_obj()
|
||||
objects_.reset();
|
||||
}
|
||||
|
||||
void ObPLCtx::reset_obj_range_to_end(int64_t index)
|
||||
{
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
if (index < objects_.count() && index >= 0) {
|
||||
for (int64_t i = objects_.count() - 1; i >= index; i--) {
|
||||
if (OB_SUCCESS != (tmp_ret = ObUserDefinedType::destruct_obj(objects_.at(i)))) {
|
||||
LOG_WARN_RET(tmp_ret, "failed to destruct pl object", K(i), K(tmp_ret));
|
||||
}
|
||||
objects_.pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ObPLCtx::~ObPLCtx()
|
||||
{
|
||||
reset_obj();
|
||||
|
@ -703,6 +703,7 @@ public:
|
||||
objects_.reset();
|
||||
}
|
||||
void reset_obj();
|
||||
void reset_obj_range_to_end(int64_t index);
|
||||
common::ObIArray<ObObj>& get_objects() { return objects_; }
|
||||
private:
|
||||
// 用于收集在PL执行过程中使用到的Allocator,
|
||||
@ -712,31 +713,6 @@ private:
|
||||
ObSEArray<ObObj, 32> objects_;
|
||||
};
|
||||
|
||||
class ObPLCtxGuard
|
||||
{
|
||||
public:
|
||||
ObPLCtxGuard(ObPLCtx *ctx, int& ret) : ctx_(ctx), ret_(ret) {
|
||||
if (OB_SUCCESS == ret_ && OB_NOT_NULL(ctx)) {
|
||||
ret_ = objects_.assign(ctx->get_objects());
|
||||
ctx_->clear();
|
||||
}
|
||||
}
|
||||
|
||||
~ObPLCtxGuard() {
|
||||
if (OB_SUCCESS == ret_ && OB_NOT_NULL(ctx_)) {
|
||||
for (int64_t i = 0; OB_SUCCESS == ret_ && i < objects_.count(); ++i) {
|
||||
ret_ = ctx_->add(objects_.at(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ObPLCtx *ctx_;
|
||||
int &ret_;
|
||||
ObSEArray<ObObj, 4> objects_;
|
||||
};
|
||||
|
||||
|
||||
class ObPLPackageGuard;
|
||||
|
||||
#define IDX_PLEXECCTX_VTABLE 0
|
||||
|
@ -444,10 +444,12 @@ int ObExprUDF::eval_udf(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res)
|
||||
session->set_start_stmt();
|
||||
}
|
||||
|
||||
pl::ObPLCtxGuard guard(ctx.exec_ctx_.get_pl_ctx(), ret);
|
||||
|
||||
ObEvalCtx::TempAllocGuard memory_guard(ctx);
|
||||
ObArenaAllocator &allocator = memory_guard.get_allocator();
|
||||
int64_t cur_obj_count = 0;
|
||||
if (OB_NOT_NULL(ctx.exec_ctx_.get_pl_ctx())) {
|
||||
cur_obj_count = ctx.exec_ctx_.get_pl_ctx()->get_objects().count();
|
||||
}
|
||||
|
||||
ObObj *objs = nullptr;
|
||||
if (expr.arg_cnt_ > 0) {
|
||||
@ -505,11 +507,11 @@ int ObExprUDF::eval_udf(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res)
|
||||
OZ (pl::ObUserDefinedType::deep_copy_obj(alloc, tmp_result, result, true));
|
||||
OZ (pl::ObUserDefinedType::destruct_obj(tmp_result, ctx.exec_ctx_.get_my_session()));
|
||||
CK (OB_NOT_NULL(ctx.exec_ctx_.get_pl_ctx()));
|
||||
OX (ctx.exec_ctx_.get_pl_ctx()->reset_obj());
|
||||
OX (ctx.exec_ctx_.get_pl_ctx()->reset_obj_range_to_end(cur_obj_count));
|
||||
OZ (ctx.exec_ctx_.get_pl_ctx()->add(result));
|
||||
} else {
|
||||
result = tmp_result;
|
||||
OX (ctx.exec_ctx_.get_pl_ctx()->reset_obj());
|
||||
OX (ctx.exec_ctx_.get_pl_ctx()->reset_obj_range_to_end(cur_obj_count));
|
||||
}
|
||||
} else {
|
||||
result = tmp_result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user