[refactor](non-vec) delete some non-vec exec node (#15239)

* [refactor](non-vec) delete some non-vec exec node
This commit is contained in:
Gabriel
2022-12-22 14:05:51 +08:00
committed by GitHub
parent 1520a4af6d
commit e9a201e0ec
176 changed files with 1698 additions and 41644 deletions

View File

@ -25,7 +25,7 @@ namespace doris::vectorized {
VTableFunctionNode::VTableFunctionNode(ObjectPool* pool, const TPlanNode& tnode,
const DescriptorTbl& descs)
: TableFunctionNode(pool, tnode, descs) {}
: ExecNode(pool, tnode, descs) {}
Status VTableFunctionNode::init(const TPlanNode& tnode, RuntimeState* state) {
RETURN_IF_ERROR(ExecNode::init(tnode, state));
@ -51,9 +51,46 @@ Status VTableFunctionNode::init(const TPlanNode& tnode, RuntimeState* state) {
return Status::OK();
}
Status VTableFunctionNode::_prepare_output_slot_ids(const TPlanNode& tnode) {
// Prepare output slot ids
if (tnode.table_function_node.outputSlotIds.empty()) {
return Status::InternalError("Output slots of table function node is empty");
}
SlotId max_id = -1;
for (auto slot_id : tnode.table_function_node.outputSlotIds) {
if (slot_id > max_id) {
max_id = slot_id;
}
}
_output_slot_ids = std::vector<bool>(max_id + 1, false);
for (auto slot_id : tnode.table_function_node.outputSlotIds) {
_output_slot_ids[slot_id] = true;
}
return Status::OK();
}
bool VTableFunctionNode::_is_inner_and_empty() {
for (int i = 0; i < _fn_num; i++) {
// if any table function is not outer and has empty result, go to next child row
if (!_fns[i]->is_outer() && _fns[i]->current_empty()) {
return true;
}
}
return false;
}
Status VTableFunctionNode::prepare(RuntimeState* state) {
SCOPED_TIMER(_runtime_profile->total_time_counter());
RETURN_IF_ERROR(TableFunctionNode::prepare(state));
RETURN_IF_ERROR(ExecNode::prepare(state));
SCOPED_CONSUME_MEM_TRACKER(mem_tracker_growh());
_num_rows_filtered_counter = ADD_COUNTER(_runtime_profile, "RowsFiltered", TUnit::UNIT);
RETURN_IF_ERROR(Expr::prepare(_fn_ctxs, state, _row_descriptor));
for (auto fn : _fns) {
RETURN_IF_ERROR(fn->prepare());
}
RETURN_IF_ERROR(VExpr::prepare(_vfn_ctxs, state, _row_descriptor));
// get current all output slots
@ -220,4 +257,63 @@ Status VTableFunctionNode::_process_next_child_row() {
return Status::OK();
}
// Returns the index of fn of the last eos counted from back to front
// eg: there are 3 functions in `_fns`
// eos: false, true, true
// return: 1
//
// eos: false, false, true
// return: 2
//
// eos: false, false, false
// return: -1
//
// eos: true, true, true
// return: 0
//
// return:
// 0: all fns are eos
// -1: all fns are not eos
// >0: some of fns are eos
int VTableFunctionNode::_find_last_fn_eos_idx() {
for (int i = _fn_num - 1; i >= 0; --i) {
if (!_fns[i]->eos()) {
if (i == _fn_num - 1) {
return -1;
} else {
return i + 1;
}
}
}
// all eos
return 0;
}
// Roll to reset the table function.
// Eg:
// There are 3 functions f1, f2 and f3 in `_fns`.
// If `last_eos_idx` is 1, which means f2 and f3 are eos.
// So we need to forward f1, and reset f2 and f3.
bool VTableFunctionNode::_roll_table_functions(int last_eos_idx) {
bool fn_eos = false;
int i = last_eos_idx - 1;
for (; i >= 0; --i) {
_fns[i]->forward(&fn_eos);
if (!fn_eos) {
break;
}
}
if (i == -1) {
// after forward, all functions are eos.
// we should process next child row to get more table function results.
return false;
}
for (int j = i + 1; j < _fn_num; ++j) {
_fns[j]->reset();
}
return true;
}
} // namespace doris::vectorized