Skip to content

Commit

Permalink
fix protobuf errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianmurariu committed Jan 24, 2025
1 parent 3771175 commit 254a97d
Show file tree
Hide file tree
Showing 12 changed files with 217 additions and 209 deletions.
206 changes: 131 additions & 75 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions raphtory-benchmark/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,6 @@ pub fn run_graph_ops_benches(
}

pub fn run_proto_encode_benchmark(group: &mut BenchmarkGroup<WallTime>, graph: Graph) {
println!("graph: {graph}");
bench(group, "proto_encode", None, |b: &mut Bencher| {
b.iter_batched(
|| TempDir::new().unwrap(),
Expand All @@ -586,7 +585,6 @@ pub fn run_proto_encode_benchmark(group: &mut BenchmarkGroup<WallTime>, graph: G
}

pub fn run_proto_decode_benchmark(group: &mut BenchmarkGroup<WallTime>, graph: Graph) {
println!("graph: {graph}");
let f = TempDir::new().unwrap();
graph.encode(f.path()).unwrap();
bench(group, "proto_decode", None, |b| {
Expand Down
Empty file.
Binary file added raphtory/resources/test/old_proto/str/graph
Binary file not shown.
6 changes: 2 additions & 4 deletions raphtory/src/algorithms/community_detection/louvain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ mod test {
test_storage,
};
use proptest::prelude::*;
#[cfg(feature = "io")]
use tracing::info;

#[cfg(feature = "io")]
use raphtory_api::core::utils::logging::global_info_logger;
Expand Down Expand Up @@ -171,8 +169,8 @@ mod test {
.unwrap();

test_storage!(&graph, |graph| {
let result = louvain::<ModularityUnDir, _>(graph, 1.0, None, None);
info!("{result:?}")
let _ = louvain::<ModularityUnDir, _>(graph, 1.0, None, None);
// TODO: Add assertions
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ mod sssp_tests {
test_storage,
};
use raphtory_api::core::utils::logging::global_info_logger;
use tracing::info;

fn load_graph(edges: Vec<(i64, u64, u64)>) -> Graph {
let graph = Graph::new();
Expand Down Expand Up @@ -120,8 +119,7 @@ mod sssp_tests {
for (node, values) in expected {
assert_eq!(results.get_by_node(node).unwrap().name(), values);
}
let binding = single_source_shortest_path(graph, 5, Some(4));
info!("{:?}", binding);
let _ = single_source_shortest_path(graph, 5, Some(4));
});
}
}
67 changes: 1 addition & 66 deletions raphtory/src/db/graph/views/deletion_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,7 @@ mod test_deletions {
test_storage,
};
use itertools::Itertools;
use raphtory_api::core::{entities::GID, utils::logging::global_info_logger};
use tracing::info;
use raphtory_api::core::entities::GID;

#[test]
fn test_nodes() {
Expand Down Expand Up @@ -1226,70 +1225,6 @@ mod test_deletions {
assert_eq!(v.latest_time(), Some(i64::MAX));
}

#[test]
fn test_jira() {
global_info_logger();
let g = PersistentGraph::new();

g.add_edge(0, 1, 2, [("added", Prop::I64(0))], Some("assigned"))
.unwrap();
g.add_edge(1, 1, 3, [("added", Prop::I64(0))], Some("assigned"))
.unwrap();
g.add_edge(2, 4, 2, [("added", Prop::I64(0))], Some("has"))
.unwrap();
g.add_edge(3, 4, 2, [("added", Prop::I64(0))], Some("has"))
.unwrap();
g.add_edge(4, 5, 2, [("added", Prop::I64(0))], Some("blocks"))
.unwrap();
g.add_edge(5, 4, 5, [("added", Prop::I64(0))], Some("has"))
.unwrap();
g.add_edge(6, 6, 5, [("added", Prop::I64(0))], Some("assigned"))
.unwrap();

let nodes = g
.window(0, 1701786285758)
.layers(vec!["assigned", "has", "blocks"])
.unwrap()
.edges()
.into_iter()
.map(|vv| vv.id())
.collect_vec();

info!("windowed edges = {:?}", nodes);

let nodes = g
.window(0, 1701786285758)
.layers(vec!["assigned", "has", "blocks"])
.unwrap()
.nodes()
.into_iter()
.map(|vv| vv.name())
.collect_vec();

info!("windowed nodes = {:?}", nodes);

let nodes = g
.at(1701786285758)
.layers(vec!["assigned", "has", "blocks"])
.unwrap()
.edges()
.into_iter()
.map(|vv| vv.id())
.collect_vec();
info!("at edges = {:?}", nodes);

let nodes = g
.at(1701786285758)
.layers(vec!["assigned", "has", "blocks"])
.unwrap()
.nodes()
.into_iter()
.map(|vv| vv.id())
.collect_vec();

info!("at nodes = {:?}", nodes);
}

#[test]
fn test_event_graph() {
let pg = PersistentGraph::new();
Expand Down
10 changes: 5 additions & 5 deletions raphtory/src/serialise/graph.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,35 @@ message NewMeta {
message NewGraphTProp {
string name = 1;
uint64 id = 2;
optional PropType.PropType p_type = 3 [deprecated=true];
PropType.PropType p_type = 3 [deprecated=true];
PropType.PType p_type2 = 4;
}

message NewNodeCProp {
string name = 1;
uint64 id = 2;
optional PropType.PropType p_type = 3 [deprecated=true];
PropType.PropType p_type = 3 [deprecated=true];
PropType.PType p_type2 = 4;
}

message NewNodeTProp {
string name = 1;
uint64 id = 2;
optional PropType.PropType p_type = 3[deprecated=true];
PropType.PropType p_type = 3[deprecated=true];
PropType.PType p_type2 = 4;
}

message NewEdgeCProp {
string name = 1;
uint64 id = 2;
optional PropType.PropType p_type = 3[deprecated=true];
PropType.PropType p_type = 3[deprecated=true];
PropType.PType p_type2 = 4;
}

message NewEdgeTProp {
string name = 1;
uint64 id = 2;
optional PropType.PropType p_type = 3 [deprecated=true];
PropType.PropType p_type = 3 [deprecated=true];
PropType.PType p_type2 = 4;
}

Expand Down
31 changes: 14 additions & 17 deletions raphtory/src/serialise/proto_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,24 +235,21 @@ impl UpdateNodeTProps {
}

pub(crate) trait PropTypeExt {
fn p_type(&self) -> Option<i32>;
fn p_type(&self) -> SPropType;
fn p_type2(&self) -> Option<&PType>;

fn prop_type(&self) -> Option<PropType> {
fn prop_type(&self) -> PropType {
self.p_type2()
.and_then(|p_type| as_prop_type2(*p_type))
.or_else(|| {
self.p_type()
.as_ref()
.and_then(|p_type| as_prop_type(prop_type_from_i32(*p_type)?))
})
.or_else(|| as_prop_type(self.p_type()))
.unwrap_or(PropType::Empty)
}
}

impl PropTypeExt for NewNodeCProp {
#[allow(deprecated)]
fn p_type(&self) -> Option<i32> {
self.p_type
fn p_type(&self) -> SPropType {
self.p_type()
}

fn p_type2(&self) -> Option<&PType> {
Expand All @@ -262,8 +259,8 @@ impl PropTypeExt for NewNodeCProp {

impl PropTypeExt for NewNodeTProp {
#[allow(deprecated)]
fn p_type(&self) -> Option<i32> {
self.p_type
fn p_type(&self) -> SPropType {
self.p_type()
}

fn p_type2(&self) -> Option<&PType> {
Expand All @@ -273,8 +270,8 @@ impl PropTypeExt for NewNodeTProp {

impl PropTypeExt for NewEdgeCProp {
#[allow(deprecated)]
fn p_type(&self) -> Option<i32> {
self.p_type
fn p_type(&self) -> SPropType {
self.p_type()
}

fn p_type2(&self) -> Option<&PType> {
Expand All @@ -284,8 +281,8 @@ impl PropTypeExt for NewEdgeCProp {

impl PropTypeExt for NewEdgeTProp {
#[allow(deprecated)]
fn p_type(&self) -> Option<i32> {
self.p_type
fn p_type(&self) -> SPropType {
self.p_type()
}

fn p_type2(&self) -> Option<&PType> {
Expand All @@ -295,8 +292,8 @@ impl PropTypeExt for NewEdgeTProp {

impl PropTypeExt for NewGraphTProp {
#[allow(deprecated)]
fn p_type(&self) -> Option<i32> {
self.p_type
fn p_type(&self) -> SPropType {
self.p_type()
}

fn p_type2(&self) -> Option<&PType> {
Expand Down
100 changes: 63 additions & 37 deletions raphtory/src/serialise/serialise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,57 +283,52 @@ impl StableDecode for TemporalGraph {
.set_id(node_type.name.as_str(), node_type.id as usize);
}
Meta::NewNodeCprop(node_cprop) => {
if let Some(p_type) = node_cprop.prop_type() {
storage.node_meta.const_prop_meta().set_id_and_dtype(
node_cprop.name.as_str(),
node_cprop.id as usize,
p_type,
)
}
let p_type = node_cprop.prop_type();
storage.node_meta.const_prop_meta().set_id_and_dtype(
node_cprop.name.as_str(),
node_cprop.id as usize,
p_type,
)
}
Meta::NewNodeTprop(node_tprop) => {
if let Some(p_type) = node_tprop.prop_type() {
storage.node_meta.temporal_prop_meta().set_id_and_dtype(
node_tprop.name.as_str(),
node_tprop.id as usize,
p_type,
)
}
let p_type = node_tprop.prop_type();
storage.node_meta.temporal_prop_meta().set_id_and_dtype(
node_tprop.name.as_str(),
node_tprop.id as usize,
p_type,
)
}
Meta::NewGraphCprop(graph_cprop) => storage
.graph_meta
.const_prop_meta()
.set_id(graph_cprop.name.as_str(), graph_cprop.id as usize),
Meta::NewGraphTprop(graph_tprop) => {
if let Some(p_type) = graph_tprop.prop_type() {
storage.graph_meta.temporal_prop_meta().set_id_and_dtype(
graph_tprop.name.as_str(),
graph_tprop.id as usize,
p_type,
)
}
let p_type = graph_tprop.prop_type();
storage.graph_meta.temporal_prop_meta().set_id_and_dtype(
graph_tprop.name.as_str(),
graph_tprop.id as usize,
p_type,
)
}
Meta::NewLayer(new_layer) => storage
.edge_meta
.layer_meta()
.set_id(new_layer.name.as_str(), new_layer.id as usize),
Meta::NewEdgeCprop(edge_cprop) => {
if let Some(p_type) = edge_cprop.prop_type() {
storage.edge_meta.const_prop_meta().set_id_and_dtype(
edge_cprop.name.as_str(),
edge_cprop.id as usize,
p_type,
)
}
let p_type = edge_cprop.prop_type();
storage.edge_meta.const_prop_meta().set_id_and_dtype(
edge_cprop.name.as_str(),
edge_cprop.id as usize,
p_type,
)
}
Meta::NewEdgeTprop(edge_tprop) => {
if let Some(p_type) = edge_tprop.prop_type() {
storage.edge_meta.temporal_prop_meta().set_id_and_dtype(
edge_tprop.name.as_str(),
edge_tprop.id as usize,
p_type,
)
}
let p_type = edge_tprop.prop_type();
storage.edge_meta.temporal_prop_meta().set_id_and_dtype(
edge_tprop.name.as_str(),
edge_tprop.id as usize,
p_type,
)
}
}
}
Expand Down Expand Up @@ -570,11 +565,35 @@ mod proto_test {
use proptest::proptest;
use raphtory_api::core::storage::arc_str::ArcStr;

#[test]
fn prev_proto_str() {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.map(|p| p.join("raphtory/resources/test/old_proto/str"))
.unwrap();

let graph = Graph::decode(path).unwrap();

let nodes = graph
.nodes()
.properties()
.into_iter()
.flat_map(|(_, props)| props.into_iter())
.collect::<Vec<_>>();
assert_eq!(
nodes,
vec![
("a".into(), Some("a".into())),
("z".into(), Some("a".into())),
("a".into(), None)
]
);
}
#[test]
fn can_read_previous_proto() {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.map(|p| p.join("raphtory/resources/test/old_graph_proto.bin"))
.map(|p| p.join("raphtory/resources/test/old_proto/all_props"))
.unwrap();

let graph = Graph::decode(path).unwrap();
Expand All @@ -594,7 +613,14 @@ mod proto_test {
.collect();

let expected: HashMap<ArcStr, Vec<Option<Prop>>> = [
("name".into(), vec![None, None, None]),
(
"name".into(),
vec![
Some("Alice".into()),
Some("Alice".into()),
Some("Alice".into()),
],
),
(
"age".into(),
vec![
Expand Down

0 comments on commit 254a97d

Please sign in to comment.