Skip to content

Commit faea6da

Browse files
committed
fmt
1 parent 298d4b3 commit faea6da

9 files changed

Lines changed: 176 additions & 107 deletions

File tree

raphtory-graphql/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,6 @@ mod graphql_test {
536536
graph
537537
}
538538

539-
540539
fn degree_graph_with_add_edge_only() -> Graph {
541540
let graph = Graph::new();
542541

@@ -646,8 +645,6 @@ mod graphql_test {
646645
);
647646
}
648647

649-
650-
651648
#[tokio::test]
652649
async fn test_unique_temporal_properties() {
653650
let g = Graph::new();

raphtory-graphql/src/model/graph/filtering.rs

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use crate::model::{graph::{node_id::GqlNodeId, property::Value, timeindex::GqlTimeInput}, plugins::operation};
1+
use crate::model::{
2+
graph::{node_id::GqlNodeId, property::Value, timeindex::GqlTimeInput},
3+
plugins::operation,
4+
};
25
use async_graphql::dynamic::ValueAccessor;
36
use dynamic_graphql::{
47
internal::{
@@ -7,16 +10,35 @@ use dynamic_graphql::{
710
Enum, InputObject, OneOfInput,
811
};
912
use raphtory::{
10-
db::{api::{state::ops::Degree, view::internal::filtered_edge}, graph::views::filter::model::{
11-
ComposableFilter, DynFilter, DynView, NoFilter, ViewWrapOps, degree_filter::DegreeFilter, edge_filter::{CompositeEdgeFilter, EdgeFilter}, filter::{Filter, FilterValue}, filter_operator::FilterOperator, graph_filter::GraphFilter, is_active_edge_filter::IsActiveEdge, is_active_node_filter::IsActiveNode, is_deleted_filter::IsDeletedEdge, is_self_loop_filter::IsSelfLoopEdge, is_valid_filter::IsValidEdge, latest_filter::Latest as LatestWrap, layered_filter::Layered, node_filter::{CompositeNodeFilter, NodeFilter}, property_filter::{Op, PropertyFilter, PropertyFilterValue, PropertyRef}, snapshot_filter::{SnapshotAt as SnapshotAtWrap, SnapshotLatest as SnapshotLatestWrap}, windowed_filter::Windowed
12-
}},
13+
db::{
14+
api::{state::ops::Degree, view::internal::filtered_edge},
15+
graph::views::filter::model::{
16+
degree_filter::DegreeFilter,
17+
edge_filter::{CompositeEdgeFilter, EdgeFilter},
18+
filter::{Filter, FilterValue},
19+
filter_operator::FilterOperator,
20+
graph_filter::GraphFilter,
21+
is_active_edge_filter::IsActiveEdge,
22+
is_active_node_filter::IsActiveNode,
23+
is_deleted_filter::IsDeletedEdge,
24+
is_self_loop_filter::IsSelfLoopEdge,
25+
is_valid_filter::IsValidEdge,
26+
latest_filter::Latest as LatestWrap,
27+
layered_filter::Layered,
28+
node_filter::{CompositeNodeFilter, NodeFilter},
29+
property_filter::{Op, PropertyFilter, PropertyFilterValue, PropertyRef},
30+
snapshot_filter::{SnapshotAt as SnapshotAtWrap, SnapshotLatest as SnapshotLatestWrap},
31+
windowed_filter::Windowed,
32+
ComposableFilter, DynFilter, DynView, NoFilter, ViewWrapOps,
33+
},
34+
},
1335
errors::GraphError,
1436
};
15-
use raphtory_api::core::Direction;
1637
use raphtory_api::core::{
1738
entities::{properties::prop::Prop, Layer, GID},
1839
storage::timeindex::{AsTime, EventTime},
1940
utils::time::IntoTime,
41+
Direction,
2042
};
2143
use serde::{Deserialize, Serialize};
2244
use std::{
@@ -304,7 +326,6 @@ pub struct PropertyFilterNew {
304326
pub where_: PropCondition,
305327
}
306328

307-
308329
/// Filters nodes by computed degree with a directional scope.
309330
///
310331
/// `DegreeFilterNew` lets callers filter on:
@@ -330,8 +351,8 @@ pub enum DegreeDirection {
330351
impl From<DegreeDirection> for Direction {
331352
fn from(d: DegreeDirection) -> Self {
332353
match d {
333-
DegreeDirection::In => Direction::IN,
334-
DegreeDirection::Out => Direction::OUT,
354+
DegreeDirection::In => Direction::IN,
355+
DegreeDirection::Out => Direction::OUT,
335356
DegreeDirection::Both => Direction::BOTH,
336357
}
337358
}
@@ -342,7 +363,7 @@ impl From<DegreeDirection> for String {
342363
match d {
343364
DegreeDirection::In => "in_degree".to_string(),
344365
DegreeDirection::Out => "out_degree".to_string(),
345-
DegreeDirection::Both => "degree".to_string(),
366+
DegreeDirection::Both => "degree".to_string(),
346367
}
347368
}
348369
}
@@ -1440,8 +1461,8 @@ impl TryFrom<GqlNodeFilter> for CompositeNodeFilter {
14401461
direction: core_direction,
14411462
operator,
14421463
value,
1443-
ops
1444-
}))
1464+
ops,
1465+
}))
14451466
}
14461467
GqlNodeFilter::Property(prop) => {
14471468
let prop_ref = PropertyRef::Property(prop.name.clone());

raphtory-tests/tests/test_filters.rs

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,32 +1647,38 @@ fn init_edges_graph_with_str_ids_del<
16471647

16481648
mod test_node_filter {
16491649

1650-
use crate::{
1650+
use crate::{
16511651
init_nodes_graph, init_nodes_graph_with_num_ids, init_nodes_graph_with_str_ids,
16521652
IdentityGraphTransformer,
16531653
};
1654+
use proptest::proptest;
16541655
use raphtory::{
1655-
algorithms::alternating_mask::alternating_mask, core::entities::VID, db::{
1656-
api::view::{Filter, filter_ops::NodeSelect},
1657-
graph::{
1658-
views::filter::{
1659-
CreateFilter, model::{
1660-
ComposableFilter, CompositeNodeFilter, NodeViewFilterOps, PropertyFilterFactory, TryAsCompositeFilter, ViewWrapOps, degree_filter::DegreeFilterFactory, node_filter::ops::{NodeFilterOps, NodeIdFilterOps}, property_filter::ops::{ListAggOps, PropertyFilterOps}
1661-
}
1656+
algorithms::alternating_mask::alternating_mask,
1657+
core::entities::VID,
1658+
db::{
1659+
api::view::{filter_ops::NodeSelect, Filter},
1660+
graph::views::filter::{
1661+
model::{
1662+
degree_filter::DegreeFilterFactory,
1663+
node_filter::ops::{NodeFilterOps, NodeIdFilterOps},
1664+
property_filter::ops::{ElemQualifierOps, ListAggOps, PropertyFilterOps},
1665+
ComposableFilter, CompositeNodeFilter, NodeViewFilterOps,
1666+
PropertyFilterFactory, TryAsCompositeFilter, ViewWrapOps,
16621667
},
1668+
CreateFilter,
16631669
},
1664-
}, errors::GraphError, prelude::{
1665-
AdditionOps, Graph, GraphViewOps, NO_PROPS, NodeFilter, NodeStateOps, NodeViewOps, TimeOps
1666-
}
1670+
},
1671+
errors::GraphError,
1672+
prelude::{
1673+
AdditionOps, Graph, GraphViewOps, IntoProp, NodeFilter, NodeStateOps, NodeViewOps,
1674+
TimeOps, NO_PROPS,
1675+
},
16671676
};
1677+
use raphtory_api::core::{entities::properties::prop::Prop, Direction};
16681678
use raphtory_tests::assertions::{
16691679
assert_filter_nodes_results, assert_search_nodes_results, assert_select_nodes_results,
16701680
TestVariants,
16711681
};
1672-
use raphtory_api::core::{Direction, entities::properties::prop::Prop};
1673-
use raphtory::prelude::IntoProp;
1674-
use raphtory::db::graph::views::filter::model::property_filter::ops::ElemQualifierOps;
1675-
use proptest::proptest;
16761682

16771683
fn sort_vids(mut vids: Vec<VID>) -> Vec<VID> {
16781684
vids.sort();
@@ -1717,7 +1723,8 @@ use crate::{
17171723
.map(|n| n.node)
17181724
.collect::<Vec<_>>();
17191725

1720-
let expected_filter_nodes = candidates_with_history_after_filtering(graph, expected_select_nodes.clone());
1726+
let expected_filter_nodes =
1727+
candidates_with_history_after_filtering(graph, expected_select_nodes.clone());
17211728

17221729
let filtered_event_graph = graph.filter(filter.clone()).unwrap();
17231730
let filtered_event_nodes = sort_vids(
@@ -1799,7 +1806,6 @@ use crate::{
17991806
graph
18001807
}
18011808

1802-
18031809
fn degree_graph_with_add_edge_only() -> Graph {
18041810
let graph = Graph::new();
18051811

@@ -1844,7 +1850,6 @@ use crate::{
18441850
graph
18451851
}
18461852

1847-
18481853
// Property-based tests for degree filtering
18491854
proptest! {
18501855
#[test]
@@ -2033,7 +2038,7 @@ use crate::{
20332038
|d| d > threshold as usize && d < (threshold + 5) as usize,
20342039
&format!("OUT > {} AND OUT < {}", threshold, threshold + 5),
20352040
);
2036-
}
2041+
}
20372042

20382043
#[test]
20392044
fn prop_degree_filter_or(threshold in 0u64..15) {
@@ -2158,7 +2163,7 @@ use crate::{
21582163
&format!("OUT is_not_in({}, {})", val1, val2),
21592164
);
21602165
}
2161-
}
2166+
}
21622167

21632168
#[test]
21642169
fn test_degree_filter_with_invalid_expressions() {
@@ -13021,4 +13026,3 @@ mod test_edge_composite_filter {
1302113026
);
1302213027
}
1302313028
}
13024-

raphtory/src/arrow_loader/df_loaders/nodes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ use crate::arrow_loader::df_loaders::build_progress_bar;
4040
use crate::arrow_loader::{
4141
dataframe::{DFChunk, DFView},
4242
df_loaders::{
43-
extract_secondary_index_col, process_shared_properties, resolve_nodes_and_type_with_cache,
43+
extract_secondary_index_col, group_rows_by_vid_segment, process_shared_properties,
44+
resolve_nodes_and_type_with_cache, secondary_index_at,
4445
},
4546
layer_col::{lift_layer_col, lift_node_type_col, LayerCol},
4647
node_col::NodeCol,
@@ -49,7 +50,6 @@ use crate::arrow_loader::{
4950
};
5051
#[cfg(feature = "progress")]
5152
use kdam::BarExt;
52-
use crate::arrow_loader::df_loaders::{group_rows_by_vid_segment, secondary_index_at};
5353

5454
/// If layer_id_col is provided, then layer_col must also be provided
5555
#[allow(clippy::too_many_arguments)]

raphtory/src/db/api/state/ops/filter.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,25 @@ use crate::{
22
db::{
33
api::{
44
state::{
5-
Index, ops::{Const, Degree, IntoDynNodeOp, NodeOp, TypeId}
5+
ops::{Const, Degree, IntoDynNodeOp, NodeOp, TypeId},
6+
Index,
67
},
78
view::internal::{GraphView, NodeList},
89
},
910
graph::{
1011
create_node_type_filter,
11-
views::filter::model::{FilterOperator, degree_filter::DegreeFilter, filter::{Filter, FilterValue}, node_filter::NodeFilter, property_filter::PropertyFilterValue},
12+
views::filter::model::{
13+
degree_filter::DegreeFilter,
14+
filter::{Filter, FilterValue},
15+
node_filter::NodeFilter,
16+
property_filter::PropertyFilterValue,
17+
FilterOperator,
18+
},
1219
},
1320
},
1421
prelude::{GraphViewOps, PropertyFilter},
1522
};
16-
use raphtory_api::core::entities::{VID, properties::prop::Prop};
23+
use raphtory_api::core::entities::{properties::prop::Prop, VID};
1724
use raphtory_core::entities::nodes::node_ref::AsNodeRef;
1825
use raphtory_storage::graph::{graph::GraphStorage, nodes::node_storage_ops::NodeStorageOps};
1926
use std::sync::Arc;
@@ -225,19 +232,19 @@ impl<G: GraphView> NodeOp for NodePropertyFilterOp<G> {
225232
pub struct NodeDegreeFilterOp<G> {
226233
degree: Degree<G>,
227234
operator: FilterOperator,
228-
value: PropertyFilterValue
235+
value: PropertyFilterValue,
229236
}
230237

231238
impl<G> NodeDegreeFilterOp<G> {
232239
pub(crate) fn new(graph: G, filter: DegreeFilter) -> Self {
233240
let degree = Degree {
234241
dir: filter.direction,
235-
view: graph
242+
view: graph,
236243
};
237244
Self {
238245
degree,
239246
operator: filter.operator,
240-
value: filter.value
247+
value: filter.value,
241248
}
242249
}
243250
}
@@ -248,7 +255,8 @@ impl<G: GraphView> NodeOp for NodeDegreeFilterOp<G> {
248255
fn apply(&self, storage: &GraphStorage, node: VID) -> Self::Output {
249256
let node_degree = self.degree.apply(storage, node);
250257
let node_degree_prop = Prop::U64(node_degree as u64);
251-
self.operator.apply_to_property(&self.value, Some(&node_degree_prop))
258+
self.operator
259+
.apply_to_property(&self.value, Some(&node_degree_prop))
252260
}
253261
}
254262

0 commit comments

Comments
 (0)