diff --git a/Cargo.toml b/Cargo.toml index 19f9bfa1a5..4a79a862ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -130,7 +130,7 @@ arrow-data = { version = "50" } arrow-array = { version = "50" } raphtory-arrow = { version = "0.8.1", path = "./raphtory-arrow" } -# raphtory-arrow = { git = "ssh://git@github.com/Pometry/raphtory-arrow.git", branch = "master" } +#flip raphtory-arrow = { git = "ssh://git@github.com/Pometry/raphtory-arrow.git", branch = "master" } # Make sure that transitive dependencies stick to arrow 50 [patch.crates-io] diff --git a/raphtory-cypher/examples/raphtory_cypher.rs b/raphtory-cypher/examples/raphtory_cypher.rs index 3f39dd9e21..0af6f5d5be 100644 --- a/raphtory-cypher/examples/raphtory_cypher.rs +++ b/raphtory-cypher/examples/raphtory_cypher.rs @@ -4,6 +4,12 @@ pub use cyper_arrow::*; #[cfg(not(feature = "arrow"))] fn main() {} +#[cfg(feature = "arrow")] +#[tokio::main] +async fn main() { + cyper_arrow::main().await; +} + #[cfg(feature = "arrow")] mod cyper_arrow { use std::{error::Error, str::FromStr}; @@ -121,8 +127,8 @@ mod cyper_arrow { Load(LoadGraph), } - #[tokio::main] - async fn main() { + // #[tokio::main] + pub async fn main() { let args = Args::parse(); match args { diff --git a/raphtory-cypher/src/lib.rs b/raphtory-cypher/src/lib.rs index 08605296a4..d79e85c3f9 100644 --- a/raphtory-cypher/src/lib.rs +++ b/raphtory-cypher/src/lib.rs @@ -1,6 +1,15 @@ #[cfg(feature = "arrow")] pub use cypher_arrow::*; +#[cfg(feature = "arrow")] +pub mod executor; +#[cfg(feature = "arrow")] +pub mod hop; +#[cfg(feature = "arrow")] +pub mod parser; +#[cfg(feature = "arrow")] +pub mod transpiler; + #[cfg(feature = "arrow")] mod cypher_arrow { use arrow::compute::take; @@ -20,20 +29,16 @@ mod cypher_arrow { physical_plan::SendableRecordBatchStream, }; - use executor::{table_provider::edge::EdgeListTableProvider, ExecError}; - use parser::ast::*; + use super::executor::{table_provider::edge::EdgeListTableProvider, ExecError}; + use super::parser::ast::*; use raphtory::arrow::graph_impl::ArrowGraph; + use super::*; use crate::{ executor::table_provider::node::NodeTableProvider, hop::rule::{HopQueryPlanner, HopRule}, }; - pub mod executor; - pub mod hop; - pub mod parser; - pub mod transpiler; - pub use polars_arrow as arrow2; pub async fn run_cypher( @@ -52,7 +57,7 @@ mod cypher_arrow { enable_hop_optim: bool, ) -> Result<(SessionContext, LogicalPlan), ExecError> { // println!("Running query: {:?}", query); - let query = parser::parse_cypher(query)?; + let query = super::parser::parse_cypher(query)?; let config = SessionConfig::from_env()?.with_information_schema(true); @@ -292,7 +297,8 @@ mod cypher_arrow { let srcs = PrimitiveArray::from_vec(vec![1u64, 2u64, 2u64, 2u64]).boxed(); let dsts = PrimitiveArray::from_vec(vec![3u64, 3u64, 4u64, 4u64]).boxed(); let time = PrimitiveArray::from_vec(vec![2i64, 3i64, 4i64, 5i64]).boxed(); - let weight = PrimitiveArray::from_vec(vec![3.14f64, 4.14f64, 5.14f64, 6.14f64]).boxed(); + let weight = + PrimitiveArray::from_vec(vec![3.14f64, 4.14f64, 5.14f64, 6.14f64]).boxed(); let chunk = StructArray::new( ArrowDataType::Struct(schema().fields), @@ -305,7 +311,8 @@ mod cypher_arrow { let edge_lists = vec![chunk]; let graph = - ArrowGraph::load_from_edge_lists(&edge_lists, 20, 20, graph_dir, 0, 1, 2).unwrap(); + ArrowGraph::load_from_edge_lists(&edge_lists, 20, 20, graph_dir, 0, 1, 2) + .unwrap(); let df = run_cypher("match ()-[e]->() RETURN *", &graph, true) .await @@ -357,7 +364,7 @@ mod cypher_arrow { None, 1, ) - .unwrap(); + .unwrap(); let df = run_cypher("match ()-[e]->() RETURN *", &graph, true) .await @@ -410,8 +417,8 @@ mod cypher_arrow { &graph, true, ) - .await - .unwrap(); + .await + .unwrap(); let data = df.collect().await.unwrap(); print_batches(&data).expect("failed to print batches"); @@ -462,8 +469,8 @@ mod cypher_arrow { &graph, true, ) - .await - .unwrap(); + .await + .unwrap(); let data = df.collect().await.unwrap(); print_batches(&data).unwrap(); @@ -479,8 +486,8 @@ mod cypher_arrow { &graph, true, ) - .await - .unwrap(); + .await + .unwrap(); let data = df.collect().await.unwrap(); print_batches(&data).unwrap(); @@ -510,10 +517,10 @@ mod cypher_arrow { ("name", Prop::str(name.as_ref())), ("age", Prop::I64(*age)), ]) - .unwrap(); + .unwrap(); if let Some(city) = city { nv.add_constant_properties(vec![("city", Prop::str(city.as_ref()))]) - .unwrap(); + .unwrap(); } } } @@ -561,8 +568,8 @@ mod cypher_arrow { &graph, true, ) - .await - .unwrap(); + .await + .unwrap(); let data = df.collect().await.unwrap(); print_batches(&data).unwrap(); @@ -578,8 +585,8 @@ mod cypher_arrow { &graph, true, ) - .await - .unwrap(); + .await + .unwrap(); let data = df.collect().await.unwrap(); print_batches(&data).unwrap(); } @@ -618,8 +625,8 @@ mod cypher_arrow { &graph, true, ) - .await - .unwrap(); + .await + .unwrap(); let data = df.collect().await.unwrap(); print_batches(&data).unwrap(); } @@ -682,8 +689,8 @@ mod cypher_arrow { &graph, true, ) - .await - .unwrap(); + .await + .unwrap(); let data = df.collect().await.unwrap(); print_batches(&data).expect("failed to print batches"); @@ -747,11 +754,10 @@ mod cypher_arrow { &graph, true, ) - .await - .unwrap(); + .await + .unwrap(); let data = df.collect().await.unwrap(); print_batches(&data).unwrap(); } } - } diff --git a/raphtory-cypher/src/transpiler/exprs.rs b/raphtory-cypher/src/transpiler/exprs.rs index f42f57df3e..6d47c8b14e 100644 --- a/raphtory-cypher/src/transpiler/exprs.rs +++ b/raphtory-cypher/src/transpiler/exprs.rs @@ -1,6 +1,6 @@ use sqlparser::ast::{self as sql_ast}; -use crate::{Clause, Query, Return}; +use crate::parser::ast::{Clause, Query, Return}; pub fn parse_limit(query: &Query) -> Option { query.clauses().iter().find_map(|clause| match clause { diff --git a/scripts/add_arrow_dep.sh b/scripts/add_arrow_dep.sh deleted file mode 100755 index 48c5aefb32..0000000000 --- a/scripts/add_arrow_dep.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -set -e -set -x - -# Detect the operating system -if [[ "$OSTYPE" == "darwin"* ]]; then - # macOS - find . -name "Cargo.toml" -type f -exec sed -i '' '/#.*raphtory-arrow/ s/^# //' {} + -else - # Linux and other UNIX-like systems - find . -name "Cargo.toml" -type f -exec sed -i '/#.*raphtory-arrow/ s/^# //' {} + -fi diff --git a/scripts/flip_ra.py b/scripts/flip_ra.py new file mode 100755 index 0000000000..6fa2ebb4cb --- /dev/null +++ b/scripts/flip_ra.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +import sys + +if len(sys.argv) != 2: + print("Usage: flip_ra.py ") + sys.exit(1) + +file = sys.argv[1] + +with open(file, 'r') as f: + for line in f: + if line.startswith("#flip raphtory-arrow"): + line = line.replace("#flip raphtory-arrow", "raphtory-arrow", 1) + elif line.startswith("raphtory-arrow"): + line = line.replace("raphtory-arrow", "#flip raphtory-arrow", 1) + print(line, end='') diff --git a/scripts/hide_arrow_dep.sh b/scripts/hide_arrow_dep.sh index 343c55611d..66449ded28 100755 --- a/scripts/hide_arrow_dep.sh +++ b/scripts/hide_arrow_dep.sh @@ -3,11 +3,7 @@ set -e set -x # Hide arrow dependency in all Cargo.toml files -# Detect the operating system -if [[ "$OSTYPE" == "darwin"* ]]; then - # macOS - find . -name "Cargo.toml" -type f -exec sed -i '' '/raphtory-arrow/ s/^/# /' {} + -else - # Linux and other UNIX-like systems - find . -name "Cargo.toml" -type f -exec sed -i '/raphtory-arrow/ s/^/# /' {} + -fi +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +$SCRIPT_DIR/flip_ra.py Cargo.toml > Cargo.toml.bk +mv Cargo.toml.bk Cargo.toml