Skip to content

Commit 69e6813

Browse files
authored
Create Clippy rule dis-allowing std::collection::hashmap (datafusion-contrib#447)
see datafusion-contrib#445
1 parent a29925d commit 69e6813

16 files changed

Lines changed: 34 additions & 9 deletions

File tree

Cargo.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,7 @@ hyper-util = { version = "0.1.16", optional = true }
5959

6060
[features]
6161
avro = ["datafusion/avro"]
62-
integration = [
63-
"insta",
64-
"parquet",
65-
"arrow",
66-
"hyper-util",
67-
]
62+
integration = ["insta", "parquet", "arrow", "hyper-util"]
6863

6964
system-metrics = ["sysinfo"]
7065

@@ -83,3 +78,7 @@ tokio-stream = { version = "0.1.17", features = ["sync"] }
8378
hyper-util = "0.1.16"
8479
pretty_assertions = "1.4"
8580
test-case = "3.3.1"
81+
82+
[workspace.lints.clippy]
83+
disallowed_types = "deny"
84+
disallowed-methods = "deny"

benchmarks/cdk/ballista/src/ballista_http.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ use ballista::datafusion::physical_plan::execute_stream;
77
use ballista::datafusion::prelude::SessionConfig;
88
use ballista::datafusion::prelude::SessionContext;
99
use ballista::prelude::*;
10+
use datafusion::common::HashMap;
1011
use futures::{StreamExt, TryFutureExt};
1112
use log::{error, info};
1213
use object_store::aws::AmazonS3Builder;
1314
use serde::Serialize;
14-
use std::collections::HashMap;
1515
use std::error::Error;
1616
use std::fmt::Display;
1717
use std::sync::Arc;

benchmarks/cdk/bin/worker.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ struct Ec2WorkerResolver {
260260
}
261261

262262
async fn background_ec2_worker_resolver(urls: Arc<RwLock<Vec<Url>>>) {
263+
#[allow(clippy::disallowed_methods)]
263264
tokio::spawn(async move {
264265
let config = aws_config::load_defaults(BehaviorVersion::latest()).await;
265266
let ec2_client = Ec2Client::new(&config);
@@ -317,6 +318,7 @@ async fn background_ec2_worker_resolver(urls: Arc<RwLock<Vec<Url>>>) {
317318
impl Ec2WorkerResolver {
318319
fn new() -> Self {
319320
let urls = Arc::new(RwLock::new(Vec::new()));
321+
#[allow(clippy::disallowed_methods)]
320322
tokio::spawn(background_ec2_worker_resolver(urls.clone()));
321323
Self { urls }
322324
}

clippy.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
disallowed-types = [
2+
{ path = "std::collections::HashMap", reason = "Use hashbrown::HashMap (or datafusion_common::HashMap) for better performance" },
3+
{ path = "std::collections::HashSet", reason = "Use hashbrown::HashSet (or datafusion_common::HashSet) for better performance" },
4+
]
5+
6+
disallowed-methods = [
7+
{ path = "tokio::spawn", reason = "use datafusion::common::runtime::SpawnTask instead to correctly propagate task context" },
8+
]

console/examples/cluster.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
5151

5252
for listener in listeners {
5353
let resolver = localhost_resolver.clone();
54+
#[allow(clippy::disallowed_methods)]
5455
tokio::spawn(async move {
5556
let worker = Worker::default();
5657

examples/in_memory_cluster.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ impl InMemoryChannelResolver {
9292
async move { Ok(ctx.builder.with_distributed_channel_resolver(this).build()) }
9393
});
9494

95+
#[allow(clippy::disallowed_methods)]
9596
tokio::spawn(async move {
9697
Server::builder()
9798
.add_service(endpoint.into_worker_server())

src/execution_plans/broadcast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ mod tests {
446446
let mut stream1 = broadcast.execute(0, task_ctx.clone())?;
447447
assert_eq!(execute_counts[0].load(Ordering::SeqCst), 1);
448448

449+
#[allow(clippy::disallowed_methods)]
449450
let handle = tokio::spawn(async move { stream1.next().await });
450451

451452
// Cancel this consumer (simulates a cancellation like a TopK)

src/execution_plans/distributed.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ impl<'a> CoordinatorToWorkerTaskSpawner<'a> {
528528
task_number: task_i as u64,
529529
};
530530
let task_metrics_collection = Arc::clone(self.task_metrics);
531+
#[allow(clippy::disallowed_methods)]
531532
tokio::spawn(async move {
532533
while let Some(Ok(msg)) = worker_to_coordinator_rx.recv().await {
533534
let Some(worker_to_coordinator_msg::Inner::TaskMetrics(pre_order_metrics)) =

src/observability/service.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ impl ObservabilityServiceImpl {
4040
let mut sys = sysinfo::System::new_all();
4141

4242
// Spawn background task to periodically collect and send system metrics.
43+
#[allow(clippy::disallowed_methods)]
4344
tokio::task::spawn(async move {
4445
loop {
4546
sys.refresh_process_specifics(

src/test_utils/in_memory_channel_resolver.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ impl InMemoryChannelResolver {
5151
Ok(builder.with_distributed_channel_resolver(this).build())
5252
}));
5353

54+
#[allow(clippy::disallowed_methods)]
5455
tokio::spawn(async move {
5556
Server::builder()
5657
.add_service(endpoint.into_worker_server())

0 commit comments

Comments
 (0)