Skip to content

Commit

Permalink
clippy + remove some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianmurariu committed Jul 18, 2024
1 parent f31501f commit e5eab5d
Show file tree
Hide file tree
Showing 17 changed files with 73 additions and 105 deletions.
99 changes: 43 additions & 56 deletions raphtory/src/core/entities/graph/tgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,25 @@ use crate::{
timer::{MaxCounter, MinCounter, TimeCounterTrait},
},
nodes::{node_ref::NodeRef, node_store::NodeStore},
properties::{graph_meta::GraphMeta, props::Meta, tprop::TProp},
properties::{graph_meta::GraphMeta, props::Meta},
LayerIds, EID, VID,
},
storage::{
locked_view::LockedView,
raw_edges::EdgeWGuard,
timeindex::{AsTime, TimeIndexEntry},
EntryMut,
},
utils::errors::GraphError,
Direction, Prop,
},
db::api::view::{BoxedIter, Layer},
db::api::view::Layer,
};
use dashmap::DashSet;
use itertools::Itertools;
use raphtory_api::core::{
entities::edges::edge_ref::EdgeRef,
input::input_node::InputNode,
storage::{arc_str::ArcStr, locked_vec::ArcReadLockedVec, FxDashMap},
storage::{arc_str::ArcStr, FxDashMap},
};
use rustc_hash::FxHasher;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -111,24 +110,24 @@ impl TemporalGraph {
self.edge_meta.layer_meta().len()
}

pub(crate) fn layer_names(&self, layer_ids: &LayerIds) -> BoxedIter<ArcStr> {
let layer_ids = layer_ids.clone();
match layer_ids {
LayerIds::None => Box::new(iter::empty()),
LayerIds::All => Box::new(self.edge_meta.layer_meta().get_keys().into_iter()),
LayerIds::One(id) => {
let name = self.edge_meta.layer_meta().get_name(id).clone();
Box::new(iter::once(name))
}
LayerIds::Multiple(ids) => {
let keys = self.edge_meta.layer_meta().get_keys();
Box::new((0..ids.len()).map(move |index| {
let id = ids[index];
keys[id].clone()
}))
}
}
}
// pub(crate) fn layer_names(&self, layer_ids: &LayerIds) -> BoxedIter<ArcStr> {
// let layer_ids = layer_ids.clone();
// match layer_ids {
// LayerIds::None => Box::new(iter::empty()),
// LayerIds::All => Box::new(self.edge_meta.layer_meta().get_keys().into_iter()),
// LayerIds::One(id) => {
// let name = self.edge_meta.layer_meta().get_name(id).clone();
// Box::new(iter::once(name))
// }
// LayerIds::Multiple(ids) => {
// let keys = self.edge_meta.layer_meta().get_keys();
// Box::new((0..ids.len()).map(move |index| {
// let id = ids[index];
// keys[id].clone()
// }))
// }
// }
// }

pub(crate) fn layer_ids(&self, key: Layer) -> Result<LayerIds, GraphError> {
match key {
Expand Down Expand Up @@ -214,32 +213,32 @@ impl TemporalGraph {
Some(self.latest_time.get()).filter(|t| *t != i64::MIN)
}

#[inline]
pub(crate) fn global_node_id(&self, v: VID) -> u64 {
let node = self.storage.get_node(v);
node.global_id()
}
// #[inline]
// pub(crate) fn global_node_id(&self, v: VID) -> u64 {
// let node = self.storage.get_node(v);
// node.global_id()
// }

pub(crate) fn node_name(&self, v: VID) -> String {
let node = self.storage.get_node(v);
node.name
.clone()
.unwrap_or_else(|| node.global_id().to_string())
}
// pub(crate) fn node_name(&self, v: VID) -> String {
// let node = self.storage.get_node(v);
// node.name
// .clone()
// .unwrap_or_else(|| node.global_id().to_string())
// }

pub(crate) fn node_type(&self, v: VID) -> Option<ArcStr> {
let node = self.storage.get_node(v);
self.node_meta.get_node_type_name_by_id(node.node_type)
}
// pub(crate) fn node_type(&self, v: VID) -> Option<ArcStr> {
// let node = self.storage.get_node(v);
// self.node_meta.get_node_type_name_by_id(node.node_type)
// }

pub(crate) fn node_type_id(&self, v: VID) -> usize {
let node = self.storage.get_node(v);
node.node_type
}
// pub(crate) fn node_type_id(&self, v: VID) -> usize {
// let node = self.storage.get_node(v);
// node.node_type
// }

pub(crate) fn get_all_node_types(&self) -> Vec<ArcStr> {
self.node_meta.get_all_node_types()
}
// pub(crate) fn get_all_node_types(&self) -> Vec<ArcStr> {
// self.node_meta.get_all_node_types()
// }

pub(crate) fn core_temporal_edge_prop_ids(
&self,
Expand Down Expand Up @@ -464,18 +463,6 @@ impl TemporalGraph {
Ok(())
}

pub(crate) fn get_constant_prop(&self, id: usize) -> Option<Prop> {
self.graph_meta.get_constant(id)
}

pub(crate) fn get_temporal_prop(&self, id: usize) -> Option<LockedView<TProp>> {
self.graph_meta.get_temporal_prop(id)
}

pub(crate) fn const_prop_names(&self) -> ArcReadLockedVec<ArcStr> {
self.graph_meta.constant_names()
}

pub(crate) fn delete_edge(
&self,
t: TimeIndexEntry,
Expand Down
24 changes: 1 addition & 23 deletions raphtory/src/core/entities/nodes/node_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use itertools::Itertools;
use serde::{Deserialize, Serialize};
use std::{
iter,
ops::{Deref, Range},
ops::Deref,
};

#[derive(Serialize, Deserialize, Debug, Default, PartialEq)]
Expand Down Expand Up @@ -149,28 +149,6 @@ impl NodeStore {
}
}

pub(crate) fn temporal_properties(
&self,
prop_id: usize,
window: Option<Range<i64>>,
) -> impl Iterator<Item = (i64, Prop)> + '_ {
if let Some(window) = window {
self.props
.as_ref()
.map(|ps| ps.temporal_props_window(prop_id, window.start, window.end))
.unwrap_or_else(|| Box::new(iter::empty()))
} else {
self.props
.as_ref()
.map(|ps| ps.temporal_props(prop_id))
.unwrap_or_else(|| Box::new(iter::empty()))
}
}

pub(crate) fn const_prop(&self, prop_id: usize) -> Option<&Prop> {
self.props.as_ref().and_then(|ps| ps.const_prop(prop_id))
}

#[inline]
pub(crate) fn edge_tuples<'a>(
&'a self,
Expand Down
14 changes: 10 additions & 4 deletions raphtory/src/core/storage/raw_edges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,15 @@ impl PartialEq for EdgesStorage {
}
}

impl Default for EdgesStorage {
fn default() -> Self {
Self::new()
}
}

impl EdgesStorage {
pub fn new() -> Self {
let mut shards = (0..SHARD_SIZE).into_iter().map(|_| {
let mut shards = (0..SHARD_SIZE).map(|_| {
Arc::new(RwLock::new(EdgeShard {
edge_ids: vec![],
props: Vec::with_capacity(0),
Expand Down Expand Up @@ -282,7 +288,7 @@ impl LockedEdges {
pub fn get(&self, eid: EID) -> &EdgeShard {
let (bucket, offset) = resolve(eid.into(), self.shards.len());
let shard = &self.shards[bucket];
&shard
shard
}

pub fn get_mem(&self, eid: EID) -> MemEdge {
Expand All @@ -308,7 +314,7 @@ impl LockedEdges {
.edge_ids
.iter()
.enumerate()
.map(move |(offset, _)| MemEdge::new(&shard, offset))
.map(move |(offset, _)| MemEdge::new(shard, offset))
})
}

Expand All @@ -318,7 +324,7 @@ impl LockedEdges {
.edge_ids
.par_iter()
.enumerate()
.map(move |(offset, _)| MemEdge::new(&shard, offset))
.map(move |(offset, _)| MemEdge::new(shard, offset))
})
}
}
4 changes: 2 additions & 2 deletions raphtory/src/db/api/state/lazy_node_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl<
let cg = self.graph.core_graph();
Some((
NodeView::new_one_hop_filtered(&self.base_graph, &self.graph, vid),
(self.op)(&cg, &self.graph, vid),
(self.op)(cg, &self.graph, vid),
))
}
}
Expand All @@ -242,7 +242,7 @@ impl<
}

let cg = self.graph.core_graph();
Some(self.apply(&cg, &self.graph, vid))
Some(self.apply(cg, &self.graph, vid))
}

fn len(&self) -> usize {
Expand Down
1 change: 0 additions & 1 deletion raphtory/src/db/api/storage/storage_ops/materialize.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::{
core::entities::graph::tgraph::TemporalGraph,
db::api::view::{internal::InternalMaterialize, MaterializedGraph},
prelude::Graph,
};
Expand Down
2 changes: 1 addition & 1 deletion raphtory/src/db/api/storage/storage_ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ impl GraphStorage {
}
#[cfg(feature = "storage")]
GraphStorage::Disk(storage) => {
let layer = eid
let _ = eid
.layer()
.expect("disk_graph EdgeRefs should always have layer set");
EdgeOwnedEntry::Disk(DiskOwnedEdge::new(&storage.inner, eid))
Expand Down
2 changes: 1 addition & 1 deletion raphtory/src/db/api/storage/storage_ops/time_props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use raphtory_api::core::storage::{arc_str::ArcStr, timeindex::AsTime};

use crate::{
db::api::{
properties::internal::{PropertiesOps, TemporalPropertiesOps, TemporalPropertyViewOps},
properties::internal::{TemporalPropertiesOps, TemporalPropertyViewOps},
storage::tprop_storage_ops::TPropOps,
},
prelude::Prop,
Expand Down
4 changes: 2 additions & 2 deletions raphtory/src/db/api/storage/storage_ops/time_semantics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ impl TimeSemantics for GraphStorage {
.collect()
}

fn edge_is_valid(&self, e: EdgeRef, layer_ids: &LayerIds) -> bool {
fn edge_is_valid(&self, _e: EdgeRef, _layer_ids: &LayerIds) -> bool {
true
}

fn edge_is_valid_at_end(&self, e: EdgeRef, layer_ids: &LayerIds, t: i64) -> bool {
fn edge_is_valid_at_end(&self, _e: EdgeRef,_layer_idss: &LayerIds, _t: i64) -> bool {
true
}

Expand Down
4 changes: 2 additions & 2 deletions raphtory/src/db/api/view/graph.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
core::{
entities::{graph::tgraph::TemporalGraph, nodes::node_ref::AsNodeRef, LayerIds, VID},
entities::{nodes::node_ref::AsNodeRef, LayerIds, VID},
storage::timeindex::AsTime,
utils::errors::GraphError,
},
Expand All @@ -24,7 +24,7 @@ use crate::{
},
},
},
prelude::{DeletionOps, Graph, NO_PROPS},
prelude::{DeletionOps, NO_PROPS},
};
use chrono::{DateTime, Utc};
use itertools::Itertools;
Expand Down
3 changes: 1 addition & 2 deletions raphtory/src/db/api/view/internal/core_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ use crate::{
db::api::{
storage::{
edges::{
edge_entry::EdgeStorageEntry, edge_owned_entry::EdgeOwnedEntry,
edge_storage_ops::EdgeStorageOps, edges::EdgesStorage,
edge_entry::EdgeStorageEntry, edge_owned_entry::EdgeOwnedEntry, edges::EdgesStorage,
},
nodes::{
node_entry::NodeStorageEntry, node_owned_entry::NodeOwnedEntry,
Expand Down
1 change: 0 additions & 1 deletion raphtory/src/db/api/view/internal/materialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::{
core::{
entities::{
edges::edge_ref::EdgeRef,
graph::tgraph::TemporalGraph,
nodes::node_ref::NodeRef,
properties::{graph_meta::GraphMeta, props::Meta, tprop::TProp},
LayerIds, EID, ELID, VID,
Expand Down
2 changes: 1 addition & 1 deletion raphtory/src/db/graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::{
db::api::{
mutation::internal::InheritMutationOps,
storage::storage_ops::GraphStorage,
view::internal::{Base, CoreGraphOps, InheritViewOps, MaterializedGraph, Static},
view::internal::{Base, InheritViewOps, MaterializedGraph, Static},
},
prelude::*,
};
Expand Down
6 changes: 3 additions & 3 deletions raphtory/src/db/graph/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl<'graph, G: GraphViewOps<'graph>, GH: GraphViewOps<'graph>> BaseNodeViewOps<
op: F,
) -> Self::ValueType<O> {
let cg = self.graph.core_graph();
op(&cg, &self.graph, self.node)
op(cg, &self.graph, self.node)
}

fn as_props(&self) -> Self::ValueType<Properties<Self::PropType>> {
Expand All @@ -301,7 +301,7 @@ impl<'graph, G: GraphViewOps<'graph>, GH: GraphViewOps<'graph>> BaseNodeViewOps<
let node = self.node;
let edges = Arc::new(move || {
let cg = graph.core_graph();
op(&cg, &graph, node).into_dyn_boxed()
op(cg, &graph, node).into_dyn_boxed()
});
let base_graph = self.base_graph.clone();
let graph = self.graph.clone();
Expand All @@ -323,7 +323,7 @@ impl<'graph, G: GraphViewOps<'graph>, GH: GraphViewOps<'graph>> BaseNodeViewOps<
let node = self.node;
PathFromNode::new(self.base_graph.clone(), move || {
let cg = graph.core_graph();
op(&cg, &graph, node).into_dyn_boxed()
op(cg, &graph, node).into_dyn_boxed()
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions raphtory/src/db/graph/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ where
let nodes = Arc::new(move || nodes.iter_refs().into_dyn_boxed());
let edges = Arc::new(move |node: VID| {
let cg = graph.core_graph();
op(&cg, &graph, node).into_dyn_boxed()
op(cg, &graph, node).into_dyn_boxed()
});
let graph = self.graph.clone();
NestedEdges {
Expand All @@ -224,7 +224,7 @@ where
let nodes = Arc::new(move || nodes.iter_refs().into_dyn_boxed());
PathFromGraph::new(self.base_graph.clone(), nodes, move |v| {
let cg = graph.core_graph();
op(&cg, &graph, v).into_dyn_boxed()
op(cg, &graph, v).into_dyn_boxed()
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion raphtory/src/db/task/task_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ impl<G: StaticGraphViewOps, CS: ComputeState> TaskRunner<G, CS> {
global_state,
cur_local_state,
&prev_local_state,
&storage,
storage,
);

// copy and reset the state from the step that just ended
Expand Down
Loading

0 comments on commit e5eab5d

Please sign in to comment.