Skip to content

Commit

Permalink
Import Arc consistently (#12899)
Browse files Browse the repository at this point in the history
Just a code cleanup

In many places the qualified name is redundant since `Arc` is already
imported. In some `use` was added. In all cases `Arc` is unambiguous.
  • Loading branch information
findepi authored Oct 15, 2024
1 parent 377a4c5 commit d9450da
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 28 deletions.
4 changes: 2 additions & 2 deletions datafusion-examples/examples/custom_file_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl FileFormatFactory for TSVFileFactory {
&self,
state: &SessionState,
format_options: &std::collections::HashMap<String, String>,
) -> Result<std::sync::Arc<dyn FileFormat>> {
) -> Result<Arc<dyn FileFormat>> {
let mut new_options = format_options.clone();
new_options.insert("format.delimiter".to_string(), "\t".to_string());

Expand All @@ -164,7 +164,7 @@ impl FileFormatFactory for TSVFileFactory {
Ok(tsv_file_format)
}

fn default(&self) -> std::sync::Arc<dyn FileFormat> {
fn default(&self) -> Arc<dyn FileFormat> {
todo!()
}

Expand Down
4 changes: 3 additions & 1 deletion datafusion/functions/src/regex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

//! "regex" DataFusion functions
use std::sync::Arc;

pub mod regexplike;
pub mod regexpmatch;
pub mod regexpreplace;
Expand Down Expand Up @@ -67,6 +69,6 @@ pub mod expr_fn {
}

/// Returns all DataFusion functions defined in this package
pub fn functions() -> Vec<std::sync::Arc<datafusion_expr::ScalarUDF>> {
pub fn functions() -> Vec<Arc<datafusion_expr::ScalarUDF>> {
vec![regexp_match(), regexp_like(), regexp_replace()]
}
4 changes: 3 additions & 1 deletion datafusion/optimizer/src/replace_distinct_aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
// under the License.

//! [`ReplaceDistinctWithAggregate`] replaces `DISTINCT ...` with `GROUP BY ...`
use crate::optimizer::{ApplyOrder, ApplyOrder::BottomUp};
use crate::{OptimizerConfig, OptimizerRule};
use std::sync::Arc;

use datafusion_common::tree_node::Transformed;
use datafusion_common::{Column, Result};
Expand Down Expand Up @@ -110,7 +112,7 @@ impl OptimizerRule for ReplaceDistinctWithAggregate {
let expr_cnt = on_expr.len();

// Construct the aggregation expression to be used to fetch the selected expressions.
let first_value_udaf: std::sync::Arc<datafusion_expr::AggregateUDF> =
let first_value_udaf: Arc<datafusion_expr::AggregateUDF> =
config.function_registry().unwrap().udaf("first_value")?;
let aggr_expr = select_expr.into_iter().map(|e| {
if let Some(order_by) = &sort_expr {
Expand Down
4 changes: 2 additions & 2 deletions datafusion/physical-plan/src/metrics/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use parking_lot::Mutex;
#[derive(Debug, Clone)]
pub struct Count {
/// value of the metric counter
value: std::sync::Arc<AtomicUsize>,
value: Arc<AtomicUsize>,
}

impl PartialEq for Count {
Expand Down Expand Up @@ -86,7 +86,7 @@ impl Count {
#[derive(Debug, Clone)]
pub struct Gauge {
/// value of the metric gauge
value: std::sync::Arc<AtomicUsize>,
value: Arc<AtomicUsize>,
}

impl PartialEq for Gauge {
Expand Down
30 changes: 10 additions & 20 deletions datafusion/proto/src/logical_plan/file_formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,14 @@ impl LogicalExtensionCodec for CsvLogicalExtensionCodec {
_table_ref: &TableReference,
_schema: arrow::datatypes::SchemaRef,
_ctx: &datafusion::prelude::SessionContext,
) -> datafusion_common::Result<
std::sync::Arc<dyn datafusion::datasource::TableProvider>,
> {
) -> datafusion_common::Result<Arc<dyn datafusion::datasource::TableProvider>> {
not_impl_err!("Method not implemented")
}

fn try_encode_table_provider(
&self,
_table_ref: &TableReference,
_node: std::sync::Arc<dyn datafusion::datasource::TableProvider>,
_node: Arc<dyn datafusion::datasource::TableProvider>,
_buf: &mut Vec<u8>,
) -> datafusion_common::Result<()> {
not_impl_err!("Method not implemented")
Expand Down Expand Up @@ -292,16 +290,14 @@ impl LogicalExtensionCodec for JsonLogicalExtensionCodec {
_table_ref: &TableReference,
_schema: arrow::datatypes::SchemaRef,
_ctx: &datafusion::prelude::SessionContext,
) -> datafusion_common::Result<
std::sync::Arc<dyn datafusion::datasource::TableProvider>,
> {
) -> datafusion_common::Result<Arc<dyn datafusion::datasource::TableProvider>> {
not_impl_err!("Method not implemented")
}

fn try_encode_table_provider(
&self,
_table_ref: &TableReference,
_node: std::sync::Arc<dyn datafusion::datasource::TableProvider>,
_node: Arc<dyn datafusion::datasource::TableProvider>,
_buf: &mut Vec<u8>,
) -> datafusion_common::Result<()> {
not_impl_err!("Method not implemented")
Expand Down Expand Up @@ -591,16 +587,14 @@ impl LogicalExtensionCodec for ParquetLogicalExtensionCodec {
_table_ref: &TableReference,
_schema: arrow::datatypes::SchemaRef,
_ctx: &datafusion::prelude::SessionContext,
) -> datafusion_common::Result<
std::sync::Arc<dyn datafusion::datasource::TableProvider>,
> {
) -> datafusion_common::Result<Arc<dyn datafusion::datasource::TableProvider>> {
not_impl_err!("Method not implemented")
}

fn try_encode_table_provider(
&self,
_table_ref: &TableReference,
_node: std::sync::Arc<dyn datafusion::datasource::TableProvider>,
_node: Arc<dyn datafusion::datasource::TableProvider>,
_buf: &mut Vec<u8>,
) -> datafusion_common::Result<()> {
not_impl_err!("Method not implemented")
Expand Down Expand Up @@ -681,16 +675,14 @@ impl LogicalExtensionCodec for ArrowLogicalExtensionCodec {
_table_ref: &TableReference,
_schema: arrow::datatypes::SchemaRef,
_ctx: &datafusion::prelude::SessionContext,
) -> datafusion_common::Result<
std::sync::Arc<dyn datafusion::datasource::TableProvider>,
> {
) -> datafusion_common::Result<Arc<dyn datafusion::datasource::TableProvider>> {
not_impl_err!("Method not implemented")
}

fn try_encode_table_provider(
&self,
_table_ref: &TableReference,
_node: std::sync::Arc<dyn datafusion::datasource::TableProvider>,
_node: Arc<dyn datafusion::datasource::TableProvider>,
_buf: &mut Vec<u8>,
) -> datafusion_common::Result<()> {
not_impl_err!("Method not implemented")
Expand Down Expand Up @@ -741,16 +733,14 @@ impl LogicalExtensionCodec for AvroLogicalExtensionCodec {
_table_ref: &TableReference,
_schema: arrow::datatypes::SchemaRef,
_cts: &datafusion::prelude::SessionContext,
) -> datafusion_common::Result<
std::sync::Arc<dyn datafusion::datasource::TableProvider>,
> {
) -> datafusion_common::Result<Arc<dyn datafusion::datasource::TableProvider>> {
not_impl_err!("Method not implemented")
}

fn try_encode_table_provider(
&self,
_table_ref: &TableReference,
_node: std::sync::Arc<dyn datafusion::datasource::TableProvider>,
_node: Arc<dyn datafusion::datasource::TableProvider>,
_buf: &mut Vec<u8>,
) -> datafusion_common::Result<()> {
not_impl_err!("Method not implemented")
Expand Down
3 changes: 1 addition & 2 deletions datafusion/substrait/tests/cases/roundtrip_logical_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ impl SerializerRegistry for MockSerializerRegistry {
&self,
name: &str,
bytes: &[u8],
) -> Result<std::sync::Arc<dyn datafusion::logical_expr::UserDefinedLogicalNode>>
{
) -> Result<Arc<dyn datafusion::logical_expr::UserDefinedLogicalNode>> {
if name == "MockUserDefinedLogicalPlan" {
MockUserDefinedLogicalPlan::deserialize(bytes)
} else {
Expand Down

0 comments on commit d9450da

Please sign in to comment.