github-actions[bot] commented on code in PR #40273: URL: https://github.com/apache/doris/pull/40273#discussion_r1740781512
########## be/test/vec/exec/vfile_scanner_exception_test.cpp: ########## @@ -0,0 +1,307 @@ +// 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 <gtest/gtest.h> + +#include <string> +#include <vector> + +#include "common/object_pool.h" +#include "cpp/sync_point.h" +#include "gen_cpp/Descriptors_types.h" +#include "gen_cpp/PlanNodes_types.h" +#include "io/fs/local_file_system.h" +#include "olap/wal/wal_manager.h" +#include "pipeline/exec/file_scan_operator.h" +#include "runtime/descriptors.h" +#include "runtime/memory/mem_tracker.h" +#include "runtime/runtime_state.h" +#include "runtime/user_function_cache.h" +#include "vec/exec/scan/vfile_scanner.h" + +namespace doris { + +namespace vectorized { Review Comment: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces] ```suggestion namespace doris::vectorized { ``` be/test/vec/exec/vfile_scanner_exception_test.cpp:305: ```diff - } // namespace vectorized - } // namespace doris + } // namespace doris ``` ########## be/test/vec/exec/vfile_scanner_exception_test.cpp: ########## @@ -0,0 +1,307 @@ +// 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 <gtest/gtest.h> + +#include <string> +#include <vector> + +#include "common/object_pool.h" +#include "cpp/sync_point.h" +#include "gen_cpp/Descriptors_types.h" +#include "gen_cpp/PlanNodes_types.h" +#include "io/fs/local_file_system.h" +#include "olap/wal/wal_manager.h" +#include "pipeline/exec/file_scan_operator.h" +#include "runtime/descriptors.h" +#include "runtime/memory/mem_tracker.h" +#include "runtime/runtime_state.h" +#include "runtime/user_function_cache.h" +#include "vec/exec/scan/vfile_scanner.h" + +namespace doris { + +namespace vectorized { + +class TestSplitSourceConnectorStub : public SplitSourceConnector { +private: + std::mutex _range_lock; + TFileScanRange _scan_range; + int _range_index = 0; + +public: + TestSplitSourceConnectorStub(const TFileScanRange& scan_range) : _scan_range(scan_range) {} + + Status get_next(bool* has_next, TFileRangeDesc* range) override { + std::lock_guard<std::mutex> l(_range_lock); + if (_range_index < _scan_range.ranges.size()) { + *has_next = true; + *range = _scan_range.ranges[_range_index++]; + } else { + *has_next = false; + } + return Status::OK(); + } + + int num_scan_ranges() override { return _scan_range.ranges.size(); } + + TFileScanRangeParams* get_params() override { return &_scan_range.params; } +}; + +class VfileScannerExceptionTest : public testing::Test { +public: + VfileScannerExceptionTest() + : _runtime_state(TQueryGlobals()), _global_profile("<global profile>") { + _runtime_state.resize_op_id_to_local_state(-1); + init(); + _profile = _runtime_state.runtime_profile(); + WARN_IF_ERROR(_runtime_state.init(_unique_id, _query_options, _query_globals, _env), + "fail to init _runtime_state"); + } + void init(); + void generate_scanner(std::shared_ptr<VFileScanner>& scanner); + + void TearDown() override { + WARN_IF_ERROR(_scan_node->close(&_runtime_state), "fail to close scan_node") + } + +protected: + virtual void SetUp() override {} Review Comment: warning: 'virtual' is redundant since the function is already declared 'override' [modernize-use-override] ```suggestion void SetUp() override {} ``` ########## be/test/vec/exec/vfile_scanner_exception_test.cpp: ########## @@ -0,0 +1,307 @@ +// 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 <gtest/gtest.h> + +#include <string> +#include <vector> + +#include "common/object_pool.h" +#include "cpp/sync_point.h" +#include "gen_cpp/Descriptors_types.h" +#include "gen_cpp/PlanNodes_types.h" +#include "io/fs/local_file_system.h" +#include "olap/wal/wal_manager.h" +#include "pipeline/exec/file_scan_operator.h" +#include "runtime/descriptors.h" +#include "runtime/memory/mem_tracker.h" +#include "runtime/runtime_state.h" +#include "runtime/user_function_cache.h" +#include "vec/exec/scan/vfile_scanner.h" + +namespace doris { + +namespace vectorized { + +class TestSplitSourceConnectorStub : public SplitSourceConnector { +private: + std::mutex _range_lock; + TFileScanRange _scan_range; + int _range_index = 0; + +public: + TestSplitSourceConnectorStub(const TFileScanRange& scan_range) : _scan_range(scan_range) {} + + Status get_next(bool* has_next, TFileRangeDesc* range) override { + std::lock_guard<std::mutex> l(_range_lock); + if (_range_index < _scan_range.ranges.size()) { + *has_next = true; + *range = _scan_range.ranges[_range_index++]; + } else { + *has_next = false; + } + return Status::OK(); + } + + int num_scan_ranges() override { return _scan_range.ranges.size(); } + + TFileScanRangeParams* get_params() override { return &_scan_range.params; } +}; + +class VfileScannerExceptionTest : public testing::Test { +public: + VfileScannerExceptionTest() + : _runtime_state(TQueryGlobals()), _global_profile("<global profile>") { + _runtime_state.resize_op_id_to_local_state(-1); + init(); + _profile = _runtime_state.runtime_profile(); + WARN_IF_ERROR(_runtime_state.init(_unique_id, _query_options, _query_globals, _env), + "fail to init _runtime_state"); + } + void init(); + void generate_scanner(std::shared_ptr<VFileScanner>& scanner); + + void TearDown() override { + WARN_IF_ERROR(_scan_node->close(&_runtime_state), "fail to close scan_node") + } + +protected: + virtual void SetUp() override {} + +private: + void _init_desc_table(); + + ExecEnv* _env = nullptr; + int64_t _backend_id = 1001; + std::string _label_1 = "test1"; + std::string _label_2 = "test2"; + + TupleId _dst_tuple_id = 0; + RuntimeState _runtime_state; + RuntimeProfile _global_profile; + RuntimeProfile* _profile; + ObjectPool _obj_pool; + DescriptorTbl* _desc_tbl; + std::vector<TNetworkAddress> _addresses; + ScannerCounter _counter; + std::vector<TExpr> _pre_filter; + TPlanNode _tnode; + TUniqueId _unique_id; + TQueryOptions _query_options; + TQueryGlobals _query_globals; + std::shared_ptr<pipeline::FileScanOperatorX> _scan_node = nullptr; + std::vector<TFileRangeDesc> _ranges; + TFileRangeDesc _range_desc; + TFileScanRange _scan_range; + std::unique_ptr<ShardedKVCache> _kv_cache = nullptr; + std::unique_ptr<TMasterInfo> _master_info = nullptr; +}; + +void VfileScannerExceptionTest::_init_desc_table() { Review Comment: warning: function '_init_desc_table' exceeds recommended size/complexity thresholds [readability-function-size] ```cpp void VfileScannerExceptionTest::_init_desc_table() { ^ ``` <details> <summary>Additional context</summary> **be/test/vec/exec/vfile_scanner_exception_test.cpp:112:** 117 lines including whitespace and comments (threshold 80) ```cpp void VfileScannerExceptionTest::_init_desc_table() { ^ ``` </details> -- 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