[FEAT MERGE] das framework optimization.

This commit is contained in:
rolandqi
2023-01-10 12:49:51 +00:00
committed by ob-robot
parent 82426bb509
commit 31171bb553
31 changed files with 1497 additions and 275 deletions

View File

@ -70,7 +70,9 @@ ObDASInsertOp::ObDASInsertOp(ObIAllocator &op_alloc)
: ObIDASTaskOp(op_alloc),
ins_ctdef_(nullptr),
ins_rtdef_(nullptr),
result_(nullptr)
result_(nullptr),
affected_rows_(0),
is_duplicated_(false)
{
}
@ -108,6 +110,7 @@ int ObDASInsertOp::insert_rows()
}
} else {
ins_rtdef_->affected_rows_ += affected_rows;
affected_rows_ = affected_rows;
}
return ret;
}
@ -161,6 +164,7 @@ int ObDASInsertOp::insert_row_with_fetch()
} else {
LOG_DEBUG("insert one row and conflicted", KPC(insert_row));
ins_rtdef_->is_duplicated_ = true;
is_duplicated_ = true;
}
}
}
@ -216,6 +220,7 @@ int ObDASInsertOp::insert_row_with_fetch()
} else {
LOG_DEBUG("insert one row and conflicted", KPC(insert_row));
ins_rtdef_->is_duplicated_ = true;
is_duplicated_ = true;
}
} else {
// 需要释放iter的内存, 否则会内存泄漏
@ -291,18 +296,18 @@ int ObDASInsertOp::decode_task_result(ObIDASTaskResult *task_result)
} else {
result_ = insert_result;
ins_rtdef_->affected_rows_ += insert_result->get_affected_rows();
ins_rtdef_->is_duplicated_ = ins_rtdef_->is_duplicated_ || insert_result->is_duplicated();
ins_rtdef_->is_duplicated_ |= insert_result->is_duplicated();
}
} else {
result_ = insert_result;
ins_rtdef_->affected_rows_ += insert_result->get_affected_rows();
ins_rtdef_->is_duplicated_ = ins_rtdef_->is_duplicated_ || insert_result->is_duplicated();
ins_rtdef_->is_duplicated_ |= insert_result->is_duplicated();
}
}
return ret;
}
int ObDASInsertOp::fill_task_result(ObIDASTaskResult &task_result, bool &has_more)
int ObDASInsertOp::fill_task_result(ObIDASTaskResult &task_result, bool &has_more, int64_t &memory_limit)
{
int ret = OB_SUCCESS;
#if !defined(NDEBUG)
@ -316,12 +321,13 @@ int ObDASInsertOp::fill_task_result(ObIDASTaskResult &task_result, bool &has_mor
if (OB_FAIL(store_conflict_row(ins_result))) {
LOG_WARN("fail to fetch conflict row", K(ret));
} else {
ins_result.set_affected_rows(ins_rtdef_->affected_rows_);
ins_result.set_is_duplicated(ins_rtdef_->is_duplicated_);
ins_result.set_affected_rows(affected_rows_);
ins_result.set_is_duplicated(is_duplicated_);
has_more = false;
memory_limit -= ins_result.get_result_buffer().get_mem_used();
}
} else {
ins_result.set_affected_rows(ins_rtdef_->affected_rows_);
ins_result.set_affected_rows(affected_rows_);
has_more = false;
}
}
@ -387,7 +393,9 @@ int ObDASInsertResult::get_next_row(ObNewRow *&row)
int ret = OB_SUCCESS;
ObNewRow *result_row = NULL;
if (OB_FAIL(result_newrow_iter_.get_next_row(result_row))) {
LOG_WARN("get next row from result iter failed", K(ret));
if (ret != OB_ITER_END) {
LOG_WARN("get next row from result iter failed", K(ret));
}
} else {
row = result_row;
}
@ -431,7 +439,7 @@ void ObDASInsertResult::reset()
output_types_ = nullptr;
}
int ObDASInsertResult::init(const ObIDASTaskOp &op)
int ObDASInsertResult::init(const ObIDASTaskOp &op, common::ObIAllocator &alloc)
{
int ret = OB_SUCCESS;
const ObDASInsertOp &ins_op = static_cast<const ObDASInsertOp&>(op);
@ -445,7 +453,7 @@ int ObDASInsertResult::init(const ObIDASTaskOp &op)
tenant_id = MTL_ID();
// replace和insert_up拉回冲突数据的das_write_buff暂时不需要带pay_load
if (!result_buffer_.is_inited()
&& OB_FAIL(result_buffer_.init(ins_op.op_alloc_, 0 /*row_extend_size*/, tenant_id, "DASInsRsultBuffer"))) {
&& OB_FAIL(result_buffer_.init(alloc, 0 /*row_extend_size*/, tenant_id, "DASInsRsultBuffer"))) {
LOG_WARN("init result buffer failed", K(ret));
}
}