Skip to content

Commit

Permalink
fx_hashmap for fixed graphql schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianmurariu committed Dec 18, 2024
1 parent dae9491 commit e3ce6bc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions raphtory-graphql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ config = { workspace = true }
url = { workspace = true }
base64-compat = { workspace = true }
reqwest = { workspace = true }
rustc-hash = { workspace = true }
moka = { workspace = true }
# python binding optional dependencies
pyo3 = { workspace = true, optional = true }
Expand Down
5 changes: 3 additions & 2 deletions raphtory-graphql/src/model/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use raphtory::{
db::graph::node::NodeView,
prelude::{GraphViewOps, NodeViewOps},
};
use std::collections::{HashMap, HashSet};
use rustc_hash::FxHashMap;
use std::collections::HashSet;

pub(crate) mod edge_schema;
pub(crate) mod graph_schema;
Expand All @@ -21,7 +22,7 @@ fn get_node_type<'graph, G: GraphViewOps<'graph>>(node: NodeView<G>) -> String {
}
}

type SchemaAggregate = HashMap<(String, String), HashSet<String>>;
type SchemaAggregate = FxHashMap<(String, String), HashSet<String>>;

fn merge_schemas(mut s1: SchemaAggregate, s2: SchemaAggregate) -> SchemaAggregate {
for ((key, prop_type), set2) in s2 {
Expand Down
2 changes: 1 addition & 1 deletion raphtory-graphql/src/model/schema/node_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl NodeSchema {
let schema: SchemaAggregate = filtered_nodes
.map(collect_node_schema)
.reduce(merge_schemas)
.unwrap_or_else(|| FxHashMap::default());
.unwrap_or_default();

schema.into_iter().map(|prop| prop.into()).collect_vec()
}
Expand Down

0 comments on commit e3ce6bc

Please sign in to comment.