Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianmurariu committed May 24, 2024
1 parent 85f3869 commit 3152378
Show file tree
Hide file tree
Showing 41 changed files with 158 additions and 153 deletions.
4 changes: 2 additions & 2 deletions raphtory/src/algorithms/algorithm_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ mod algorithm_result_test {
let algo_result = create_algo_result_tuple();
assert_eq!(algo_result.get(node_c.clone()).unwrap().0, 30.0f32);
let algo_result = create_algo_result_hashmap_vec();
let answer = algo_result.get(node_c.clone()).unwrap().get(0).unwrap().0;
let answer = algo_result.get(node_c.clone()).unwrap().first().unwrap().0;
assert_eq!(answer, 22i32);
}

Expand Down Expand Up @@ -617,7 +617,7 @@ mod algorithm_result_test {
let algo_result = create_algo_result_hashmap_vec();
let algo_results_hashmap = algo_result.get_all_with_names();
let tuple_result = algo_results_hashmap.get("A").unwrap();
assert_eq!(tuple_result.clone().get(0).unwrap().0, 11);
assert_eq!(tuple_result.clone().first().unwrap().0, 11);
assert_eq!(algo_result.get_all_values().len(), 3);
}

Expand Down
6 changes: 2 additions & 4 deletions raphtory/src/algorithms/components/lcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ mod largest_connected_component_test {

let expected_nodes = vec![1, 2, 3];
for node in expected_nodes {
assert_eq!(
assert!(
subgraph.has_node(node),
true,
"Node {} should be in the largest connected component.",
node
);
Expand All @@ -113,9 +112,8 @@ mod largest_connected_component_test {
let subgraph = graph.largest_connected_component();
let expected_nodes = vec![1, 2, 3];
for node in expected_nodes {
assert_eq!(
assert!(
subgraph.has_node(node),
true,
"Node {} should be in the largest connected component.",
node
);
Expand Down
2 changes: 1 addition & 1 deletion raphtory/src/algorithms/components/scc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn tarjan<'graph, G>(
for neighbor in node.out_neighbours() {
if !indices.contains_key(&neighbor.node) {
tarjan(
neighbor.clone(),
neighbor,
index,
stack,
indices,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ mod motifs_test {
let actual = binding
.iter()
.map(|(k, v)| (k, v[0].clone()))
.into_iter()
.collect::<HashMap<&String, Vec<usize>>>();

let expected: HashMap<String, Vec<usize>> = HashMap::from([
Expand Down
2 changes: 1 addition & 1 deletion raphtory/src/algorithms/motifs/three_node_motifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ mod three_node_motifs_test {

#[test]
fn triad_test() {
let events = vec![(true, 0, 1, 1, 1), (false, 1, 0, 1, 2), (false, 0, 0, 0, 3)]
let events = [(true, 0, 1, 1, 1), (false, 1, 0, 1, 2), (false, 0, 0, 0, 3)]
.iter()
.map(|x| TriangleEdge {
uv_edge: x.0,
Expand Down
17 changes: 8 additions & 9 deletions raphtory/src/arrow/graph_impl/core_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl CoreGraphOps for ArrowGraph {
LayerIds::All => Box::new(
self.inner
.layer_names()
.into_iter()
.iter()
.map(|s| ArcStr::from(s.as_str()))
.collect::<Vec<_>>()
.into_iter(),
Expand All @@ -78,15 +78,15 @@ impl CoreGraphOps for ArrowGraph {
.get(*id)
.cloned()
.into_iter()
.map(|s| ArcStr::from(s)),
.map(ArcStr::from),
),
LayerIds::Multiple(ids) => Box::new(
ids.iter()
.copied()
.filter_map(|id| self.inner.layer_names().get(id).cloned())
.collect_vec()
.into_iter()
.map(|s| ArcStr::from(s)),
.map(ArcStr::from),
),
}
}
Expand Down Expand Up @@ -117,12 +117,11 @@ impl CoreGraphOps for ArrowGraph {

fn internalise_node(&self, v: NodeRef) -> Option<VID> {
match v {
NodeRef::Internal(vid) => Some(vid.into()),
NodeRef::External(vid) => self.inner.find_node(&GID::U64(vid)).map(|v| v.into()),
NodeRef::Internal(vid) => Some(vid),
NodeRef::External(vid) => self.inner.find_node(&GID::U64(vid)),
NodeRef::ExternalStr(string) => self
.inner
.find_node(&GID::Str(string.into()))
.map(|v| v.into()),
.find_node(&GID::Str(string.into())),
}
}

Expand All @@ -141,7 +140,7 @@ impl CoreGraphOps for ArrowGraph {
fn constant_node_prop(&self, v: VID, id: usize) -> Option<Prop> {
match &self.inner.node_properties() {
None => None,
Some(props) => const_props(props, v.into(), id),
Some(props) => const_props(props, v, id),
}
}

Expand All @@ -150,7 +149,7 @@ impl CoreGraphOps for ArrowGraph {
None => Box::new(std::iter::empty()),
Some(props) => Box::new(
(0..props.const_props.num_props())
.filter(move |id| props.const_props.has_prop(v.into(), *id)),
.filter(move |id| props.const_props.has_prop(v, *id)),
),
}
}
Expand Down
18 changes: 9 additions & 9 deletions raphtory/src/arrow/graph_impl/edge_storage_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ use std::{iter, ops::Range};
impl<'a> EdgeStorageOps<'a> for Edge<'a> {
fn in_ref(self) -> EdgeRef {
EdgeRef::new_incoming(
self.eid().into(),
self.src_id().into(),
self.dst_id().into(),
self.eid(),
self.src_id(),
self.dst_id(),
)
.at_layer(self.layer_id())
}

fn out_ref(self) -> EdgeRef {
EdgeRef::new_outgoing(
self.eid().into(),
self.src_id().into(),
self.dst_id().into(),
self.eid(),
self.src_id(),
self.dst_id(),
)
.at_layer(self.layer_id())
}
Expand All @@ -43,11 +43,11 @@ impl<'a> EdgeStorageOps<'a> for Edge<'a> {
}

fn src(self) -> VID {
self.src_id().into()
self.src_id()
}

fn dst(self) -> VID {
self.dst_id().into()
self.dst_id()
}

fn layer_ids_iter(self, layer_ids: &'a LayerIds) -> impl Iterator<Item = usize> + 'a {
Expand Down Expand Up @@ -101,7 +101,7 @@ impl<'a> EdgeStorageOps<'a> for Edge<'a> {
self,
layer_id: usize,
prop_id: usize,
) -> impl TPropOps<'a> + Send + Sync + 'a {
) -> impl TPropOps<'a> + Sync + 'a {
if layer_id == self.layer_id() {
self.temporal_property_field(prop_id)
.and_then(|field| read_tprop_column(prop_id, field, self))
Expand Down
8 changes: 4 additions & 4 deletions raphtory/src/arrow/graph_impl/interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ impl GraphLike<TimeIndexEntry> for Graph {
fn in_edges<B>(&self, vid: VID, layer: usize, map: impl Fn(VID, EID) -> B) -> Vec<B> {
let node = self.core_node_entry(vid.0.into());
node.edges_iter(&LayerIds::One(layer), Direction::IN)
.map(|edge| map(edge.src().into(), edge.pid().into()))
.map(|edge| map(edge.src(), edge.pid()))
.collect()
}
fn out_edges(&self, vid: VID, layer: usize) -> Vec<(VID, VID, EID)> {
let node = self.core_node_entry(vid.0.into());
let edges = node
.edges_iter(&LayerIds::One(layer), Direction::OUT)
.map(|edge| {
let src = edge.src().into();
let dst = edge.dst().into();
let eid = edge.pid().into();
let src = edge.src();
let dst = edge.dst();
let eid = edge.pid();
(src, dst, eid)
})
.collect();
Expand Down
10 changes: 5 additions & 5 deletions raphtory/src/arrow/graph_impl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl ArrowGraph {
) -> ArrowGraph {
// unzip into 4 vectors
let (src, (dst, (time, weight))): (Vec<_>, (Vec<_>, (Vec<_>, Vec<_>))) = edges
.into_iter()
.iter()
.map(|(a, b, c, d)| (*a, (*b, (*c, *d))))
.unzip();

Expand Down Expand Up @@ -251,11 +251,11 @@ impl ArrowGraph {
time_col,
}| {
ExternalEdgeList::new(
*layer,
layer,
parquet_dir.as_ref(),
*src_col,
*dst_col,
*time_col,
src_col,
dst_col,
time_col,
)
.expect("Failed to load events")
},
Expand Down
4 changes: 2 additions & 2 deletions raphtory/src/arrow/graph_impl/prop_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,6 @@ pub fn schema_from_prop_meta(prop_map: &PropMapper) -> Schema {
}
}

let schema = Schema::from(schema);
schema

Schema::from(schema)
}
3 changes: 0 additions & 3 deletions raphtory/src/arrow/graph_impl/time_index_into_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ impl<'a> TimeIndexOps for TimeStamps<'a, TimeIndexEntry> {
TimeStamps::new(
self.timestamps().slice(start..end),
self.sec_index()
.clone()
.map(|sec_index| sec_index.sliced(start..end)),
)
}
Expand Down Expand Up @@ -112,7 +111,6 @@ impl<'a> TimeIndexOps for TimeStamps<'a, TimeIndexEntry> {
fn iter(&self) -> Box<dyn Iterator<Item = Self::IndexType> + Send + '_> {
let sec_iter: Box<dyn Iterator<Item = usize> + Send + 'a> = self
.sec_index()
.clone()
.map(|v| v.map(|i| i as usize).into_dyn_boxed())
.unwrap_or(self.timestamps().range().clone().into_dyn_boxed());
Box::new(
Expand Down Expand Up @@ -141,7 +139,6 @@ impl<'a> TimeIndexOps for TimeStamps<'a, i64> {
TimeStamps::new(
self.timestamps().slice(start..end),
self.sec_index()
.clone()
.map(|sec_index| sec_index.sliced(start..end)),
)
}
Expand Down
10 changes: 5 additions & 5 deletions raphtory/src/arrow/graph_impl/time_semantics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl TimeSemantics for ArrowGraph {
.map(|props| {
props
.temporal_props
.timestamps::<TimeIndexEntry>(v.vid().into())
.timestamps::<TimeIndexEntry>(v.vid())
.active_t(w.clone())
})
.unwrap_or(false)
Expand Down Expand Up @@ -452,7 +452,7 @@ impl TimeSemantics for ArrowGraph {
fn has_temporal_node_prop(&self, v: VID, prop_id: usize) -> bool {
match &self.inner.node_properties() {
None => false,
Some(props) => props.temporal_props.has_prop(v.into(), prop_id),
Some(props) => props.temporal_props.has_prop(v, prop_id),
}
}

Expand All @@ -462,14 +462,14 @@ impl TimeSemantics for ArrowGraph {
None => {
vec![]
}
Some(props) => props.temporal_props.prop(v.into(), id).iter_t().collect(),
Some(props) => props.temporal_props.prop(v, id).iter_t().collect(),
}
}

fn has_temporal_node_prop_window(&self, v: VID, prop_id: usize, w: Range<i64>) -> bool {
match &self.inner.node_properties() {
None => false,
Some(props) => props.temporal_props.has_prop_window(v.into(), prop_id, w),
Some(props) => props.temporal_props.has_prop_window(v, prop_id, w),
}
}

Expand All @@ -484,7 +484,7 @@ impl TimeSemantics for ArrowGraph {
None => vec![],
Some(props) => props
.temporal_props
.prop(v.into(), id)
.prop(v, id)
.iter_window_t(start..end)
.collect(),
}
Expand Down
20 changes: 10 additions & 10 deletions raphtory/src/arrow/graph_impl/tprops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<'a, T: NativeType + Into<Prop>> TPropOps<'a>
let (props, timestamps) = self.into_inner();
let (t, t_index) = timestamps.last_before(t)?;
let v = props.get(t_index)?;
Some((t.into(), v.into()))
Some((t, v.into()))
}

fn iter(self) -> impl Iterator<Item = (TimeIndexEntry, Prop)> + Send + 'a {
Expand All @@ -40,18 +40,18 @@ impl<'a, T: NativeType + Into<Prop>> TPropOps<'a>
r: Range<TimeIndexEntry>,
) -> impl Iterator<Item = (TimeIndexEntry, Prop)> + Send + 'a {
let (props, timestamps) = self.into_inner();
let start = timestamps.position(&r.start.into());
let end = timestamps.position(&r.end.into());
let start = timestamps.position(&r.start);
let end = timestamps.position(&r.end);
timestamps
.sliced(start..end)
.into_iter()
.zip(props.sliced(start..end).into_iter())
.zip(props.sliced(start..end))
.filter_map(|(t, v)| v.map(|v| (t, v.into())))
}

fn at(self, ti: &TimeIndexEntry) -> Option<Prop> {
let (props, timestamps) = self.into_inner();
let t_index = timestamps.position(ti.into());
let t_index = timestamps.position(ti);
props.get(t_index).map(|v| v.into())
}

Expand All @@ -71,7 +71,7 @@ impl<'a, I: Offset> TPropOps<'a> for TPropColumn<'a, StringCol<'a, I>, TimeIndex
let (props, timestamps) = self.into_inner();
let (t, t_index) = timestamps.last_before(t)?;
let v = props.get(t_index)?;
Some((t.into(), v.into()))
Some((t, v.into()))
}

fn iter(self) -> impl Iterator<Item = (TimeIndexEntry, Prop)> + Send + 'a {
Expand All @@ -87,18 +87,18 @@ impl<'a, I: Offset> TPropOps<'a> for TPropColumn<'a, StringCol<'a, I>, TimeIndex
r: Range<TimeIndexEntry>,
) -> impl Iterator<Item = (TimeIndexEntry, Prop)> + Send + 'a {
let (props, timestamps) = self.into_inner();
let start = timestamps.position(&r.start.into());
let end = timestamps.position(&r.end.into());
let start = timestamps.position(&r.start);
let end = timestamps.position(&r.end);
timestamps
.sliced(start..end)
.into_iter()
.zip(props.sliced(start..end).into_iter())
.zip(props.sliced(start..end))
.filter_map(|(t, v)| v.map(|v| (t, v.into())))
}

fn at(self, ti: &TimeIndexEntry) -> Option<Prop> {
let (props, timestamps) = self.into_inner();
let t_index = timestamps.position(ti.into());
let t_index = timestamps.position(ti);
props.get(t_index).map(|v| v.into())
}

Expand Down
2 changes: 1 addition & 1 deletion raphtory/src/arrow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ mod test {
let dst = dst as u64;
times.into_iter().map(move |t| (src, dst, t))}).collect();
v.sort();
v}).prop_filter("edge list mut have one edge at least",|edges| edges.len() > 0),
v}).prop_filter("edge list mut have one edge at least",|edges| !edges.is_empty()),
chunk_size in 1..300usize,
) {
compare_raphtory_graph(edges, chunk_size);
Expand Down
6 changes: 6 additions & 0 deletions raphtory/src/arrow/query/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ pub struct Query<S> {
pub hops: Vec<Hop>,
}

impl<S> Default for Query<S> {
fn default() -> Self {
Self::new()
}
}

impl<S> Query<S> {
pub fn new() -> Self {
Self {
Expand Down
Loading

0 comments on commit 3152378

Please sign in to comment.