Skip to content

Commit

Permalink
changes post rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianmurariu committed Jul 22, 2024
1 parent 2ae3d9b commit 31a9336
Show file tree
Hide file tree
Showing 26 changed files with 328 additions and 1,267 deletions.
58 changes: 55 additions & 3 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ debug = true

[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.5", features = ["dynamic-schema"] }
async-graphql-poem = "7.0.5"
dynamic-graphql = "0.9.0"
Expand Down
2 changes: 1 addition & 1 deletion pometry-storage-private
79 changes: 72 additions & 7 deletions raphtory-api/src/core/entities/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,6 @@ impl<'source> FromPyObject<'source> for GID {
}
}

#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)]
pub enum GidRef<'a> {
U64(u64),
I64(i64),
Str(&'a str),
}

impl GID {
pub fn into_str(self) -> Option<String> {
match self {
Expand Down Expand Up @@ -258,3 +251,75 @@ impl From<&str> for GID {
Self::Str(id.to_string())
}
}

#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)]
pub enum GidRef<'a> {
U64(u64),
I64(i64),
Str(&'a str),
}

impl<'a> From<&'a GID> for GidRef<'a> {
fn from(value: &'a GID) -> Self {
match value {
GID::U64(v) => GidRef::U64(*v),
GID::I64(v) => GidRef::I64(*v),
GID::Str(v) => GidRef::Str(v),
}
}
}

impl<'a> GidRef<'a> {
pub fn as_str(self) -> Option<&'a str> {
match self {
GidRef::Str(s) => Some(s),
_ => None,
}
}

pub fn as_i64(self) -> Option<i64> {
match self {
GidRef::I64(v) => Some(v),
_ => None,
}
}

pub fn as_u64(self) -> Option<u64> {
match self {
GidRef::U64(v) => Some(v),
_ => None,
}
}

pub fn to_owned(self) -> GID {
match self {
GidRef::U64(v) => GID::U64(v),
GidRef::I64(v) => GID::I64(v),
GidRef::Str(v) => GID::Str(v.to_owned()),
}
}

pub fn to_str(self) -> Cow<'a, str> {
match self {
GidRef::U64(v) => Cow::Owned(v.to_string()),
GidRef::I64(v) => Cow::Owned(v.to_string()),
GidRef::Str(v) => Cow::Borrowed(v),
}
}

pub fn to_i64(self) -> Option<i64> {
match self {
GidRef::U64(v) => v.to_i64(),
GidRef::I64(v) => Some(v),
GidRef::Str(v) => parse_u64_strict(v)?.to_i64(),
}
}

pub fn to_u64(self) -> Option<u64> {
match self {
GidRef::U64(v) => Some(v),
GidRef::I64(v) => v.to_u64(),
GidRef::Str(v) => parse_u64_strict(v),
}
}
}
5 changes: 1 addition & 4 deletions raphtory-benchmark/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,7 @@ fn main() {
// Out neighbours of all nodes with time
now = Instant::now();
let nodes = &g.nodes();
let _out_neighbours = nodes
.iter()
.map(|v| v.out_neighbours())
.collect::<Vec<_>>();
let _out_neighbours = nodes.iter().map(|v| v.out_neighbours()).collect::<Vec<_>>();
println!("Out neighbours: {} seconds", now.elapsed().as_secs_f64());

// page rank with time
Expand Down
2 changes: 1 addition & 1 deletion raphtory-cypher/examples/raphtory_cypher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod cypher {
use arrow::util::pretty::print_batches;
use clap::Parser;
use futures::{stream, StreamExt};
use raphtory::disk_graph::graph_impl::{DiskGraphStorage, ParquetLayerCols};
use raphtory::disk_graph::{graph_impl::ParquetLayerCols, DiskGraphStorage};
use raphtory_cypher::{run_cypher, run_cypher_to_streams, run_sql};
use serde::{de::DeserializeOwned, Deserialize};

Expand Down
2 changes: 1 addition & 1 deletion raphtory-cypher/src/executor/table_provider/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use datafusion::{
};
use futures::Stream;
use pometry_storage::prelude::*;
use raphtory::disk_graph::graph_impl::DiskGraphStorage;
use raphtory::disk_graph::DiskGraphStorage;

use crate::executor::{arrow2_to_arrow_buf, ExecError};

Expand Down
2 changes: 1 addition & 1 deletion raphtory-cypher/src/executor/table_provider/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use futures::Stream;
use pometry_storage::properties::ConstProps;
use raphtory::{
core::entities::VID,
disk_graph::{graph_impl::DiskGraphStorage, prelude::*},
disk_graph::{prelude::*, DiskGraphStorage},
};
use std::{any::Any, fmt::Formatter, sync::Arc};

Expand Down
2 changes: 1 addition & 1 deletion raphtory-cypher/src/hop/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ use pometry_storage::graph_fragment::TempColGraphFragment;
use raphtory::{
core::{entities::VID, Direction},
disk_graph::{
graph_impl::DiskGraphStorage,
prelude::{ArrayOps, BaseArrayOps, PrimitiveCol},
DiskGraphStorage,
},
};

Expand Down
2 changes: 1 addition & 1 deletion raphtory-cypher/src/hop/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use datafusion::{
logical_expr::{Expr, LogicalPlan, TableScan, UserDefinedLogicalNodeCore},
};

use raphtory::{core::Direction, disk_graph::graph_impl::DiskGraphStorage};
use raphtory::{core::Direction, disk_graph::DiskGraphStorage};

#[derive(Debug, PartialEq, Hash, Eq)]
pub struct HopPlan {
Expand Down
6 changes: 3 additions & 3 deletions raphtory-cypher/src/hop/rule.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::sync::Arc;

use super::execution::HopExec;
use crate::hop::operator::HopPlan;
use async_trait::async_trait;
use datafusion::{
Expand All @@ -11,8 +12,7 @@ use datafusion::{
physical_plan::ExecutionPlan,
physical_planner::{DefaultPhysicalPlanner, ExtensionPlanner, PhysicalPlanner},
};
use raphtory::{core::Direction, disk_graph::graph_impl::DiskGraphStorage};
use super::execution::HopExec;
use raphtory::{core::Direction, disk_graph::DiskGraphStorage};

pub struct HopRule {
pub graph: DiskGraphStorage,
Expand Down Expand Up @@ -139,7 +139,7 @@ impl ExtensionPlanner for HopPlanner {
#[cfg(test)]
mod test {
use arrow::util::pretty::print_batches;
use raphtory::disk_graph::graph_impl::DiskGraphStorage;
use raphtory::disk_graph::DiskGraphStorage;
use tempfile::tempdir;

use crate::prepare_plan;
Expand Down
6 changes: 3 additions & 3 deletions raphtory-cypher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod cypher {
parser::ast::*,
*,
};
use raphtory::disk_graph::graph_impl::DiskGraphStorage;
use raphtory::disk_graph::DiskGraphStorage;

use crate::{
executor::table_provider::node::NodeTableProvider,
Expand Down Expand Up @@ -185,7 +185,7 @@ mod cypher {
use arrow_array::RecordBatch;
use tempfile::tempdir;

use raphtory::{disk_graph::graph_impl::DiskGraphStorage, prelude::*};
use raphtory::{disk_graph::DiskGraphStorage, prelude::*};

use crate::run_cypher;

Expand Down Expand Up @@ -280,7 +280,7 @@ mod cypher {
use arrow::util::pretty::print_batches;
use tempfile::tempdir;

use raphtory::disk_graph::graph_impl::{DiskGraphStorage, ParquetLayerCols};
use raphtory::disk_graph::{graph_impl::ParquetLayerCols, DiskGraphStorage};

use crate::run_cypher;

Expand Down
3 changes: 2 additions & 1 deletion raphtory-cypher/src/transpiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use raphtory::{
Direction,
},
db::{api::properties::internal::ConstPropertiesOps, graph::node::NodeView},
disk_graph::graph_impl::DiskGraphStorage,
disk_graph::DiskGraphStorage,
prelude::*,
};
use sqlparser::ast::{
Expand Down Expand Up @@ -1147,6 +1147,7 @@ mod test {
use pretty_assertions::assert_eq;
use raphtory::{
db::{api::mutation::AdditionOps, graph::graph::Graph},
disk_graph::DiskGraphStorage,
prelude::NO_PROPS,
};
use tempfile::tempdir;
Expand Down
2 changes: 1 addition & 1 deletion raphtory-graphql/src/data.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use parking_lot::RwLock;
#[cfg(feature = "storage")]
use raphtory::disk_graph::graph_impl::DiskGraphStorage;
use raphtory::disk_graph::DiskGraphStorage;
use raphtory::{
core::Prop,
db::api::view::MaterializedGraph,
Expand Down
2 changes: 1 addition & 1 deletion raphtory-graphql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mod graphql_test {
use async_graphql::UploadValue;
use dynamic_graphql::{Request, Variables};
#[cfg(feature = "storage")]
use raphtory::disk_graph::graph_impl::DiskGraphStorage;
use raphtory::disk_graph::DiskGraphStorage;
use raphtory::{
db::{api::view::IntoDynamic, graph::views::deletion_graph::PersistentGraph},
prelude::*,
Expand Down
1 change: 0 additions & 1 deletion raphtory/src/db/api/storage/storage_ops/edge_filter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{
core::entities::LayerIds,
db::api::{storage::edges::edge_ref::EdgeStorageRef, view::internal::EdgeFilterOps},
disk_graph::DiskGraph,
};

use super::GraphStorage;
Expand Down
7 changes: 4 additions & 3 deletions raphtory/src/db/api/storage/storage_ops/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "storage")]
use crate::disk_graph::{graph_impl::DiskGraphStorage, storage_interface::edge::DiskOwnedEdge};
use crate::disk_graph::{storage_interface::edge::DiskOwnedEdge, DiskGraphStorage};
use crate::{
core::{
entities::{
Expand Down Expand Up @@ -32,6 +32,7 @@ use crate::{
prelude::{DeletionOps, GraphViewOps},
};
use itertools::Itertools;
use pometry_storage::GidRef;
#[cfg(feature = "storage")]
use pometry_storage::GID;
use raphtory_api::core::entities::ELID;
Expand Down Expand Up @@ -144,8 +145,8 @@ impl GraphStorage {
GraphStorage::Unlocked(unlocked) => unlocked.resolve_node_ref(node_ref),
#[cfg(feature = "storage")]
GraphStorage::Disk(storage) => match v {
NodeRef::External(id) => storage.inner.find_node(&GID::U64(id)),
NodeRef::ExternalStr(vid) => storage.inner.find_node(&GID::Str(vid.into())),
NodeRef::External(id) => storage.inner.find_node(GidRef::U64(id)),
NodeRef::ExternalStr(vid) => storage.inner.find_node(GidRef::Str(vid)),
_ => unreachable!("VID is handled above!"),
},
},
Expand Down
Loading

0 comments on commit 31a9336

Please sign in to comment.