* chore: adjudicate the last 18 bare dead_code allows in the library crates Finishes backlog#1823 step 10 outside `rustfs/src` and `protocols`: config, s3select-query, common, madmin, heal, ecstore, signer and notify. Stripped first, then clippy asked which the compiler actually missed — 8 of the 18 were inert. Seven items are deleted, each checked by grep as well as by clippy: - `common/last_minute.rs`'s private `TimedAction` (with its impl) and `SizeCategory` (with its `Display` impl). The file's public surface — `AccElem`, `LastMinuteLatency` — stays; ecstore consumes it. - `s3select-query`'s three `with_*` builders. `DefaultLogicalOptimizer::with_optimizer_rules` looks used, but the call in the same file is `SessionStateBuilder::with_optimizer_rules` from DataFusion; the local methods have no callers. - `heal/manager.rs`'s `contains_key`. Its six apparent references are all `HashMap::contains_key`. Three keep their code: - `heal/storage.rs`'s `Test` variant is constructed by the `#[cfg(test)] test()` helper, which the lib target cannot see, so it takes a reasoned allow. - `signer`'s `STREAMING_PAYLOAD_HDR` and `try_build_chunk_string_to_sign` gain the `_` prefix instead. That file already marks deliberately-unheld code that way — `_STREAMING_TRAILER_HDR`, `_PAYLOAD_CHUNK_SIZE`, and `_try_build_chunk_signature`, which is the only caller of that function. Following the existing convention removes the allow without an attribute. `protocols` keeps its four; that crate needs `--features swift,sftp` to compile fully and is verified differently. The four `#![allow(dead_code)]` in `e2e_test` are module-root blankets in test-support files, which belong to steps 1-5 rather than step 10. Refs backlog#1823 * chore(e2e_test): adjudicate the two dead_code allows the lib test target still needs `cargo clippy --all-targets` compiles e2e_test's lib test target, which the earlier pass did not cover, so these two removals only surfaced in CI. test_large_multipart_upload's allow was load-bearing: its call site in test_local_kms_multipart_upload is commented out behind "TODO: Re-enable after fixing streaming encryption issues with large files". The allow comes back with the reason string this batch uses everywhere else, so the next reader sees why it is parked instead of deleting a test we intend to run again. TestDefinition.category was the opposite: written at all six definitions, read nowhere, and its enum's impl block is empty. The live copy of that type is crates/e2e_test/src/kms/test_runner.rs, which has an as_str; the policy copy is a vestige of it. Dropping the field, the enum, and the constructor parameter leaves the runner unchanged — it dispatches on name and filters on is_critical. Verification: cargo clippy --all-targets -- -D warnings (workspace, the CI command) and cargo fmt --all --check both pass. --------- Co-authored-by: houseme <[email protected]>
103 lines
4.1 KiB
Rust
103 lines
4.1 KiB
Rust
// Copyright 2024 RustFS Team
|
|
//
|
|
// 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 async_trait::async_trait;
|
|
use datafusion::execution::SessionStateBuilder;
|
|
use datafusion::logical_expr::LogicalPlan;
|
|
use datafusion::physical_optimizer::PhysicalOptimizerRule;
|
|
use datafusion::physical_optimizer::aggregate_statistics::AggregateStatistics;
|
|
use datafusion::physical_optimizer::join_selection::JoinSelection;
|
|
use datafusion::physical_plan::ExecutionPlan;
|
|
use datafusion::physical_planner::{
|
|
DefaultPhysicalPlanner as DFDefaultPhysicalPlanner, ExtensionPlanner, PhysicalPlanner as DFPhysicalPlanner,
|
|
};
|
|
use rustfs_s3select_api::QueryResult;
|
|
use rustfs_s3select_api::query::physical_planner::PhysicalPlanner;
|
|
use rustfs_s3select_api::query::session::SessionCtx;
|
|
|
|
use super::optimizer::PhysicalOptimizer;
|
|
|
|
pub struct DefaultPhysicalPlanner {
|
|
ext_physical_transform_rules: Vec<Arc<dyn ExtensionPlanner + Send + Sync>>,
|
|
/// Responsible for optimizing a physical execution plan
|
|
ext_physical_optimizer_rules: Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>>,
|
|
}
|
|
|
|
impl DefaultPhysicalPlanner {}
|
|
|
|
impl DefaultPhysicalPlanner {}
|
|
|
|
impl Default for DefaultPhysicalPlanner {
|
|
fn default() -> Self {
|
|
let ext_physical_transform_rules: Vec<Arc<dyn ExtensionPlanner + Send + Sync>> = vec![
|
|
// can add rules at here
|
|
];
|
|
|
|
// We need to take care of the rule ordering. They may influence each other.
|
|
let ext_physical_optimizer_rules: Vec<Arc<dyn PhysicalOptimizerRule + Sync + Send>> = vec![
|
|
Arc::new(AggregateStatistics::new()),
|
|
// Statistics-based join selection will change the Auto mode to a real join implementation,
|
|
// like collect left, or hash join, or future sort merge join, which will influence the
|
|
// EnforceDistribution and EnforceSorting rules as they decide whether to add additional
|
|
// repartitioning and local sorting steps to meet distribution and ordering requirements.
|
|
// Therefore, it should run before EnforceDistribution and EnforceSorting.
|
|
Arc::new(JoinSelection::new()),
|
|
];
|
|
|
|
Self {
|
|
ext_physical_transform_rules,
|
|
ext_physical_optimizer_rules,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[async_trait]
|
|
impl PhysicalPlanner for DefaultPhysicalPlanner {
|
|
async fn create_physical_plan(
|
|
&self,
|
|
logical_plan: &LogicalPlan,
|
|
session: &SessionCtx,
|
|
) -> QueryResult<Arc<dyn ExecutionPlan>> {
|
|
// Inject extended physical plan optimization rules into df's session state
|
|
let new_state = SessionStateBuilder::new_from_existing(session.inner().clone())
|
|
.with_physical_optimizer_rules(self.ext_physical_optimizer_rules.clone())
|
|
.build();
|
|
|
|
// Construct df's Physical Planner with extended physical plan transformation rules
|
|
let planner = DFDefaultPhysicalPlanner::with_extension_planners(self.ext_physical_transform_rules.clone());
|
|
|
|
// Execute df's physical plan planning and optimization
|
|
planner
|
|
.create_physical_plan(logical_plan, &new_state)
|
|
.await
|
|
.map_err(|e| e.into())
|
|
}
|
|
|
|
fn inject_physical_transform_rule(&mut self, rule: Arc<dyn ExtensionPlanner + Send + Sync>) {
|
|
self.ext_physical_transform_rules.push(rule)
|
|
}
|
|
}
|
|
|
|
impl PhysicalOptimizer for DefaultPhysicalPlanner {
|
|
fn optimize(&self, plan: Arc<dyn ExecutionPlan>, _session: &SessionCtx) -> QueryResult<Arc<dyn ExecutionPlan>> {
|
|
Ok(plan)
|
|
}
|
|
|
|
fn inject_optimizer_rule(&mut self, optimizer_rule: Arc<dyn PhysicalOptimizerRule + Send + Sync>) {
|
|
self.ext_physical_optimizer_rules.push(optimizer_rule);
|
|
}
|
|
}
|