morningman commented on code in PR #34032: URL: https://github.com/apache/doris/pull/34032#discussion_r1593756020
########## fe/fe-core/src/main/java/org/apache/doris/datasource/FileQueryScanNode.java: ########## @@ -319,70 +320,43 @@ public void createScanRangeLocations() throws UserException { List<String> pathPartitionKeys = getPathPartitionKeys(); Multimap<Backend, Split> assignment = backendPolicy.computeScanRangeAssignment(inputSplits); + int batchModeSize = Config.num_splits_in_batch_mode; for (Backend backend : assignment.keySet()) { Collection<Split> splits = assignment.get(backend); - for (Split split : splits) { - FileSplit fileSplit = (FileSplit) split; + if (batchModeSize > 0 && splits.size() > batchModeSize) { + SplitSource splitSource = new SplitSource( + this::splitToScanRange, backend, locationProperties, splits, pathPartitionKeys); + splitSources.add(splitSource); + SplitSourceManager.registerSplitSource(splitSource); Review Comment: Do not use singleton ########## fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java: ########## @@ -966,6 +971,22 @@ public TReportExecStatusResult reportExecStatus(TReportExecStatusParams params) return QeProcessorImpl.INSTANCE.reportExecStatus(params, getClientAddr()); } + public TFetchSplitBatchResult fetchSplitBatch(TFetchSplitBatchRequest request) throws TException { Review Comment: Missing @Override ########## be/src/vec/exec/scan/split_source_connector.cpp: ########## @@ -0,0 +1,86 @@ +// 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/scan/split_source_connector.h" + +#include "runtime/exec_env.h" +#include "runtime/query_context.h" + +namespace doris::vectorized { + +using apache::thrift::transport::TTransportException; + +Status LocalSplitSourceConnector::get_next(bool* has_next, TFileRangeDesc* range) { + std::lock_guard<std::mutex> l(_range_lock); + *has_next = false; + if (_scan_index < _scan_ranges.size()) { + auto& ranges = _scan_ranges[_scan_index].scan_range.ext_scan_range.file_scan_range.ranges; + if (_range_index < ranges.size()) { + *has_next = true; + *range = ranges[_range_index++]; + if (_range_index == ranges.size()) { + _scan_index++; + _range_index = 0; + } + } + } + return Status::OK(); +} + +Status RemoteSplitSourceConnector::get_next(bool* has_next, TFileRangeDesc* range) { + std::lock_guard<std::mutex> l(_range_lock); + *has_next = false; + if (_scan_index == _scan_ranges.size() && !_last_batch) { + Status coord_status; + FrontendServiceConnection coord(_state->exec_env()->frontend_client_cache(), + _state->get_query_ctx()->coord_addr, &coord_status); + RETURN_IF_ERROR(coord_status); + TFetchSplitBatchRequest request; + request.__set_split_source_id(_split_source_id); + request.__set_max_num_splits(config::remote_split_source_batch_size); + TFetchSplitBatchResult result; + try { + coord->fetchSplitBatch(result, request); + } catch (TTransportException& e1) { + LOG(WARNING) << "Failed to get batch of split source: {}, try to reopen" << e1.what(); + RETURN_IF_ERROR(coord.reopen()); + try { + coord->fetchSplitBatch(result, request); Review Comment: Maybe we should not retry when failure. If first call fail, it is highly possible the second would fail too. Simply fail this query to avoid avalanche ########## fe/fe-core/src/main/java/org/apache/doris/datasource/SplitSourceManager.java: ########## @@ -0,0 +1,68 @@ +// 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. + +package org.apache.doris.datasource; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class SplitSourceManager { Review Comment: Suggest: 1. not using singletion 2. extends `MasterDaemon` class -- 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