Skip to content

Commit

Permalink
remove Graph and PersistentGraph from Prop
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianmurariu committed Dec 18, 2024
1 parent 1539e7e commit fcdf05f
Show file tree
Hide file tree
Showing 14 changed files with 233 additions and 309 deletions.
161 changes: 97 additions & 64 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ members = [
"raphtory-graphql",
"raphtory-api",
]
default-members = ["raphtory", "raphtory-graphql"]
default-members = [
"raphtory",
"raphtory-graphql"
]
resolver = "2"

[workspace.package]
Expand Down Expand Up @@ -40,9 +43,9 @@ debug = 0

[workspace.dependencies]
#[public-storage]
pometry-storage = { version = ">=0.8.1", path = "pometry-storage" }
# pometry-storage = { version = ">=0.8.1", path = "pometry-storage" }
#[private-storage]
# pometry-storage = { path = "pometry-storage-private", package = "pometry-storage-private" }
pometry-storage = { path = "pometry-storage-private", package = "pometry-storage-private" }
async-graphql = { version = "7.0.12", features = [
"dynamic-schema",
] }
Expand Down Expand Up @@ -136,6 +139,7 @@ memmap2 = { version = "0.9.4" }
ahash = { version = "0.8.3", features = ["serde"] }
strum = { version = "0.26.1", features = ["derive"] }
bytemuck = { version = "1.18.0", features = ["derive"] }
bytes = {version = "1.9", features = ["serde"]}
ouroboros = "0.18.3"
url = "2.2"
base64-compat = { package = "base64-compat", version = "1.0.0" }
Expand Down
14 changes: 8 additions & 6 deletions raphtory-api/src/core/entities/properties/props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,15 @@ impl PropMapper {
}
}

pub fn set_id_and_dtype(&self, key: impl Into<ArcStr>, id: usize, dtype: PropType) {
let mut dtypes = self.dtypes.write();
self.set_id(key, id);
if dtypes.len() <= id {
dtypes.resize(id + 1, PropType::Empty);
pub fn set_id_and_dtype(&self, key: impl Into<ArcStr>, id: usize, dtype: Option<PropType>) {
if let Some(dtype) = dtype {
let mut dtypes = self.dtypes.write();
self.set_id(key, id);
if dtypes.len() <= id {
dtypes.resize(id + 1, PropType::Empty);
}
dtypes[id] = dtype;
}
dtypes[id] = dtype;
}

pub fn get_dtype(&self, prop_id: usize) -> Option<PropType> {
Expand Down
6 changes: 2 additions & 4 deletions raphtory-api/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ pub enum PropType {
List,
Map,
NDTime,
Graph,
PersistentGraph,
Blob,
Document,
DTime,
}
Expand All @@ -56,8 +55,7 @@ impl Display for PropType {
PropType::List => "List",
PropType::Map => "Map",
PropType::NDTime => "NDTime",
PropType::Graph => "Graph",
PropType::PersistentGraph => "PersistentGraph",
PropType::Blob => "Blob",
PropType::Document => "Document",
PropType::DTime => "DTime",
};
Expand Down
6 changes: 2 additions & 4 deletions raphtory/src/algorithms/pathing/dijkstra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ pub fn dijkstra_single_source_shortest_paths<G: StaticGraphViewOps, T: AsNodeRef
PropType::List => return Err("Weight type: List, not supported"),
PropType::Map => return Err("Weight type: Map, not supported"),
PropType::DTime => return Err("Weight type: DTime, not supported"),
PropType::Blob => return Err("Weight type: Blob, not supported"),
PropType::NDTime => return Err("Weight type: NDTime, not supported"),
PropType::Graph => return Err("Weight type: Graph, not supported"),
PropType::PersistentGraph => return Err("Weight type: Persistent Graph, not supported"),
PropType::Document => return Err("Weight type: Document, not supported"),
};
let max_val = match weight_type.unwrap() {
Expand All @@ -128,8 +127,7 @@ pub fn dijkstra_single_source_shortest_paths<G: StaticGraphViewOps, T: AsNodeRef
PropType::Map => return Err("Weight type: Map, not supported"),
PropType::DTime => return Err("Weight type: DTime, not supported"),
PropType::NDTime => return Err("Weight type: NDTime, not supported"),
PropType::Graph => return Err("Weight type: Graph, not supported"),
PropType::PersistentGraph => return Err("Weight type: Persistent Graph, not supported"),
PropType::Blob => return Err("Weight type: Blob, not supported"),
PropType::Document => return Err("Weight type: Document, not supported"),
};
let mut heap = BinaryHeap::new();
Expand Down
56 changes: 14 additions & 42 deletions raphtory/src/core/entities/properties/tprop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ use crate::{
entities::properties::tcell::TCell, storage::timeindex::TimeIndexEntry,
utils::errors::GraphError, DocumentInput, Prop, PropType,
},
db::{
api::storage::graph::tprop_storage_ops::TPropOps,
graph::{graph::Graph, views::deletion_graph::PersistentGraph},
},
db::api::storage::graph::tprop_storage_ops::TPropOps,
};
use chrono::{DateTime, NaiveDateTime, Utc};
use raphtory_api::{core::storage::arc_str::ArcStr, iter::BoxedLIter};
Expand All @@ -29,9 +26,8 @@ pub enum TProp {
F64(TCell<f64>),
Bool(TCell<bool>),
DTime(TCell<DateTime<Utc>>),
Blob(TCell<Vec<u8>>),
NDTime(TCell<NaiveDateTime>),
Graph(TCell<Graph>),
PersistentGraph(TCell<PersistentGraph>),
Document(TCell<DocumentInput>),
List(TCell<Arc<Vec<Prop>>>),
Map(TCell<Arc<HashMap<ArcStr, Prop>>>),
Expand All @@ -52,12 +48,11 @@ impl TProp {
TProp::F64(_) => PropType::F64,
TProp::Bool(_) => PropType::Bool,
TProp::NDTime(_) => PropType::NDTime,
TProp::Graph(_) => PropType::Graph,
TProp::PersistentGraph(_) => PropType::PersistentGraph,
TProp::Document(_) => PropType::Document,
TProp::List(_) => PropType::List,
TProp::Map(_) => PropType::Map,
TProp::DTime(_) => PropType::DTime,
TProp::Blob(_) => PropType::Bool,
}
}

Expand All @@ -75,8 +70,7 @@ impl TProp {
Prop::Bool(value) => TProp::Bool(TCell::new(t, value)),
Prop::DTime(value) => TProp::DTime(TCell::new(t, value)),
Prop::NDTime(value) => TProp::NDTime(TCell::new(t, value)),
Prop::Graph(value) => TProp::Graph(TCell::new(t, value)),
Prop::PersistentGraph(value) => TProp::PersistentGraph(TCell::new(t, value)),
Prop::Blob(value) => TProp::Blob(TCell::new(t, value)),
Prop::Document(value) => TProp::Document(TCell::new(t, value)),
Prop::List(value) => TProp::List(TCell::new(t, value)),
Prop::Map(value) => TProp::Map(TCell::new(t, value)),
Expand Down Expand Up @@ -126,10 +120,7 @@ impl TProp {
(TProp::NDTime(cell), Prop::NDTime(a)) => {
cell.set(t, a);
}
(TProp::Graph(cell), Prop::Graph(a)) => {
cell.set(t, a);
}
(TProp::PersistentGraph(cell), Prop::PersistentGraph(a)) => {
(TProp::Blob(cell), Prop::Blob(a)) => {
cell.set(t, a);
}
(TProp::Document(cell), Prop::Document(a)) => {
Expand Down Expand Up @@ -166,13 +157,9 @@ impl TProp {
TProp::NDTime(cell) => {
Box::new(cell.iter().map(|(t, value)| (*t, Prop::NDTime(*value))))
}
TProp::Graph(cell) => Box::new(
TProp::Blob(cell) => Box::new(
cell.iter()
.map(|(t, value)| (*t, Prop::Graph(value.clone()))),
),
TProp::PersistentGraph(cell) => Box::new(
cell.iter()
.map(|(t, value)| (*t, Prop::PersistentGraph(value.clone()))),
.map(|(t, value)| (*t, Prop::Blob(value.clone()))),
),
TProp::Document(cell) => Box::new(
cell.iter()
Expand Down Expand Up @@ -210,13 +197,9 @@ impl TProp {
TProp::NDTime(cell) => {
Box::new(cell.iter_t().map(|(t, value)| (t, Prop::NDTime(*value))))
}
TProp::Graph(cell) => Box::new(
TProp::Blob(cell) => Box::new(
cell.iter_t()
.map(|(t, value)| (t, Prop::Graph(value.clone()))),
),
TProp::PersistentGraph(cell) => Box::new(
cell.iter_t()
.map(|(t, value)| (t, Prop::PersistentGraph(value.clone()))),
.map(|(t, value)| (t, Prop::Blob(value.clone()))),
),
TProp::Document(cell) => Box::new(
cell.iter_t()
Expand Down Expand Up @@ -286,13 +269,9 @@ impl TProp {
cell.iter_window(r)
.map(|(t, value)| (*t, Prop::NDTime(*value))),
),
TProp::Graph(cell) => Box::new(
cell.iter_window(r)
.map(|(t, value)| (*t, Prop::Graph(value.clone()))),
),
TProp::PersistentGraph(cell) => Box::new(
TProp::Blob(cell) => Box::new(
cell.iter_window(r)
.map(|(t, value)| (*t, Prop::PersistentGraph(value.clone()))),
.map(|(t, value)| (*t, Prop::Blob(value.clone()))),
),
TProp::Document(cell) => Box::new(
cell.iter_window(r)
Expand Down Expand Up @@ -326,12 +305,7 @@ impl<'a> TPropOps<'a> for &'a TProp {
TProp::Bool(cell) => cell.last_before(t).map(|(t, v)| (t, Prop::Bool(*v))),
TProp::DTime(cell) => cell.last_before(t).map(|(t, v)| (t, Prop::DTime(*v))),
TProp::NDTime(cell) => cell.last_before(t).map(|(t, v)| (t, Prop::NDTime(*v))),
TProp::Graph(cell) => cell
.last_before(t)
.map(|(t, v)| (t, Prop::Graph(v.clone()))),
TProp::PersistentGraph(cell) => cell
.last_before(t)
.map(|(t, v)| (t, Prop::PersistentGraph(v.clone()))),
TProp::Blob(cell) => cell.last_before(t).map(|(t, v)| (t, Prop::Blob(v.clone()))),
TProp::Document(cell) => cell
.last_before(t)
.map(|(t, v)| (t, Prop::Document(v.clone()))),
Expand Down Expand Up @@ -366,8 +340,7 @@ impl<'a> TPropOps<'a> for &'a TProp {
TProp::Bool(cell) => cell.at(ti).map(|v| Prop::Bool(*v)),
TProp::DTime(cell) => cell.at(ti).map(|v| Prop::DTime(*v)),
TProp::NDTime(cell) => cell.at(ti).map(|v| Prop::NDTime(*v)),
TProp::Graph(cell) => cell.at(ti).map(|v| Prop::Graph(v.clone())),
TProp::PersistentGraph(cell) => cell.at(ti).map(|v| Prop::PersistentGraph(v.clone())),
TProp::Blob(cell) => cell.at(ti).map(|v| Prop::Blob(v.clone())),
TProp::Document(cell) => cell.at(ti).map(|v| Prop::Document(v.clone())),
TProp::List(cell) => cell.at(ti).map(|v| Prop::List(v.clone())),
TProp::Map(cell) => cell.at(ti).map(|v| Prop::Map(v.clone())),
Expand All @@ -389,8 +362,7 @@ impl<'a> TPropOps<'a> for &'a TProp {
TProp::Bool(v) => v.len(),
TProp::DTime(v) => v.len(),
TProp::NDTime(v) => v.len(),
TProp::Graph(v) => v.len(),
TProp::PersistentGraph(v) => v.len(),
TProp::Blob(v) => v.len(),
TProp::Document(v) => v.len(),
TProp::List(v) => v.len(),
TProp::Map(v) => v.len(),
Expand Down
85 changes: 19 additions & 66 deletions raphtory/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
//! * `macOS`
//!
use crate::{
db::graph::{graph::Graph, views::deletion_graph::PersistentGraph},
prelude::GraphViewOps,
};
use chrono::{DateTime, NaiveDateTime, Utc};
use itertools::Itertools;
use raphtory_api::core::storage::arc_str::ArcStr;
Expand Down Expand Up @@ -90,8 +86,7 @@ pub enum Prop {
Map(Arc<HashMap<ArcStr, Prop>>),
NDTime(NaiveDateTime),
DTime(DateTime<Utc>),
Graph(Graph),
PersistentGraph(PersistentGraph),
Blob(Vec<u8>),
Document(DocumentInput),
}

Expand All @@ -115,6 +110,7 @@ impl Hash for Prop {
}
Prop::Bool(b) => b.hash(state),
Prop::NDTime(dt) => dt.hash(state),
Prop::Blob(b) => b.hash(state),
Prop::DTime(dt) => dt.hash(state),
Prop::List(v) => {
for prop in v.iter() {
Expand All @@ -127,22 +123,6 @@ impl Hash for Prop {
prop.hash(state);
}
}
Prop::Graph(g) => {
for node in g.nodes() {
node.node.hash(state);
}
for edge in g.edges() {
edge.edge.pid().hash(state);
}
}
Prop::PersistentGraph(pg) => {
for node in pg.nodes() {
node.node.hash(state);
}
for edge in pg.edges() {
edge.edge.pid().hash(state);
}
}
Prop::Document(d) => d.hash(state),
}
}
Expand Down Expand Up @@ -186,8 +166,7 @@ impl Prop {
Prop::List(_) => PropType::List,
Prop::Map(_) => PropType::Map,
Prop::NDTime(_) => PropType::NDTime,
Prop::Graph(_) => PropType::Graph,
Prop::PersistentGraph(_) => PropType::PersistentGraph,
Prop::Blob(_) => PropType::Blob,
Prop::Document(_) => PropType::Document,
Prop::DTime(_) => PropType::DTime,
}
Expand Down Expand Up @@ -323,18 +302,15 @@ pub trait PropUnwrap: Sized {
self.into_ndtime().unwrap()
}

fn into_graph(self) -> Option<Graph>;

fn into_persistent_graph(self) -> Option<PersistentGraph>;

fn unwrap_graph(self) -> Graph {
self.into_graph().unwrap()
}

fn into_document(self) -> Option<DocumentInput>;
fn unwrap_document(self) -> DocumentInput {
self.into_document().unwrap()
}

fn into_blob(self) -> Option<Vec<u8>>;
fn unwrap_blob(self) -> Vec<u8> {
self.into_blob().unwrap()
}
}

impl<P: PropUnwrap> PropUnwrap for Option<P> {
Expand Down Expand Up @@ -390,17 +366,13 @@ impl<P: PropUnwrap> PropUnwrap for Option<P> {
self.and_then(|p| p.into_ndtime())
}

fn into_graph(self) -> Option<Graph> {
self.and_then(|p| p.into_graph())
}

fn into_persistent_graph(self) -> Option<PersistentGraph> {
self.and_then(|p| p.into_persistent_graph())
}

fn into_document(self) -> Option<DocumentInput> {
self.and_then(|p| p.into_document())
}

fn into_blob(self) -> Option<Vec<u8>> {
self.and_then(|p| p.into_blob())
}
}

impl PropUnwrap for Prop {
Expand Down Expand Up @@ -508,25 +480,17 @@ impl PropUnwrap for Prop {
}
}

fn into_graph(self) -> Option<Graph> {
if let Prop::Graph(g) = self {
Some(g)
} else {
None
}
}

fn into_persistent_graph(self) -> Option<PersistentGraph> {
if let Prop::PersistentGraph(g) = self {
Some(g)
fn into_document(self) -> Option<DocumentInput> {
if let Prop::Document(d) = self {
Some(d)
} else {
None
}
}

fn into_document(self) -> Option<DocumentInput> {
if let Prop::Document(d) = self {
Some(d)
fn into_blob(self) -> Option<Vec<u8>> {
if let Prop::Blob(v) = self {
Some(v)
} else {
None
}
Expand All @@ -548,18 +512,7 @@ impl Display for Prop {
Prop::Bool(value) => write!(f, "{}", value),
Prop::DTime(value) => write!(f, "{}", value),
Prop::NDTime(value) => write!(f, "{}", value),
Prop::Graph(value) => write!(
f,
"Graph(num_nodes={}, num_edges={})",
value.count_nodes(),
value.count_edges()
),
Prop::PersistentGraph(value) => write!(
f,
"Graph(num_nodes={}, num_edges={})",
value.count_nodes(),
value.count_edges()
),
Prop::Blob(value) => write!(f, "{:?}", value),
Prop::List(value) => {
write!(
f,
Expand Down
Loading

0 comments on commit fcdf05f

Please sign in to comment.