wangbo commented on code in PR #19924: URL: https://github.com/apache/doris/pull/19924#discussion_r1218092392
########## be/src/vec/exec/scan/scan_task_queue.h: ########## @@ -0,0 +1,102 @@ +// 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. +#pragma once + +#include "olap/tablet.h" +#include "runtime/task_group/task_group.h" +#include "util/blocking_priority_queue.hpp" + +namespace doris { +namespace vectorized { +class ScannerContext; +}; + +namespace taskgroup { + +using WorkFunction = std::function<void()>; +static constexpr auto WAIT_CORE_TASK_TIMEOUT_MS = 100; + +// Like PriorityThreadPool::Task +struct ScanTask { + ScanTask(); + ScanTask(WorkFunction scan_func, vectorized::ScannerContext* scanner_context); + bool operator<(const ScanTask& o) const { return priority < o.priority; } + ScanTask& operator++() { + priority += 2; + return *this; + } + + int priority; + WorkFunction scan_func; + vectorized::ScannerContext* scanner_context; +}; + +// Like pipeline::PriorityTaskQueue use BlockingPriorityQueue directly? +class ScanTaskQueue { +public: + ScanTaskQueue(); + Status try_push_back(ScanTask); + bool try_get(ScanTask* scan_task, uint32_t timeout_ms); + int size() { return _queue.get_size(); } + +private: + BlockingPriorityQueue<ScanTask> _queue; +}; + +// Like TaskGroupTaskQueue +class ScanTaskTaskGroupQueue { +public: + explicit ScanTaskTaskGroupQueue(size_t core_size); + ~ScanTaskTaskGroupQueue(); + + void close(); + bool take(ScanTask* scan_task); + template <TabletStorageType storage_type> + bool push_back(ScanTask); + + // ScanTask可以用ScannerContext代替 Review Comment: In english -- 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