Skip to content

Commit 2e52580

Browse files
Introduce HashMap and HashSet type aliases (apache#13236)
* Unite all references to hashbrown::HashMap by using a common type definition * Replace some use of std::collections::HashMap with hashbrown::HashMap * Replace some use of std::collections::HashMap with hashbrown::HashMap * Replace some use of std::collections::HashMap with hashbrown::HashMap * Unite all references to hashbrown::HashSet by using a common type definition * Replace some use of std::collections::HashSet with hashbrown::HashSet
1 parent eeb9d58 commit 2e52580

File tree

41 files changed

+67
-79
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+67
-79
lines changed

datafusion/common/src/functional_dependencies.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818
//! FunctionalDependencies keeps track of functional dependencies
1919
//! inside DFSchema.
2020
21-
use std::collections::HashSet;
2221
use std::fmt::{Display, Formatter};
2322
use std::ops::Deref;
2423
use std::vec::IntoIter;
2524

2625
use crate::utils::{merge_and_order_indices, set_difference};
27-
use crate::{DFSchema, JoinType};
26+
use crate::{DFSchema, HashSet, JoinType};
2827

2928
/// This object defines a constraint on a table.
3029
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash)]

datafusion/common/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ pub use functional_dependencies::{
6666
get_target_functional_dependencies, Constraint, Constraints, Dependency,
6767
FunctionalDependence, FunctionalDependencies,
6868
};
69+
use hashbrown::hash_map::DefaultHashBuilder;
6970
pub use join_type::{JoinConstraint, JoinSide, JoinType};
7071
pub use param_value::ParamValues;
7172
pub use scalar::{ScalarType, ScalarValue};
@@ -87,6 +88,10 @@ pub use error::{
8788
_substrait_datafusion_err,
8889
};
8990

91+
// The HashMap and HashSet implementations that should be used as the uniform defaults
92+
pub type HashMap<K, V, S = DefaultHashBuilder> = hashbrown::HashMap<K, V, S>;
93+
pub type HashSet<T, S = DefaultHashBuilder> = hashbrown::HashSet<T, S>;
94+
9095
/// Downcast an Arrow Array to a concrete type, return an `DataFusionError::Internal` if the cast is
9196
/// not possible. In normal usage of DataFusion the downcast should always succeed.
9297
///

datafusion/core/src/bin/print_functions_docs.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616
// under the License.
1717

1818
use datafusion::execution::SessionStateDefaults;
19-
use datafusion_common::{not_impl_err, Result};
19+
use datafusion_common::{not_impl_err, HashSet, Result};
2020
use datafusion_expr::{
2121
aggregate_doc_sections, scalar_doc_sections, window_doc_sections, AggregateUDF,
2222
DocSection, Documentation, ScalarUDF, WindowUDF,
2323
};
24-
use hashbrown::HashSet;
2524
use itertools::Itertools;
2625
use std::env::args;
2726
use std::fmt::Write as _;

datafusion/core/src/catalog_common/listing_schema.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@
1818
//! [`ListingSchemaProvider`]: [`SchemaProvider`] that scans ObjectStores for tables automatically
1919
2020
use std::any::Any;
21-
use std::collections::{HashMap, HashSet};
21+
use std::collections::HashSet;
2222
use std::path::Path;
2323
use std::sync::{Arc, Mutex};
2424

2525
use crate::catalog::{SchemaProvider, TableProvider, TableProviderFactory};
2626
use crate::execution::context::SessionState;
2727

28-
use datafusion_common::{Constraints, DFSchema, DataFusionError, TableReference};
28+
use datafusion_common::{
29+
Constraints, DFSchema, DataFusionError, HashMap, TableReference,
30+
};
2931
use datafusion_expr::CreateExternalTable;
3032

3133
use async_trait::async_trait;

datafusion/core/src/datasource/file_format/parquet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ use datafusion_physical_plan::metrics::MetricsSet;
6363

6464
use async_trait::async_trait;
6565
use bytes::Bytes;
66-
use hashbrown::HashMap;
66+
use datafusion_common::HashMap;
6767
use log::debug;
6868
use object_store::buffered::BufWriter;
6969
use parquet::arrow::arrow_writer::{

datafusion/core/src/datasource/listing/helpers.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@
1717

1818
//! Helper functions for the table implementation
1919
20-
use std::collections::HashMap;
2120
use std::mem;
2221
use std::sync::Arc;
2322

2423
use super::ListingTableUrl;
2524
use super::PartitionedFile;
2625
use crate::execution::context::SessionState;
2726
use datafusion_common::internal_err;
28-
use datafusion_common::{Result, ScalarValue};
27+
use datafusion_common::{HashMap, Result, ScalarValue};
2928
use datafusion_expr::{BinaryExpr, Operator};
3029

3130
use arrow::{

datafusion/core/src/physical_optimizer/sort_pushdown.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use crate::physical_plan::{ExecutionPlan, ExecutionPlanProperties};
3232
use datafusion_common::tree_node::{
3333
ConcreteTreeNode, Transformed, TreeNode, TreeNodeRecursion,
3434
};
35-
use datafusion_common::{plan_err, JoinSide, Result};
35+
use datafusion_common::{plan_err, HashSet, JoinSide, Result};
3636
use datafusion_expr::JoinType;
3737
use datafusion_physical_expr::expressions::Column;
3838
use datafusion_physical_expr::utils::collect_columns;
@@ -41,8 +41,6 @@ use datafusion_physical_expr_common::sort_expr::{
4141
LexOrdering, LexOrderingRef, LexRequirement,
4242
};
4343

44-
use hashbrown::HashSet;
45-
4644
/// This is a "data class" we use within the [`EnforceSorting`] rule to push
4745
/// down [`SortExec`] in the plan. In some cases, we can reduce the total
4846
/// computational cost by pushing down `SortExec`s through some executors. The

datafusion/core/tests/fuzz_cases/aggregate_fuzz.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ use test_utils::{add_empty_batches, StringBatchGenerator};
4242
use crate::fuzz_cases::aggregation_fuzzer::{
4343
AggregationFuzzerBuilder, ColumnDescr, DatasetGeneratorConfig, QueryBuilder,
4444
};
45+
use datafusion_common::HashMap;
4546
use datafusion_physical_expr_common::sort_expr::LexOrdering;
46-
use hashbrown::HashMap;
4747
use rand::rngs::StdRng;
4848
use rand::{Rng, SeedableRng};
4949
use tokio::task::JoinSet;

datafusion/core/tests/fuzz_cases/window_fuzz.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ use datafusion_physical_expr::{PhysicalExpr, PhysicalSortExpr};
4545
use test_utils::add_empty_batches;
4646

4747
use datafusion::functions_window::row_number::row_number_udwf;
48+
use datafusion_common::HashMap;
4849
use datafusion_functions_window::lead_lag::{lag_udwf, lead_udwf};
4950
use datafusion_functions_window::rank::{dense_rank_udwf, rank_udwf};
5051
use datafusion_physical_expr_common::sort_expr::LexOrdering;
51-
use hashbrown::HashMap;
5252
use rand::distributions::Alphanumeric;
5353
use rand::rngs::StdRng;
5454
use rand::{Rng, SeedableRng};

datafusion/core/tests/user_defined/user_defined_scalar_functions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
// under the License.
1717

1818
use std::any::Any;
19-
use std::collections::HashMap;
2019
use std::hash::{DefaultHasher, Hash, Hasher};
2120
use std::sync::Arc;
2221

@@ -39,7 +38,8 @@ use datafusion_common::cast::{as_float64_array, as_int32_array};
3938
use datafusion_common::tree_node::{Transformed, TreeNode};
4039
use datafusion_common::{
4140
assert_batches_eq, assert_batches_sorted_eq, assert_contains, exec_err, internal_err,
42-
not_impl_err, plan_err, DFSchema, DataFusionError, ExprSchema, Result, ScalarValue,
41+
not_impl_err, plan_err, DFSchema, DataFusionError, ExprSchema, HashMap, Result,
42+
ScalarValue,
4343
};
4444
use datafusion_expr::simplify::{ExprSimplifyResult, SimplifyInfo};
4545
use datafusion_expr::{

0 commit comments

Comments
 (0)