-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(executor): globalize
QueriesPipelineExecutor
creation meth…
…od (#15129) * refactor: globalize `QueriesPipelineExecutor` creation method * fix: unit test and clippy warn * fix: executor should also return execution result Signed-off-by: Liuqing Yue <dqhl76@gmail.com> * chore: disable queries executor and ensure not affecting currently using executor Signed-off-by: Liuqing Yue <dqhl76@gmail.com> * chore: disable queries executor and ensure not affecting currently using executor Signed-off-by: Liuqing Yue <dqhl76@gmail.com> * chore: use compile feature to disable queries executor Signed-off-by: Liuqing Yue <dqhl76@gmail.com> * fix: make clippy happy Signed-off-by: Liuqing Yue <dqhl76@gmail.com> --------- Signed-off-by: Liuqing Yue <dqhl76@gmail.com>
- Loading branch information
Showing
12 changed files
with
111 additions
and
53 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/query/service/src/pipelines/executor/global_queries_executor.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2021 Datafuse Labs | ||
// | ||
// Licensed 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. | ||
|
||
use std::sync::Arc; | ||
|
||
use databend_common_base::base::GlobalInstance; | ||
use databend_common_base::runtime::Thread; | ||
use databend_common_exception::Result; | ||
use log::info; | ||
|
||
use crate::pipelines::executor::QueriesPipelineExecutor; | ||
|
||
pub struct GlobalQueriesExecutor(pub QueriesPipelineExecutor); | ||
|
||
impl GlobalQueriesExecutor { | ||
pub fn init() -> Result<()> { | ||
let num_cpus = num_cpus::get(); | ||
GlobalInstance::set(QueriesPipelineExecutor::create(num_cpus)?); | ||
Thread::spawn(|| { | ||
if let Err(e) = Self::instance().execute() { | ||
info!("Executor finished with error: {:?}", e); | ||
} | ||
}); | ||
Ok(()) | ||
} | ||
|
||
pub fn instance() -> Arc<QueriesPipelineExecutor> { | ||
GlobalInstance::get() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters