Skip to content

Commit 65df06d

Browse files
committed
Format and lint
1 parent 11c3d0d commit 65df06d

File tree

12 files changed

+49
-37
lines changed

12 files changed

+49
-37
lines changed

bench/src/results/benchmark_results.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ impl BenchmarkResults {
2424

2525
/// Adds a new run for a given `namer
2626
pub fn add_run(&mut self, name: BenchmarkName, run: BenchmarkRun) {
27-
let runs = self.runs.entry(name).or_insert(BenchmarkRuns::new());
27+
let runs = self.runs.entry(name).or_default();
2828
runs.add_run(run);
2929
}
3030
}
31+
32+
impl Default for BenchmarkResults {
33+
fn default() -> Self {
34+
Self::new()
35+
}
36+
}

bench/src/results/run.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,18 @@ impl BenchmarkRuns {
2828
self.runs.iter().map(|run| run.duration).sum::<Duration>() / number_of_samples;
2929

3030
Ok(BenchmarkSummary {
31-
avg_duration,
3231
number_of_samples,
32+
avg_duration,
3333
})
3434
}
3535
}
3636

37+
impl Default for BenchmarkRuns {
38+
fn default() -> Self {
39+
Self::new()
40+
}
41+
}
42+
3743
/// Represents a single run of a benchmark.
3844
#[derive(Debug, Serialize, Deserialize)]
3945
pub struct BenchmarkRun {
@@ -51,14 +57,10 @@ pub struct BenchmarkSummary {
5157
}
5258

5359
impl Display for BenchmarkSummary {
60+
#[allow(clippy::use_debug)]
5461
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
5562
writeln!(f, "Benchmark Summary:")?;
5663
writeln!(f, "Number of Samples: {}", self.number_of_samples)?;
57-
write!(
58-
f,
59-
"Average Duration: {:\
60-
?}",
61-
self.avg_duration
62-
)
64+
write!(f, "Average Duration: {:?}", self.avg_duration)
6365
}
6466
}

lib/engine/src/sparql/eval.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub async fn evaluate_query(
2727
pattern, base_iri, ..
2828
} => {
2929
let (stream, explanation) =
30-
graph_pattern_to_stream(ctx.state(), registry, &query, pattern, base_iri).await?;
30+
graph_pattern_to_stream(ctx.state(), registry, query, pattern, base_iri).await?;
3131
Ok((QueryResults::Solutions(stream), explanation))
3232
}
3333
spargebra::Query::Construct {
@@ -37,7 +37,7 @@ pub async fn evaluate_query(
3737
..
3838
} => {
3939
let (stream, explanation) =
40-
graph_pattern_to_stream(ctx.state(), registry, &query, pattern, base_iri).await?;
40+
graph_pattern_to_stream(ctx.state(), registry, query, pattern, base_iri).await?;
4141
Ok((
4242
QueryResults::Graph(QueryTripleStream::new(template.clone(), stream)),
4343
explanation,
@@ -47,7 +47,7 @@ pub async fn evaluate_query(
4747
pattern, base_iri, ..
4848
} => {
4949
let (mut stream, explanation) =
50-
graph_pattern_to_stream(ctx.state(), registry, &query, pattern, base_iri).await?;
50+
graph_pattern_to_stream(ctx.state(), registry, query, pattern, base_iri).await?;
5151
let count = stream.next().await;
5252
Ok((QueryResults::Boolean(count.is_some()), explanation))
5353
}

lib/engine/src/sparql/explanation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use datafusion::physical_plan::ExecutionPlan;
33
use std::sync::Arc;
44

55
#[derive(Debug)]
6+
#[allow(clippy::struct_field_names)]
67
pub struct QueryExplanation {
78
/// The initial logical plan created from the SPARQL query.
89
pub initial_logical_plan: LogicalPlan,

lib/logical/src/active_graph.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ impl EnumeratedActiveGraph {
3131
}
3232

3333
impl Display for ActiveGraph {
34+
#[allow(clippy::use_debug)]
3435
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3536
match self {
3637
ActiveGraph::DefaultGraph => write!(f, "Default Graph"),
3738
ActiveGraph::AllGraphs => write!(f, "All Graphs"),
38-
ActiveGraph::Union(graphs) => write!(f, "Union of {:?}", graphs),
39+
ActiveGraph::Union(graphs) => write!(f, "Union of {graphs:?}"),
3940
ActiveGraph::AnyNamedGraph => write!(f, "Any Named Graph"),
4041
}
4142
}

lib/logical/src/logical_plan_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,8 @@ fn construct_quads_node_for_pattern(
490490
_ => None,
491491
};
492492
let predicate = match pattern.predicate {
493-
NamedNodePattern::NamedNode(nn) => Some(nn.into()),
494-
_ => None,
493+
NamedNodePattern::NamedNode(nn) => Some(nn),
494+
NamedNodePattern::Variable(_) => None,
495495
};
496496
let object = match pattern.object {
497497
TermPattern::NamedNode(nn) => Some(nn.into()),

lib/physical/src/quads/physical.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl ExecutionPlan for QuadsExec {
7474
self: Arc<Self>,
7575
children: Vec<Arc<dyn ExecutionPlan>>,
7676
) -> DFResult<Arc<dyn ExecutionPlan>> {
77-
if children.len() != 0 {
77+
if !children.is_empty() {
7878
return plan_err!("QuadsExec has no child, got {}", children.len());
7979
}
8080
Ok(Arc::new((*self).clone()))

lib/storage/src/oxigraph_memory/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ mod encoder;
44
mod oxigraph_mem_exec;
55
mod planner;
66
mod quad_storage;
7+
mod quad_storage_stream;
78
mod small_string;
89
mod store;
910
mod table_provider;
10-
mod quad_storage_stream;
1111

1212
pub use quad_storage::MemoryQuadStorage;

lib/storage/src/oxigraph_memory/planner.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ pub struct OxigraphMemoryQuadNodePlanner {
2525

2626
impl OxigraphMemoryQuadNodePlanner {
2727
/// Creates a new [OxigraphMemoryQuadNodePlanner].
28-
pub fn new(storage: MemoryQuadStorage) -> Self {
28+
pub fn new(storage: &MemoryQuadStorage) -> Self {
2929
Self {
3030
snapshot: storage.snapshot(),
3131
}
3232
}
3333

3434
/// TODO
35-
fn enumerate_active_graph(&self, active_graph: &ActiveGraph) -> DFResult<EnumeratedActiveGraph> {
35+
fn enumerate_active_graph(
36+
&self,
37+
active_graph: &ActiveGraph,
38+
) -> DFResult<EnumeratedActiveGraph> {
3639
let graph_names = match active_graph {
3740
ActiveGraph::DefaultGraph => vec![GraphName::DefaultGraph],
3841
ActiveGraph::AllGraphs => {
@@ -90,7 +93,7 @@ impl ExtensionPlanner for OxigraphMemoryQuadNodePlanner {
9093
impl QuadPatternEvaluator for MemoryStorageReader {
9194
fn quads_for_pattern(
9295
&self,
93-
graph_name: GraphNameRef<'_>,
96+
graph: GraphNameRef<'_>,
9497
subject: Option<SubjectRef<'_>>,
9598
predicate: Option<NamedNodeRef<'_>>,
9699
object: Option<TermRef<'_>>,
@@ -100,7 +103,7 @@ impl QuadPatternEvaluator for MemoryStorageReader {
100103
subject.map(EncodedTerm::from).as_ref(),
101104
predicate.map(EncodedTerm::from).as_ref(),
102105
object.map(EncodedTerm::from).as_ref(),
103-
Some(&EncodedTerm::from(graph_name)),
106+
Some(&EncodedTerm::from(graph)),
104107
);
105108
Ok(Box::pin(QuadIteratorBatchRecordStream::new(
106109
iterator, batch_size,

lib/storage/src/oxigraph_memory/quad_storage.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ use datafusion::catalog::TableProvider;
77
use datafusion::physical_planner::ExtensionPlanner;
88
use rdf_fusion_common::error::{CorruptionError, StorageError};
99
use rdf_fusion_common::QuadStorage;
10-
use rdf_fusion_model::{
11-
GraphNameRef, NamedOrBlankNode, NamedOrBlankNodeRef, Quad, QuadRef
12-
,
13-
};
10+
use rdf_fusion_model::{GraphNameRef, NamedOrBlankNode, NamedOrBlankNodeRef, Quad, QuadRef};
1411
use std::sync::Arc;
1512

1613
#[derive(Clone, Debug)]
@@ -125,6 +122,6 @@ impl QuadStorage for MemoryQuadStorage {
125122
}
126123

127124
fn planners(&self) -> Vec<Arc<dyn ExtensionPlanner + Send + Sync>> {
128-
vec![Arc::new(OxigraphMemoryQuadNodePlanner::new(self.clone()))]
125+
vec![Arc::new(OxigraphMemoryQuadNodePlanner::new(self))]
129126
}
130127
}

0 commit comments

Comments
 (0)