dujl commented on code in PR #10402: URL: https://github.com/apache/doris/pull/10402#discussion_r908099929
########## be/src/vec/exec/file_scan_node.cpp: ########## @@ -0,0 +1,334 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "vec/exec/file_scan_node.h" + +#include "gen_cpp/PlanNodes_types.h" +#include "runtime/mem_tracker.h" +#include "runtime/runtime_state.h" +#include "runtime/string_value.h" +#include "runtime/tuple.h" +#include "runtime/tuple_row.h" +#include "util/runtime_profile.h" +#include "util/thread.h" +#include "util/types.h" +#include "vec/exec/file_arrow_scanner.h" +#include "vec/exec/file_text_scanner.h" +#include "vec/exprs/vexpr_context.h" + +namespace doris::vectorized { + +FileScanNode::FileScanNode(ObjectPool* pool, const TPlanNode& tnode, const DescriptorTbl& descs) + : ScanNode(pool, tnode, descs), + _tuple_id(tnode.file_scan_node.tuple_id), + _runtime_state(nullptr), + _tuple_desc(nullptr), + _num_running_scanners(0), + _scan_finished(false), + _max_buffered_batches(32), + _wait_scanner_timer(nullptr) {} + +Status FileScanNode::init(const TPlanNode& tnode, RuntimeState* state) { + RETURN_IF_ERROR(ScanNode::init(tnode, state)); + auto& file_scan_node = tnode.file_scan_node; + + if (file_scan_node.__isset.pre_filter_exprs) { + _pre_filter_texprs = file_scan_node.pre_filter_exprs; + } + + return Status::OK(); +} + +Status FileScanNode::prepare(RuntimeState* state) { + VLOG_QUERY << "FileScanNode prepare"; + RETURN_IF_ERROR(ScanNode::prepare(state)); + SCOPED_SWITCH_TASK_THREAD_LOCAL_MEM_TRACKER(mem_tracker()); + // get tuple desc + _runtime_state = state; + _tuple_desc = state->desc_tbl().get_tuple_descriptor(_tuple_id); + if (_tuple_desc == nullptr) { + std::stringstream ss; + ss << "Failed to get tuple descriptor, _tuple_id=" << _tuple_id; + return Status::InternalError(ss.str()); + } + + // Initialize slots map + for (auto slot : _tuple_desc->slots()) { + auto pair = _slots_map.emplace(slot->col_name(), slot); + if (!pair.second) { + std::stringstream ss; + ss << "Failed to insert slot, col_name=" << slot->col_name(); + return Status::InternalError(ss.str()); + } + } + + // Profile + _wait_scanner_timer = ADD_TIMER(runtime_profile(), "WaitScannerTime"); + + return Status::OK(); +} + +Status FileScanNode::open(RuntimeState* state) { + SCOPED_TIMER(_runtime_profile->total_time_counter()); + SCOPED_SWITCH_TASK_THREAD_LOCAL_MEM_TRACKER(mem_tracker()); + RETURN_IF_ERROR(ExecNode::open(state)); + RETURN_IF_ERROR(exec_debug_action(TExecNodePhase::OPEN)); + RETURN_IF_CANCELLED(state); + + RETURN_IF_ERROR(start_scanners()); + + return Status::OK(); +} + +Status FileScanNode::start_scanners() { + { + std::unique_lock<std::mutex> l(_batch_queue_lock); + _num_running_scanners = 1; + } + _scanner_threads.emplace_back(&FileScanNode::scanner_worker, this, 0, _scan_ranges.size()); Review Comment: always start only one thread to scan the ranges? -- 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. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org