yangzhg commented on a change in pull request #3034: implements intersect node URL: https://github.com/apache/incubator-doris/pull/3034#discussion_r388788475
########## File path: be/src/exec/intersect_node.cpp ########## @@ -56,4 +41,164 @@ Status IntersectNode::init(const TPlanNode& tnode, RuntimeState* state) { } return Status::OK(); } -} \ No newline at end of file + +Status IntersectNode::prepare(RuntimeState* state) { + RETURN_IF_ERROR(ExecNode::prepare(state)); + _build_pool.reset(new MemPool(mem_tracker())); + SCOPED_TIMER(_runtime_profile->total_time_counter()); + for (size_t i = 0; i < _child_expr_lists.size(); ++i) { + RETURN_IF_ERROR(Expr::prepare(_child_expr_lists[i], state, child(i)->row_desc(), + expr_mem_tracker())); + } + _build_tuple_size = child(0)->row_desc().tuple_descriptors().size(); + _build_tuple_row_size = _build_tuple_size * sizeof(Tuple*); + _build_tuple_idx.reserve(_build_tuple_size); + + for (int i = 0; i < _build_tuple_size; ++i) { + TupleDescriptor* build_tuple_desc = child(0)->row_desc().tuple_descriptors()[i]; + _build_tuple_idx.push_back(_row_descriptor.get_tuple_idx(build_tuple_desc->id())); + } + _find_nulls = std::vector<bool>(_child_expr_lists.size(), true); + return Status::OK(); +} + +Status IntersectNode::close(RuntimeState* state) { + if (is_closed()) { + return Status::OK(); + } + for (auto& exprs : _child_expr_lists) { + Expr::close(exprs, state); + } + + RETURN_IF_ERROR(exec_debug_action(TExecNodePhase::CLOSE)); + // Must reset _probe_batch in close() to release resources + _probe_batch.reset(NULL); + + if (_memory_used_counter != NULL && _hash_tbl.get() != NULL) { + COUNTER_UPDATE(_memory_used_counter, _build_pool->peak_allocated_bytes()); + COUNTER_UPDATE(_memory_used_counter, _hash_tbl->byte_size()); + } + if (_hash_tbl.get() != NULL) { + _hash_tbl->close(); + } + if (_build_pool.get() != NULL) { + _build_pool->free_all(); + } + + return ExecNode::close(state); +} + +Status IntersectNode::open(RuntimeState* state) { + RETURN_IF_ERROR(ExecNode::open(state)); + RETURN_IF_ERROR(exec_debug_action(TExecNodePhase::OPEN)); + SCOPED_TIMER(_runtime_profile->total_time_counter()); + RETURN_IF_CANCELLED(state); + // open result expr lists. + for (const vector<ExprContext*>& exprs : _child_expr_lists) { + RETURN_IF_ERROR(Expr::open(exprs, state)); + } + + for (int i = 0; i < _children.size(); ++i) { + // initial build hash table + if (_hash_tbl.get() == nullptr || _hash_tbl->size() == 0) { + _hash_tbl.reset(new HashTable(_child_expr_lists[0], _child_expr_lists[i], + _build_tuple_size, false, _find_nulls, id(), + mem_tracker(), 1024)); + RowBatch build_batch(child(0)->row_desc(), state->batch_size(), mem_tracker()); Review comment: no it always use the first tableās row desc ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org