From 85f3869ae8d61237a4c048b5635642679afff905 Mon Sep 17 00:00:00 2001 From: Fabian Murariu Date: Fri, 24 May 2024 17:12:59 +0100 Subject: [PATCH 1/8] move minimal structs into raphtory-api --- Cargo.lock | 57 +++ Cargo.toml | 2 +- raphtory-api/Cargo.toml | 18 + .../src/core/entities/edges/edge_ref.rs | 0 raphtory-api/src/core/entities/edges/mod.rs | 1 + raphtory-api/src/core/entities/mod.rs | 87 ++++ raphtory-api/src/core/mod.rs | 22 + raphtory-api/src/core/storage/mod.rs | 1 + raphtory-api/src/core/storage/timeindex.rs | 78 +++ raphtory-api/src/lib.rs | 1 + raphtory-arrow/Cargo.toml | 42 ++ raphtory-arrow/src/lib.rs | 471 ++++++++++++++++++ .../src/executor/table_provider/node.rs | 7 +- raphtory/Cargo.toml | 3 +- raphtory/src/arrow/graph_impl/interop.rs | 27 +- .../src/arrow/graph_impl/prop_conversion.rs | 4 +- raphtory/src/arrow/mod.rs | 11 +- raphtory/src/arrow/storage_interface/node.rs | 4 +- raphtory/src/arrow/storage_interface/nodes.rs | 2 +- .../src/arrow/storage_interface/nodes_ref.rs | 2 +- .../src/core/entities/edges/edge_store.rs | 15 +- raphtory/src/core/entities/edges/mod.rs | 3 +- raphtory/src/core/entities/mod.rs | 139 +----- raphtory/src/core/mod.rs | 33 +- raphtory/src/core/storage/timeindex.rs | 87 +--- raphtory/src/db/api/mutation/addition_ops.rs | 7 +- raphtory/src/db/api/mutation/deletion_ops.rs | 5 +- raphtory/src/db/api/mutation/import_ops.rs | 9 +- raphtory/src/db/api/mutation/mod.rs | 14 + .../db/api/mutation/property_addition_ops.rs | 4 +- raphtory/src/db/api/storage/storage_ops.rs | 4 +- raphtory/src/db/graph/edge.rs | 6 +- raphtory/src/db/graph/node.rs | 4 +- 33 files changed, 861 insertions(+), 309 deletions(-) create mode 100644 raphtory-api/Cargo.toml rename {raphtory => raphtory-api}/src/core/entities/edges/edge_ref.rs (100%) create mode 100644 raphtory-api/src/core/entities/edges/mod.rs create mode 100644 raphtory-api/src/core/entities/mod.rs create mode 100644 raphtory-api/src/core/mod.rs create mode 100644 raphtory-api/src/core/storage/mod.rs create mode 100644 raphtory-api/src/core/storage/timeindex.rs create mode 100644 raphtory-api/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index bd9dc4cfbb..b8704669aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3988,6 +3988,7 @@ dependencies = [ "quickcheck_macros", "rand 0.8.5", "rand_distr", + "raphtory-api", "raphtory-arrow", "rayon", "regex", @@ -4008,9 +4009,42 @@ dependencies = [ "zip", ] +[[package]] +name = "raphtory-api" +version = "0.8.1" +dependencies = [ + "chrono", + "serde", +] + [[package]] name = "raphtory-arrow" version = "0.8.1" +dependencies = [ + "ahash", + "bincode", + "bytemuck", + "itertools 0.12.1", + "memmap2", + "num-traits", + "once_cell", + "parking_lot", + "polars-arrow", + "polars-parquet", + "polars-utils", + "proptest", + "raphtory-api", + "rayon", + "serde", + "serde_json", + "strum 0.26.2", + "tempfile", + "thiserror", + "tracing", + "tracing-subscriber", + "tracing-test", + "twox-hash", +] [[package]] name = "raphtory-benchmark" @@ -5483,6 +5517,29 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "tracing-test" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a2c0ff408fe918a94c428a3f2ad04e4afd5c95bbc08fcf868eff750c15728a4" +dependencies = [ + "lazy_static", + "tracing-core", + "tracing-subscriber", + "tracing-test-macro", +] + +[[package]] +name = "tracing-test-macro" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "258bc1c4f8e2e73a977812ab339d503e6feeb92700f6d07a6de4d321522d5c08" +dependencies = [ + "lazy_static", + "quote", + "syn 1.0.109", +] + [[package]] name = "triomphe" version = "0.1.11" diff --git a/Cargo.toml b/Cargo.toml index b0c51900e5..dd3ba83662 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ members = [ "examples/netflow", "python", "js-raphtory", - "raphtory-graphql", + "raphtory-graphql", "raphtory-api", ] default-members = ["raphtory"] resolver = "2" diff --git a/raphtory-api/Cargo.toml b/raphtory-api/Cargo.toml new file mode 100644 index 0000000000..799cec954f --- /dev/null +++ b/raphtory-api/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "raphtory-api" +version.workspace = true +documentation.workspace = true +repository.workspace = true +license.workspace = true +readme.workspace = true +homepage.workspace = true +keywords.workspace = true +authors.workspace = true +rust-version.workspace = true +edition.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +serde = { workspace = true, features = ["derive"] } +chrono.workspace = true \ No newline at end of file diff --git a/raphtory/src/core/entities/edges/edge_ref.rs b/raphtory-api/src/core/entities/edges/edge_ref.rs similarity index 100% rename from raphtory/src/core/entities/edges/edge_ref.rs rename to raphtory-api/src/core/entities/edges/edge_ref.rs diff --git a/raphtory-api/src/core/entities/edges/mod.rs b/raphtory-api/src/core/entities/edges/mod.rs new file mode 100644 index 0000000000..e51063bf4d --- /dev/null +++ b/raphtory-api/src/core/entities/edges/mod.rs @@ -0,0 +1 @@ +pub mod edge_ref; diff --git a/raphtory-api/src/core/entities/mod.rs b/raphtory-api/src/core/entities/mod.rs new file mode 100644 index 0000000000..02cf442c00 --- /dev/null +++ b/raphtory-api/src/core/entities/mod.rs @@ -0,0 +1,87 @@ +use serde::{Deserialize, Serialize}; + +use self::edges::edge_ref::EdgeRef; + +pub mod edges; + +// the only reason this is public is because the physical ids of the nodes don't move +#[repr(transparent)] +#[derive( + Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize, Default, +)] +pub struct VID(pub usize); + +impl VID { + pub fn index(&self) -> usize { + self.0 + } + + pub fn as_u64(&self) -> u64 { + self.0 as u64 + } +} + +impl From for VID { + fn from(id: usize) -> Self { + VID(id) + } +} + +impl From for usize { + fn from(id: VID) -> Self { + id.0 + } +} + +#[repr(transparent)] +#[derive( + Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize, Default, +)] +pub struct EID(pub usize); + +impl From for usize { + fn from(id: EID) -> Self { + id.0 + } +} + +impl From for EID { + fn from(id: usize) -> Self { + EID(id) + } +} + +#[derive( + Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize, Default, +)] +pub struct ELID { + edge: EID, + layer: Option, +} + +impl ELID { + pub fn new(edge: EID, layer: Option) -> Self { + Self { edge, layer } + } + pub fn pid(&self) -> EID { + self.edge + } + + pub fn layer(&self) -> Option { + self.layer + } +} + +impl From for ELID { + fn from(value: EdgeRef) -> Self { + ELID { + edge: value.pid(), + layer: value.layer().copied(), + } + } +} +impl EID { + pub fn from_u64(id: u64) -> Self { + EID(id as usize) + } +} diff --git a/raphtory-api/src/core/mod.rs b/raphtory-api/src/core/mod.rs new file mode 100644 index 0000000000..c8a39e619a --- /dev/null +++ b/raphtory-api/src/core/mod.rs @@ -0,0 +1,22 @@ +pub mod entities; +pub mod storage; + +/// Denotes the direction of an edge. Can be incoming, outgoing or both. +#[derive( + Clone, + Copy, + Hash, + Eq, + PartialEq, + PartialOrd, + Debug, + Default, + serde::Serialize, + serde::Deserialize, +)] +pub enum Direction { + OUT, + IN, + #[default] + BOTH, +} diff --git a/raphtory-api/src/core/storage/mod.rs b/raphtory-api/src/core/storage/mod.rs new file mode 100644 index 0000000000..5309fd0959 --- /dev/null +++ b/raphtory-api/src/core/storage/mod.rs @@ -0,0 +1 @@ +pub mod timeindex; diff --git a/raphtory-api/src/core/storage/timeindex.rs b/raphtory-api/src/core/storage/timeindex.rs new file mode 100644 index 0000000000..e83bc96fed --- /dev/null +++ b/raphtory-api/src/core/storage/timeindex.rs @@ -0,0 +1,78 @@ +use std::{fmt, ops::Range}; + +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Ord, PartialOrd, Eq)] +pub struct TimeIndexEntry(pub i64, pub usize); + +pub trait AsTime: fmt::Debug + Copy + Ord + Eq + Send + Sync + 'static { + fn t(&self) -> i64; + + fn dt(&self) -> Option> { + let t = self.t(); + DateTime::from_timestamp_millis(t) + } + + fn range(w: Range) -> Range; + + fn i(&self) -> usize { + 0 + } + + fn new(t: i64, s: usize) -> Self; +} + +impl From for TimeIndexEntry { + fn from(value: i64) -> Self { + Self::start(value) + } +} + +impl TimeIndexEntry { + pub const MIN: TimeIndexEntry = TimeIndexEntry(i64::MIN, 0); + + pub const MAX: TimeIndexEntry = TimeIndexEntry(i64::MAX, usize::MAX); + pub fn new(t: i64, s: usize) -> Self { + Self(t, s) + } + + pub fn start(t: i64) -> Self { + Self(t, 0) + } + + pub fn end(t: i64) -> Self { + Self(t.saturating_add(1), 0) + } +} + +impl AsTime for i64 { + fn t(&self) -> i64 { + *self + } + + fn range(w: Range) -> Range { + w + } + + fn new(t: i64, _s: usize) -> Self { + t + } +} + +impl AsTime for TimeIndexEntry { + fn t(&self) -> i64 { + self.0 + } + fn range(w: Range) -> Range { + Self::start(w.start)..Self::start(w.end) + } + + fn i(&self) -> usize { + self.1 + } + + fn new(t: i64, s: usize) -> Self { + Self(t, s) + } +} diff --git a/raphtory-api/src/lib.rs b/raphtory-api/src/lib.rs new file mode 100644 index 0000000000..5a7ca06a4f --- /dev/null +++ b/raphtory-api/src/lib.rs @@ -0,0 +1 @@ +pub mod core; diff --git a/raphtory-arrow/Cargo.toml b/raphtory-arrow/Cargo.toml index 6eec84f04a..36635f234f 100644 --- a/raphtory-arrow/Cargo.toml +++ b/raphtory-arrow/Cargo.toml @@ -1,4 +1,46 @@ [package] name = "raphtory-arrow" version = "0.8.1" +documentation = "https://raphtory.readthedocs.io/en/latest/" +repository = "https://github.com/Raphtory/raphtory-arrow/" +license = "GPL-3.0" +readme = "README.md" +homepage = "https://github.com/Raphtory/raphtory-arrow/" +keywords = ["graph", "temporal-graph", "temporal"] +authors = ["Pometry"] +rust-version = "1.77" +edition = "2021" + +[profile.release-with-debug] +inherits = "release" +debug = true + + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + [dependencies] +raphtory-api = { path = "../raphtory-api", version = "0.8.1" } +ahash = { version = "0.8", features = ["serde"] } +bincode = "1.3.3" +bytemuck = "1.16.0" +itertools = "0.12.1" +memmap2 = "0.9.4" +num-traits = "0.2.19" +once_cell = "1.19.0" +parking_lot = "0.12.2" +polars-arrow = "0.39.2" +polars-parquet = { version = "0.39.2", features = ["compression"] } +polars-utils = "0.39.2" +rayon = "1.10.0" +serde = "1.0.201" +serde_json = "1.0.117" +strum = { version = "0.26.2", features = ["derive"] } +tempfile = "3.10.1" +thiserror = "1.0.60" +tracing = "0.1.40" +tracing-subscriber = "0.3.18" +twox-hash = "1.6.3" + +[dev-dependencies] +proptest = "1.4.0" +tracing-test = "0.2.4" diff --git a/raphtory-arrow/src/lib.rs b/raphtory-arrow/src/lib.rs index 8b13789179..415877292b 100644 --- a/raphtory-arrow/src/lib.rs +++ b/raphtory-arrow/src/lib.rs @@ -1 +1,472 @@ +use std::{ + borrow::Cow, + num::TryFromIntError, + ops::Range, + path::{Path, PathBuf}, +}; +use crate::arrow2::{ + array::{Array, StructArray}, + compute::concatenate::concatenate, + datatypes::{ArrowDataType as DataType, ArrowSchema as Schema, Field}, +}; +use itertools::Itertools; +use num_traits::ToPrimitive; +use polars_arrow::record_batch::RecordBatch; +use serde::{Deserialize, Serialize}; + +use crate::{ + arrow2::legacy::error, + load::parquet_reader::{NumRows, TrySlice}, +}; + +pub mod algorithms; +pub mod arrow_hmap; +pub mod chunked_array; +pub mod edge; +pub mod edges; +pub mod global_order; +pub mod graph; +pub mod graph_builder; +pub mod graph_fragment; +pub mod interop; +pub mod load; +pub mod nodes; +pub mod properties; +pub mod timestamps; +pub mod tprops; + +mod compute; + +pub type Time = i64; + +pub mod prelude { + pub use super::chunked_array::array_ops::*; +} + +#[derive(thiserror::Error, Debug)] +pub enum RAError { + #[error("Failed to memory map file {file:?}, source: {source}")] + MMap { + file: PathBuf, + source: error::PolarsError, + }, + #[error("Arrow error: {0}")] + Arrow(#[from] error::PolarsError), + #[error("IO error: {0}")] + IO(#[from] std::io::Error), + //serde error + #[error("Serde error: {0}")] + Serde(#[from] serde_json::Error), + #[error("Bad data type for node column: {0:?}")] + DType(DataType), + #[error("Graph directory is not empty before loading")] + GraphDirNotEmpty, + #[error("Invalid type for column: {0}")] + InvalidTypeColumn(String), + #[error("Column not found: {0}")] + ColumnNotFound(String), + #[error("No Edge lists found in input path")] + NoEdgeLists, + #[error("Unable to open graph: {0:?}")] + EmptyGraphDir(PathBuf), + #[error("Empty parquet chunk")] + EmptyChunk, + #[error("Conversion error: {0}")] + ArgumentError(#[from] TryFromIntError), + #[error("Invalid file: {0:?}")] + InvalidFile(PathBuf), + #[error("Invalid metadata: {0:?}")] + MetadataError(#[from] Box), + #[error("Failed to cast mmap_mut to [i64]: {0:?}")] + SliceCastError(bytemuck::PodCastError), + #[error("Failed to cast array")] + TypeCastError, + #[error("Missing chunk {0}")] + MissingChunk(usize), +} + +const TIME_COLUMN: &str = "rap_time"; +const TIME_COLUMN_IDX: usize = 0; + +pub(crate) const V_COLUMN: &str = "v"; +pub(crate) const E_COLUMN: &str = "e"; + +#[inline] +pub fn adj_schema() -> DataType { + DataType::Struct(vec![ + Field::new(V_COLUMN, DataType::UInt64, false), + Field::new(E_COLUMN, DataType::UInt64, false), + ]) +} + +pub(crate) mod file_prefix { + use std::{ + path::{Path, PathBuf}, + str::FromStr, + }; + + use itertools::Itertools; + use strum::{AsRefStr, EnumString}; + + use super::RAError; + + #[derive(AsRefStr, EnumString, PartialEq, Debug, Ord, PartialOrd, Eq, Copy, Clone)] + pub enum GraphPaths { + NodeAdditions, + NodeAdditionsOffsets, + NodeTProps, + NodeTPropsTimestamps, + NodeTPropsSecondaryIndex, + NodeTPropsOffsets, + NodeConstProps, + AdjOutSrcs, + AdjOutDsts, + AdjOutOffsets, + EdgeTPropsOffsets, + EdgeTProps, + AdjInSrcs, + AdjInEdges, + AdjInOffsets, + Metadata, + HashMap, + } + + #[derive(Debug, PartialEq, Ord, PartialOrd, Eq, Copy, Clone)] + pub struct GraphFile { + pub prefix: GraphPaths, + pub chunk: usize, + } + + impl GraphFile { + pub fn try_from_path(path: impl AsRef) -> Option { + let name = path.as_ref().file_stem()?.to_str()?; + let mut name_parts = name.split('-'); + let prefix = GraphPaths::from_str(name_parts.next()?).ok()?; + let chunk_str = name_parts.next(); + let chunk: usize = chunk_str?.parse().ok()?; + Some(Self { prefix, chunk }) + } + } + + impl GraphPaths { + pub fn try_from(path: impl AsRef) -> Option { + let path = path.as_ref(); + let name = path.file_name().and_then(|name| name.to_str())?; + let prefix = name.split('-').next()?; + GraphPaths::from_str(prefix).ok() + } + + pub fn to_path(&self, location_path: impl AsRef, id: usize) -> PathBuf { + let prefix: &str = self.as_ref(); + make_path(location_path, prefix, id) + } + } + + pub fn make_path(location_path: impl AsRef, prefix: &str, id: usize) -> PathBuf { + let file_path = location_path + .as_ref() + .join(format!("{}-{:08}.ipc", prefix, id)); + file_path + } + + pub fn sorted_file_list( + dir: impl AsRef, + prefix: GraphPaths, + ) -> Result, RAError> { + let mut files = dir + .as_ref() + .read_dir()? + .filter_map_ok(|f| { + let path = f.path(); + GraphFile::try_from_path(&path) + .filter(|f| f.prefix == prefix) + .map(|f| (f.chunk, path)) + }) + .collect::, _>>()?; + files.sort(); + for (i, (chunk, _)) in files.iter().enumerate() { + if &i != chunk { + return Err(RAError::MissingChunk(i)); + } + } + Ok(files.into_iter().map(|(_, path)| path)) + } +} + +#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)] +pub enum GID { + U64(u64), + I64(i64), + Str(String), +} + +impl GID { + pub fn into_str(self) -> Option { + match self { + GID::Str(v) => Some(v), + _ => None, + } + } + + pub fn into_i64(self) -> Option { + match self { + GID::I64(v) => Some(v), + _ => None, + } + } + + pub fn into_u64(self) -> Option { + match self { + GID::U64(v) => Some(v), + _ => None, + } + } + + pub fn as_str(&self) -> Option<&str> { + match self { + GID::Str(v) => Some(v.as_str()), + _ => None, + } + } + + pub fn as_i64(&self) -> Option { + match self { + GID::I64(v) => Some(*v), + _ => None, + } + } + + pub fn as_u64(&self) -> Option { + match self { + GID::U64(v) => Some(*v), + _ => None, + } + } + + pub fn to_str(&self) -> Cow { + match self { + GID::U64(v) => Cow::Owned(v.to_string()), + GID::I64(v) => Cow::Owned(v.to_string()), + GID::Str(v) => Cow::Borrowed(v), + } + } + + pub fn to_i64(&self) -> Option { + match self { + GID::U64(v) => v.to_i64(), + GID::I64(v) => Some(*v), + GID::Str(v) => parse_u64_strict(v)?.to_i64(), + } + } + + pub fn to_u64(&self) -> Option { + match self { + GID::U64(v) => Some(*v), + GID::I64(v) => v.to_u64(), + GID::Str(v) => parse_u64_strict(v), + } + } +} + +const MAX_U64_BYTES: [u8; 20] = [ + 49, 56, 52, 52, 54, 55, 52, 52, 48, 55, 51, 55, 48, 57, 53, 53, 49, 54, 49, 53, +]; + +pub fn parse_u64_strict(input: &str) -> Option { + if input.len() > 20 { + // a u64 string has at most 20 bytes + return None; + } + let byte_0 = b'0'; + let byte_1 = b'1'; + let byte_9 = b'9'; + let mut input_iter = input.bytes(); + let first = input_iter.next()?; + if first == byte_0 { + return input_iter.next().is_none().then_some(0); + } + if input.len() == 20 && (byte_1..=MAX_U64_BYTES[0]).contains(&first) { + let mut result = (first - byte_0) as u64; + for (next_byte, max_byte) in input_iter.zip(MAX_U64_BYTES[1..].iter().copied()) { + if !(byte_0..=max_byte).contains(&next_byte) { + return None; + } + result = result * 10 + (next_byte - byte_0) as u64; + } + return Some(result); + } + if (byte_1..=byte_9).contains(&first) { + let mut result = (first - byte_0) as u64; + for next_byte in input_iter { + if !(byte_0..=byte_9).contains(&next_byte) { + return None; + } + result = result * 10 + (next_byte - byte_0) as u64; + } + return Some(result); + } + + None +} + +impl From for GID { + fn from(id: u64) -> Self { + Self::U64(id) + } +} + +impl From for GID { + fn from(id: i64) -> Self { + Self::I64(id) + } +} + +impl From for GID { + fn from(id: String) -> Self { + Self::Str(id) + } +} + +impl From<&str> for GID { + fn from(id: &str) -> Self { + Self::Str(id.to_string()) + } +} + +#[derive(Debug, Clone)] +pub(crate) struct GraphChunk { + srcs: Box, + dsts: Box, +} + +impl GraphChunk { + pub fn to_chunk(&self) -> RecordBatch> { + RecordBatch::new(vec![self.srcs.clone(), self.dsts.clone()]) + } +} + +#[derive(Debug, Clone)] +pub(crate) struct PropsChunk(pub StructArray); + +impl NumRows for &PropsChunk { + fn num_rows(&self) -> usize { + self.0.len() + } +} + +impl TrySlice for &PropsChunk { + fn try_slice(&self, range: Range) -> Result { + self.0.try_slice(range) + } +} + +pub fn concat(arrays: Vec) -> Result { + let mut refs: Vec<&dyn Array> = Vec::with_capacity(arrays.len()); + for array in arrays.iter() { + refs.push(array); + } + Ok(concatenate(&refs)? + .as_any() + .downcast_ref::() + .unwrap() + .clone()) +} + +pub(crate) fn split_struct_chunk( + chunk: StructArray, + src_col_idx: usize, + dst_col_idx: usize, + time_col_idx: usize, +) -> (GraphChunk, PropsChunk) { + let (fields, cols, _) = chunk.into_data(); + split_chunk( + cols.to_vec(), + src_col_idx, + dst_col_idx, + time_col_idx, + fields.into(), + ) +} + +pub(crate) fn split_chunk>>( + columns_in_chunk: I, + src_col_idx: usize, + dst_col_idx: usize, + time_col_idx: usize, + chunk_schema: Schema, +) -> (GraphChunk, PropsChunk) { + let all_cols = columns_in_chunk.into_iter().collect_vec(); + + let time_d_type = all_cols[time_col_idx].data_type().clone(); + assert_eq!(time_d_type, DataType::Int64, "time column must be i64"); + let first_len = all_cols.first().unwrap().len(); + if all_cols.iter().any(|arr| arr.len() != first_len) { + panic!("All arrays in a chunk must have the same length"); + } + + let mut temporal_props = vec![all_cols[time_col_idx].clone()]; + for (i, column) in all_cols.iter().enumerate() { + if !(i == src_col_idx || i == dst_col_idx || i == time_col_idx) { + temporal_props.push(column.clone()); + } + } + + let mut props_only_schema = + chunk_schema.filter(|i, _| !(i == src_col_idx || i == dst_col_idx || i == time_col_idx)); + // put time as the first column in the struct + props_only_schema + .fields + .insert(0, Field::new(TIME_COLUMN, time_d_type, false)); + let data_type = DataType::Struct(props_only_schema.fields); + let t_prop_cols = StructArray::new(data_type, temporal_props, None); + + ( + GraphChunk { + srcs: all_cols[src_col_idx].clone(), + dsts: all_cols[dst_col_idx].clone(), + // time: all_cols[time_col_idx].clone(), + }, + PropsChunk(t_prop_cols), + ) +} + +fn prepare_graph_dir>(graph_dir: P) -> Result<(), RAError> { + // create graph dir if it does not exist + // if it exists make sure it's empty + std::fs::create_dir_all(&graph_dir)?; + + let mut dir_iter = std::fs::read_dir(&graph_dir)?; + if dir_iter.next().is_some() { + return Err(RAError::GraphDirNotEmpty); + } + + Ok(()) +} +pub mod utils { + + use std::hash::{Hash, Hasher}; + use twox_hash::XxHash64; + + use crate::GID; + + pub fn calculate_hash(t: &T) -> u64 { + let mut s = XxHash64::default(); + t.hash(&mut s); + s.finish() + } + + pub fn calculate_hash_spark(gid: &GID) -> i64 { + let mut s = XxHash64::with_seed(42); + match gid { + GID::U64(x) => s.write_u64(*x), + GID::I64(x) => s.write_i64(*x), + GID::Str(t) => { + t.chars().for_each(|c| s.write_u8(c as u8)); + } + } + s.finish() as i64 + } +} + +pub use polars_arrow as arrow2; diff --git a/raphtory-cypher/src/executor/table_provider/node.rs b/raphtory-cypher/src/executor/table_provider/node.rs index d7520bd521..e0d9deefb4 100644 --- a/raphtory-cypher/src/executor/table_provider/node.rs +++ b/raphtory-cypher/src/executor/table_provider/node.rs @@ -21,7 +21,10 @@ use datafusion::{ use futures::Stream; use raphtory_arrow::properties::Properties; -use raphtory::arrow::{graph_impl::ArrowGraph, prelude::*}; +use raphtory::{ + arrow::{graph_impl::ArrowGraph, prelude::*}, + core::entities::VID, +}; use crate::{ arrow2::{self, array::to_data, datatypes::ArrowDataType}, @@ -64,7 +67,7 @@ impl NodeTableProvider { pub fn lift_arrow_schema( gid_dt: ArrowDataType, - properties: Option<&Properties>, + properties: Option<&Properties>, ) -> Result { let mut fields = vec![]; diff --git a/raphtory/Cargo.toml b/raphtory/Cargo.toml index aacd181300..cf61f0fe7b 100644 --- a/raphtory/Cargo.toml +++ b/raphtory/Cargo.toml @@ -15,6 +15,7 @@ homepage.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +raphtory-api = { path = "../raphtory-api", version="0.8.1" } bincode = { workspace = true } chrono = { workspace = true } itertools = { workspace = true } @@ -88,7 +89,7 @@ streaming-stats = { workspace = true } proptest = { workspace = true } [features] -default = [] +default = ["arrow"] # Enables the graph loader io module io = [ "dep:zip", diff --git a/raphtory/src/arrow/graph_impl/interop.rs b/raphtory/src/arrow/graph_impl/interop.rs index db0787753f..9dd184815a 100644 --- a/raphtory/src/arrow/graph_impl/interop.rs +++ b/raphtory/src/arrow/graph_impl/interop.rs @@ -16,7 +16,8 @@ use crate::{ }; use itertools::Itertools; use polars_arrow::array::Array; -use raphtory_arrow::interop::{AsEID, AsVID, GraphLike, EID, VID}; +use raphtory_api::core::entities::{EID, VID}; +use raphtory_arrow::interop::GraphLike; impl GraphLike for Graph { fn external_ids(&self) -> Vec { @@ -44,24 +45,24 @@ impl GraphLike for Graph { self.count_edges() } - fn out_degree(&self, vid: impl AsVID, layer: usize) -> usize { - self.core_node_entry(vid.as_vid().0.into()) + fn out_degree(&self, vid: VID, layer: usize) -> usize { + self.core_node_entry(vid.0.into()) .degree(&LayerIds::One(layer), Direction::OUT) } - fn in_degree(&self, vid: impl AsVID, layer: usize) -> usize { - self.core_node_entry(vid.as_vid().0.into()) + fn in_degree(&self, vid: VID, layer: usize) -> usize { + self.core_node_entry(vid.0.into()) .degree(&LayerIds::One(layer), Direction::IN) } - fn in_edges(&self, vid: impl AsVID, layer: usize, map: impl Fn(VID, EID) -> B) -> Vec { - let node = self.core_node_entry(vid.as_vid().0.into()); + fn in_edges(&self, vid: VID, layer: usize, map: impl Fn(VID, EID) -> B) -> Vec { + let node = self.core_node_entry(vid.0.into()); node.edges_iter(&LayerIds::One(layer), Direction::IN) .map(|edge| map(edge.src().into(), edge.pid().into())) .collect() } - fn out_edges(&self, vid: impl AsVID, layer: usize) -> Vec<(VID, VID, EID)> { - let node = self.core_node_entry(vid.as_vid().0.into()); + fn out_edges(&self, vid: VID, layer: usize) -> Vec<(VID, VID, EID)> { + let node = self.core_node_entry(vid.0.into()); let edges = node .edges_iter(&LayerIds::One(layer), Direction::OUT) .map(|edge| { @@ -74,8 +75,8 @@ impl GraphLike for Graph { edges } - fn edge_additions(&self, eid: impl AsEID, layer: usize) -> Vec { - let el_id = ELID::new(eid.as_eid().0.into(), Some(layer)); + fn edge_additions(&self, eid: EID, layer: usize) -> Vec { + let el_id = ELID::new(eid.0.into(), Some(layer)); let edge = self.core_edge(el_id); let timestamps: Vec<_> = edge.additions(layer).iter().collect(); timestamps @@ -86,8 +87,8 @@ impl GraphLike for Graph { props.into_iter().map(|s| s.to_string()).collect() } - fn find_name(&self, vid: impl AsVID) -> Option { - self.core_node_entry(vid.as_vid().0.into()) + fn find_name(&self, vid: VID) -> Option { + self.core_node_entry(vid.0.into()) .name() .map(|s| s.to_string()) } diff --git a/raphtory/src/arrow/graph_impl/prop_conversion.rs b/raphtory/src/arrow/graph_impl/prop_conversion.rs index 648e559e24..376062933a 100644 --- a/raphtory/src/arrow/graph_impl/prop_conversion.rs +++ b/raphtory/src/arrow/graph_impl/prop_conversion.rs @@ -20,7 +20,7 @@ use std::path::Path; pub fn make_node_properties_from_graph( graph: &Graph, graph_dir: impl AsRef, -) -> Result>, RAError> { +) -> Result>, RAError> { let graph_dir = graph_dir.as_ref(); let n = graph.unfiltered_num_nodes(); @@ -65,7 +65,7 @@ pub fn make_node_properties_from_graph( let prop_type = temporal_meta.get_dtype(prop_id).unwrap(); let col = arrow_array_from_props( (0..n).flat_map(|vid| { - let ts = node_ts(raphtory_arrow::interop::VID(vid), offsets, ts); + let ts = node_ts(VID(vid), offsets, ts); let node = nodes.get(VID(vid)); ts.iter() .map(move |t| node.temporal_property(prop_id).and_then(|prop| prop.at(t))) diff --git a/raphtory/src/arrow/mod.rs b/raphtory/src/arrow/mod.rs index 0f94c46246..be37356346 100644 --- a/raphtory/src/arrow/mod.rs +++ b/raphtory/src/arrow/mod.rs @@ -29,12 +29,11 @@ mod test { datatypes::Field, }; use proptest::{prelude::*, sample::size_range}; - use raphtory_arrow::{ - global_order::GlobalMap, - graph_fragment::TempColGraphFragment, - interop::{Direction, EID, VID}, - RAError, + use raphtory_api::core::{ + entities::{EID, VID}, + Direction, }; + use raphtory_arrow::{global_order::GlobalMap, graph_fragment::TempColGraphFragment, RAError}; use tempfile::TempDir; fn edges_sanity_node_list(edges: &[(u64, u64, i64)]) -> Vec { @@ -367,7 +366,7 @@ mod test { mod addition_bounds { use itertools::Itertools; use proptest::{prelude::*, sample::size_range}; - use raphtory_arrow::interop::VID; + use raphtory_api::core::entities::VID; use tempfile::TempDir; use super::{ diff --git a/raphtory/src/arrow/storage_interface/node.rs b/raphtory/src/arrow/storage_interface/node.rs index 0e87effb4c..b41c01ea69 100644 --- a/raphtory/src/arrow/storage_interface/node.rs +++ b/raphtory/src/arrow/storage_interface/node.rs @@ -22,7 +22,7 @@ use std::{iter, sync::Arc}; #[derive(Copy, Clone, Debug)] pub struct ArrowNode<'a> { - pub(super) properties: Option<&'a Properties>, + pub(super) properties: Option<&'a Properties>, pub(super) layers: &'a Arc<[TempColGraphFragment]>, pub(super) vid: VID, } @@ -292,7 +292,7 @@ impl<'a> NodeStorageOps<'a> for ArrowNode<'a> { #[derive(Clone, Debug)] pub struct ArrowOwnedNode { - properties: Option>, + properties: Option>, layers: Arc<[TempColGraphFragment]>, vid: VID, } diff --git a/raphtory/src/arrow/storage_interface/nodes.rs b/raphtory/src/arrow/storage_interface/nodes.rs index 111f96b145..bb894416a9 100644 --- a/raphtory/src/arrow/storage_interface/nodes.rs +++ b/raphtory/src/arrow/storage_interface/nodes.rs @@ -11,7 +11,7 @@ use std::sync::Arc; #[derive(Clone, Debug)] pub struct ArrowNodesOwned { num_nodes: usize, - properties: Option>, + properties: Option>, layers: Arc<[TempColGraphFragment]>, } diff --git a/raphtory/src/arrow/storage_interface/nodes_ref.rs b/raphtory/src/arrow/storage_interface/nodes_ref.rs index bb1c7dce86..6a21f6e7b9 100644 --- a/raphtory/src/arrow/storage_interface/nodes_ref.rs +++ b/raphtory/src/arrow/storage_interface/nodes_ref.rs @@ -8,7 +8,7 @@ use std::sync::Arc; #[derive(Copy, Clone, Debug)] pub struct ArrowNodesRef<'a> { pub(super) num_nodes: usize, - pub(super) properties: Option<&'a Properties>, + pub(super) properties: Option<&'a Properties>, pub(super) layers: &'a Arc<[TempColGraphFragment]>, } diff --git a/raphtory/src/core/entities/edges/edge_store.rs b/raphtory/src/core/entities/edges/edge_store.rs index 98c51d8a3a..a00988a275 100644 --- a/raphtory/src/core/entities/edges/edge_store.rs +++ b/raphtory/src/core/entities/edges/edge_store.rs @@ -1,7 +1,6 @@ use crate::{ core::{ entities::{ - edges::edge_ref::EdgeRef, properties::{props::Props, tprop::TProp}, LayerIds, EID, VID, }, @@ -18,13 +17,17 @@ use crate::{ view::{BoxedLIter, IntoDynBoxed}, }, }; + +use raphtory_api::core::entities::edges::edge_ref::EdgeRef; +pub use raphtory_api::core::entities::edges::*; + use itertools::{EitherOrBoth, Itertools}; use ouroboros::self_referencing; use rayon::prelude::*; use serde::{Deserialize, Serialize}; use std::{ iter, - ops::{Deref, DerefMut, Range}, + ops::{DerefMut, Range}, }; #[derive(Serialize, Deserialize, Debug, Default, PartialEq)] @@ -87,13 +90,11 @@ impl EdgeLayer { } } -impl> From for EdgeRef { - fn from(val: E) -> Self { - EdgeRef::new_outgoing(val.eid, val.src, val.dst) +impl EdgeStore { + pub fn as_edge_ref(&self) -> EdgeRef { + EdgeRef::new_outgoing(self.eid, self.src, self.dst) } -} -impl EdgeStore { pub fn internal_num_layers(&self) -> usize { self.layers .len() diff --git a/raphtory/src/core/entities/edges/mod.rs b/raphtory/src/core/entities/edges/mod.rs index 7c83a0c4b3..d1f7224234 100644 --- a/raphtory/src/core/entities/edges/mod.rs +++ b/raphtory/src/core/entities/edges/mod.rs @@ -1,2 +1,3 @@ -pub mod edge_ref; pub mod edge_store; + +pub use raphtory_api::core::entities::edges::*; diff --git a/raphtory/src/core/entities/mod.rs b/raphtory/src/core/entities/mod.rs index 8e3c21a7be..1deb0e08cc 100644 --- a/raphtory/src/core/entities/mod.rs +++ b/raphtory/src/core/entities/mod.rs @@ -1,148 +1,13 @@ use std::sync::Arc; -#[cfg(feature = "arrow")] -use raphtory_arrow::interop::{AsEID, AsVID}; -use serde::{Deserialize, Serialize}; - -use crate::core::entities::edges::edge_ref::EdgeRef; +use raphtory_api::core::entities::edges::edge_ref::EdgeRef; pub mod edges; pub mod graph; pub mod nodes; pub mod properties; -// the only reason this is public is because the physical ids of the nodes don't move -#[repr(transparent)] -#[derive( - Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize, Default, -)] -pub struct VID(pub usize); - -impl VID { - pub fn index(&self) -> usize { - self.0 - } - - pub fn as_u64(&self) -> u64 { - self.0 as u64 - } -} - -impl From for VID { - fn from(id: usize) -> Self { - VID(id) - } -} - -#[cfg(feature = "arrow")] -impl From for VID { - fn from(vid: raphtory_arrow::interop::VID) -> Self { - VID(vid.0) - } -} - -impl From for usize { - fn from(id: VID) -> Self { - id.0 - } -} - -#[cfg(feature = "arrow")] -impl AsVID for VID { - fn as_vid(&self) -> raphtory_arrow::interop::VID { - raphtory_arrow::interop::VID::from(self.0) - } -} - -#[cfg(feature = "arrow")] -impl PartialEq for raphtory_arrow::interop::VID { - fn eq(&self, other: &VID) -> bool { - self.0 == other.0 - } -} - -#[cfg(feature = "arrow")] -impl Into for VID { - #[inline] - fn into(self) -> raphtory_arrow::interop::VID { - raphtory_arrow::interop::VID(self.0) - } -} - -#[repr(transparent)] -#[derive( - Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize, Default, -)] -pub struct EID(pub usize); - -#[cfg(feature = "arrow")] -impl From for EID { - fn from(eid: raphtory_arrow::interop::EID) -> Self { - EID(eid.0) - } -} - -#[cfg(feature = "arrow")] -impl Into for EID { - #[inline] - fn into(self) -> raphtory_arrow::interop::EID { - raphtory_arrow::interop::EID(self.0) - } -} - -#[cfg(feature = "arrow")] -impl AsEID for EID { - fn as_eid(&self) -> raphtory_arrow::interop::EID { - raphtory_arrow::interop::EID(self.0) - } -} - -#[derive( - Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize, Default, -)] -pub struct ELID { - edge: EID, - layer: Option, -} - -impl ELID { - pub fn new(edge: EID, layer: Option) -> Self { - Self { edge, layer } - } - pub fn pid(&self) -> EID { - self.edge - } - - pub fn layer(&self) -> Option { - self.layer - } -} - -impl From for ELID { - fn from(value: EdgeRef) -> Self { - ELID { - edge: value.pid(), - layer: value.layer().copied(), - } - } -} -impl EID { - pub fn from_u64(id: u64) -> Self { - EID(id as usize) - } -} - -impl From for usize { - fn from(id: EID) -> Self { - id.0 - } -} - -impl From for EID { - fn from(id: usize) -> Self { - EID(id) - } -} +pub use raphtory_api::core::entities::*; #[derive(Clone, Debug)] pub enum LayerIds { diff --git a/raphtory/src/core/mod.rs b/raphtory/src/core/mod.rs index c41d40d3cd..b2615f4a1b 100644 --- a/raphtory/src/core/mod.rs +++ b/raphtory/src/core/mod.rs @@ -29,8 +29,6 @@ use crate::{ prelude::GraphViewOps, }; use chrono::{DateTime, NaiveDateTime, Utc}; -#[cfg(feature = "arrow")] -use raphtory_arrow::interop::AsDir; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::{ @@ -136,36 +134,7 @@ impl<'a, O: AsRef + 'a> OptionAsStr<'a> for Option<&'a O> { } } -/// Denotes the direction of an edge. Can be incoming, outgoing or both. -#[derive( - Clone, - Copy, - Hash, - Eq, - PartialEq, - PartialOrd, - Debug, - Default, - serde::Serialize, - serde::Deserialize, -)] -pub enum Direction { - OUT, - IN, - #[default] - BOTH, -} - -#[cfg(feature = "arrow")] -impl AsDir for Direction { - fn as_dir(&self) -> raphtory_arrow::interop::Direction { - match self { - Direction::OUT => raphtory_arrow::interop::Direction::OUT, - Direction::IN => raphtory_arrow::interop::Direction::IN, - Direction::BOTH => raphtory_arrow::interop::Direction::BOTH, - } - } -} +pub use raphtory_api::core::*; #[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)] pub enum Lifespan { diff --git a/raphtory/src/core/storage/timeindex.rs b/raphtory/src/core/storage/timeindex.rs index ac80b386fa..006bd844f6 100644 --- a/raphtory/src/core/storage/timeindex.rs +++ b/raphtory/src/core/storage/timeindex.rs @@ -17,91 +17,7 @@ use std::{ ops::{Deref, Range}, }; -#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Ord, PartialOrd, Eq)] -pub struct TimeIndexEntry(pub i64, pub usize); - -pub trait AsTime: Debug + Copy + Ord + Eq + Send + Sync + 'static { - fn t(&self) -> i64; - - fn dt(&self) -> Option> { - let t = self.t(); - DateTime::from_timestamp_millis(t) - } - - fn range(w: Range) -> Range; -} - -#[cfg(feature = "arrow")] -impl raphtory_arrow::interop::AsTime for TimeIndexEntry { - fn t(&self) -> i64 { - self.0 - } - - fn range(w: Range) -> Range { - Self::start(w.start)..Self::start(w.end) - } - - fn new(t: i64, s: usize) -> Self { - Self(t, s) - } - - fn i(&self) -> usize { - self.1 - } -} - -impl From for TimeIndexEntry { - fn from(value: i64) -> Self { - Self::start(value) - } -} - -impl TimeIndexEntry { - pub const MIN: TimeIndexEntry = TimeIndexEntry(i64::MIN, 0); - - pub const MAX: TimeIndexEntry = TimeIndexEntry(i64::MAX, usize::MAX); - pub fn new(t: i64, s: usize) -> Self { - Self(t, s) - } - - pub fn from_input( - g: &G, - t: T, - ) -> Result { - let t = t.try_into_input_time()?; - Ok(match t { - InputTime::Simple(t) => Self::new(t, g.next_event_id()), - InputTime::Indexed(t, s) => Self::new(t, s), - }) - } - - pub fn start(t: i64) -> Self { - Self(t, 0) - } - - pub fn end(t: i64) -> Self { - Self(t.saturating_add(1), 0) - } -} - -impl AsTime for i64 { - fn t(&self) -> i64 { - *self - } - - fn range(w: Range) -> Range { - w - } -} - -impl AsTime for TimeIndexEntry { - fn t(&self) -> i64 { - self.0 - } - fn range(w: Range) -> Range { - Self::start(w.start)..Self::start(w.end) - } -} +pub use raphtory_api::core::storage::timeindex::*; #[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)] pub enum TimeIndex { @@ -375,6 +291,7 @@ pub trait TimeIndexOps: Send + Sync { Self: 'a; fn active(&self, w: Range) -> bool; + fn active_t(&self, w: Range) -> bool { self.active(Self::IndexType::range(w)) } diff --git a/raphtory/src/db/api/mutation/addition_ops.rs b/raphtory/src/db/api/mutation/addition_ops.rs index ef57e15f70..d1a50e619f 100644 --- a/raphtory/src/db/api/mutation/addition_ops.rs +++ b/raphtory/src/db/api/mutation/addition_ops.rs @@ -1,7 +1,6 @@ use crate::{ core::{ entities::{edges::edge_ref::EdgeRef, nodes::input_node::InputNode}, - storage::timeindex::TimeIndexEntry, utils::{errors::GraphError, time::IntoTimeWithFormat}, Prop, }, @@ -14,6 +13,8 @@ use crate::{ }, }; +use super::time_from_input; + pub trait AdditionOps: StaticGraphViewOps { // TODO: Probably add vector reference here like add /// Add a node to the graph @@ -112,7 +113,7 @@ impl AdditionOps for G { |name, dtype| self.resolve_node_property(name, dtype, false), |prop| self.process_prop_value(prop), )?; - let ti = TimeIndexEntry::from_input(self, t)?; + let ti = time_from_input(self, t)?; let v_id = self.resolve_node(v.id(), v.id_str()); let type_id = self.resolve_node_type(v_id, node_type)?; self.internal_add_node(ti, v_id, properties, type_id)?; @@ -127,7 +128,7 @@ impl AdditionOps for G { props: PI, layer: Option<&str>, ) -> Result, GraphError> { - let ti = TimeIndexEntry::from_input(self, t)?; + let ti = time_from_input(self, t)?; let src_id = self.resolve_node(src.id(), src.id_str()); let dst_id = self.resolve_node(dst.id(), dst.id_str()); let layer_id = self.resolve_layer(layer); diff --git a/raphtory/src/db/api/mutation/deletion_ops.rs b/raphtory/src/db/api/mutation/deletion_ops.rs index 085e95576c..9ab844abeb 100644 --- a/raphtory/src/db/api/mutation/deletion_ops.rs +++ b/raphtory/src/db/api/mutation/deletion_ops.rs @@ -1,7 +1,6 @@ use crate::{ core::{ entities::nodes::input_node::InputNode, - storage::timeindex::TimeIndexEntry, utils::{errors::GraphError, time::IntoTimeWithFormat}, }, db::api::mutation::{ @@ -10,6 +9,8 @@ use crate::{ }, }; +use super::time_from_input; + pub trait DeletionOps: InternalDeletionOps + InternalAdditionOps + Sized { fn delete_edge( &self, @@ -18,7 +19,7 @@ pub trait DeletionOps: InternalDeletionOps + InternalAdditionOps + Sized { dst: V, layer: Option<&str>, ) -> Result<(), GraphError> { - let ti = TimeIndexEntry::from_input(self, t)?; + let ti = time_from_input(self, t)?; let src_id = self.resolve_node(src.id(), src.id_str()); let dst_id = self.resolve_node(dst.id(), src.id_str()); let layer = self.resolve_layer(layer); diff --git a/raphtory/src/db/api/mutation/import_ops.rs b/raphtory/src/db/api/mutation/import_ops.rs index a1a4bb896c..8ad52c0070 100644 --- a/raphtory/src/db/api/mutation/import_ops.rs +++ b/raphtory/src/db/api/mutation/import_ops.rs @@ -1,7 +1,6 @@ use crate::{ core::{ entities::LayerIds, - storage::timeindex::TimeIndexEntry, utils::errors::{ GraphError, GraphError::{EdgeExistsError, NodeExistsError}, @@ -21,6 +20,8 @@ use crate::{ prelude::{AdditionOps, EdgeViewOps, NodeViewOps}, }; +use super::time_from_input; + pub trait ImportOps: StaticGraphViewOps + InternalAdditionOps @@ -133,7 +134,7 @@ impl< .unwrap_or(0usize); for h in node.history() { - let t = TimeIndexEntry::from_input(self, h)?; + let t = time_from_input(self, h)?; self.internal_add_node(t, node_internal, vec![], node_internal_type_id)?; } for (name, prop_view) in node.properties().temporal().iter() { @@ -152,7 +153,7 @@ impl< let new_prop_id = self.resolve_node_property(&name, dtype, false)?; for (h, prop) in prop_view.iter() { let new_prop = self.process_prop_value(prop); - let t = TimeIndexEntry::from_input(self, h)?; + let t = time_from_input(self, h)?; self.internal_add_node( t, node_internal, @@ -217,7 +218,7 @@ impl< if self.include_deletions() { for t in edge.graph.edge_deletion_history(edge.edge, &layer_ids) { - let ti = TimeIndexEntry::from_input(self, t)?; + let ti = time_from_input(self, t)?; let src_id = self.resolve_node(edge.src().id(), Some(&edge.src().name())); let dst_id = self.resolve_node(edge.dst().id(), Some(&edge.dst().name())); let layer = self.resolve_layer(layer_name); diff --git a/raphtory/src/db/api/mutation/mod.rs b/raphtory/src/db/api/mutation/mod.rs index 9d552dc998..e5494453e7 100644 --- a/raphtory/src/db/api/mutation/mod.rs +++ b/raphtory/src/db/api/mutation/mod.rs @@ -19,6 +19,9 @@ pub use addition_ops::AdditionOps; pub use deletion_ops::DeletionOps; pub use import_ops::ImportOps; pub use property_addition_ops::PropertyAdditionOps; +use raphtory_api::core::storage::timeindex::TimeIndexEntry; + +use self::internal::InternalAdditionOps; /// Used to handle automatic injection of secondary index if not explicitly provided pub enum InputTime { @@ -26,6 +29,17 @@ pub enum InputTime { Indexed(i64, usize), } +pub fn time_from_input( + g: &G, + t: T, +) -> Result { + let t = t.try_into_input_time()?; + Ok(match t { + InputTime::Simple(t) => TimeIndexEntry::new(t, g.next_event_id()), + InputTime::Indexed(t, s) => TimeIndexEntry::new(t, s), + }) +} + pub trait TryIntoInputTime { fn try_into_input_time(self) -> Result; } diff --git a/raphtory/src/db/api/mutation/property_addition_ops.rs b/raphtory/src/db/api/mutation/property_addition_ops.rs index c3d9905ec1..9c26585270 100644 --- a/raphtory/src/db/api/mutation/property_addition_ops.rs +++ b/raphtory/src/db/api/mutation/property_addition_ops.rs @@ -9,7 +9,7 @@ use crate::{ }, }; -use super::CollectProperties; +use super::{time_from_input, CollectProperties}; pub trait PropertyAdditionOps { fn add_properties( @@ -31,7 +31,7 @@ impl PropertyAdditionOps f t: T, props: PI, ) -> Result<(), GraphError> { - let ti = TimeIndexEntry::from_input(self, t)?; + let ti = time_from_input(self, t)?; let properties: Vec<_> = props.collect_properties( |name, _| Ok(self.resolve_graph_property(name, false)), |prop| self.process_prop_value(prop), diff --git a/raphtory/src/db/api/storage/storage_ops.rs b/raphtory/src/db/api/storage/storage_ops.rs index 6ef7e45ad0..10d136afe8 100644 --- a/raphtory/src/db/api/storage/storage_ops.rs +++ b/raphtory/src/db/api/storage/storage_ops.rs @@ -252,7 +252,7 @@ impl GraphStorage { let iter = (0..edges.len()).map(EID); let filtered = match view.filter_state() { FilterState::Neither => { - FilterVariants::Neither(iter.map(move |eid| EdgeRef::from(edges.get(eid)))) + FilterVariants::Neither(iter.map(move |eid| edges.get(eid).as_edge_ref())) } FilterState::Both => FilterVariants::Both(iter.filter_map(move |e| { let e = EdgeStorageRef::Mem(edges.get(e)); @@ -378,7 +378,7 @@ impl GraphStorage { let iter = (0..edges.len()).into_par_iter().map(EID); let filtered = match view.filter_state() { FilterState::Neither => { - FilterVariants::Neither(iter.map(move |eid| EdgeRef::from(edges.get(eid)))) + FilterVariants::Neither(iter.map(move |eid| edges.get(eid).as_edge_ref())) } FilterState::Both => FilterVariants::Both(iter.filter_map(move |e| { let e = EdgeStorageRef::Mem(edges.get(e)); diff --git a/raphtory/src/db/graph/edge.rs b/raphtory/src/db/graph/edge.rs index 05def8578c..e5ae56d652 100644 --- a/raphtory/src/db/graph/edge.rs +++ b/raphtory/src/db/graph/edge.rs @@ -18,7 +18,7 @@ use crate::{ api::{ mutation::{ internal::{InternalAdditionOps, InternalDeletionOps, InternalPropertyAdditionOps}, - CollectProperties, TryIntoInputTime, + time_from_input, CollectProperties, TryIntoInputTime, }, properties::{ internal::{ConstPropertiesOps, TemporalPropertiesOps, TemporalPropertyViewOps}, @@ -85,7 +85,7 @@ impl< > EdgeView { pub fn delete(&self, t: T, layer: Option<&str>) -> Result<(), GraphError> { - let t = TimeIndexEntry::from_input(&self.graph, t)?; + let t = time_from_input(&self.graph, t)?; let layer = self.resolve_layer(layer, true)?; self.graph .internal_delete_edge(t, self.edge.src(), self.edge.dst(), layer) @@ -249,7 +249,7 @@ impl props: C, layer: Option<&str>, ) -> Result<(), GraphError> { - let t = TimeIndexEntry::from_input(&self.graph, time)?; + let t = time_from_input(&self.graph, time)?; let layer_id = self.resolve_layer(layer, true)?; let properties: Vec<(usize, Prop)> = props.collect_properties( |name, dtype| self.graph.resolve_edge_property(name, dtype, false), diff --git a/raphtory/src/db/graph/node.rs b/raphtory/src/db/graph/node.rs index 9dbf4f23e6..d12e59edc7 100644 --- a/raphtory/src/db/graph/node.rs +++ b/raphtory/src/db/graph/node.rs @@ -11,7 +11,7 @@ use crate::{ api::{ mutation::{ internal::{InternalAdditionOps, InternalPropertyAdditionOps}, - CollectProperties, TryIntoInputTime, + time_from_input, CollectProperties, TryIntoInputTime, }, properties::{ internal::{ConstPropertiesOps, TemporalPropertiesOps, TemporalPropertyViewOps}, @@ -358,7 +358,7 @@ impl time: T, props: C, ) -> Result<(), GraphError> { - let t = TimeIndexEntry::from_input(&self.graph, time)?; + let t = time_from_input(&self.graph, time)?; let properties: Vec<(usize, Prop)> = props.collect_properties( |name, dtype| self.graph.resolve_node_property(name, dtype, false), |prop| self.graph.process_prop_value(prop), From 3152378bc97f4f87537346de5aefd38f9bb2a187 Mon Sep 17 00:00:00 2001 From: Fabian Murariu Date: Fri, 24 May 2024 17:15:03 +0100 Subject: [PATCH 2/8] clippy --- raphtory/src/algorithms/algorithm_result.rs | 4 +- raphtory/src/algorithms/components/lcc.rs | 6 +-- raphtory/src/algorithms/components/scc.rs | 2 +- .../local_temporal_three_node_motifs.rs | 1 - .../algorithms/motifs/three_node_motifs.rs | 2 +- raphtory/src/arrow/graph_impl/core_ops.rs | 17 +++---- .../src/arrow/graph_impl/edge_storage_ops.rs | 18 +++---- raphtory/src/arrow/graph_impl/interop.rs | 8 +-- raphtory/src/arrow/graph_impl/mod.rs | 10 ++-- .../src/arrow/graph_impl/prop_conversion.rs | 4 +- .../arrow/graph_impl/time_index_into_ops.rs | 3 -- .../src/arrow/graph_impl/time_semantics.rs | 10 ++-- raphtory/src/arrow/graph_impl/tprops.rs | 20 ++++---- raphtory/src/arrow/mod.rs | 2 +- raphtory/src/arrow/query/ast.rs | 6 +++ raphtory/src/arrow/query/executors/rayon2.rs | 14 +++--- raphtory/src/arrow/query/mod.rs | 21 ++++---- raphtory/src/arrow/query/state.rs | 10 +++- raphtory/src/arrow/storage_interface/edges.rs | 12 ++--- raphtory/src/arrow/storage_interface/node.rs | 22 ++++---- .../src/arrow/storage_interface/nodes_ref.rs | 2 +- raphtory/src/core/entities/mod.rs | 1 - raphtory/src/core/mod.rs | 2 +- raphtory/src/core/storage/lazy_vec.rs | 10 +++- raphtory/src/core/storage/timeindex.rs | 4 +- .../db/api/mutation/property_addition_ops.rs | 1 - .../src/db/api/storage/edges/edge_entry.rs | 2 +- .../db/api/storage/edges/edge_owned_entry.rs | 2 +- raphtory/src/db/api/storage/edges/edge_ref.rs | 4 +- .../db/api/storage/edges/edge_storage_ops.rs | 4 +- raphtory/src/db/api/view/edge.rs | 4 +- raphtory/src/db/api/view/graph.rs | 4 +- raphtory/src/db/graph/edge.rs | 4 +- raphtory/src/db/graph/graph.rs | 50 +++++++++---------- raphtory/src/db/graph/node.rs | 5 +- raphtory/src/db/graph/views/deletion_graph.rs | 4 +- raphtory/src/db/graph/views/layer_graph.rs | 4 +- raphtory/src/db/graph/views/node_subgraph.rs | 4 +- raphtory/src/db/graph/views/window_graph.rs | 4 +- raphtory/src/db/task/edge/eval_edges.rs | 2 +- raphtory/src/db/task/mod.rs | 2 +- 41 files changed, 158 insertions(+), 153 deletions(-) diff --git a/raphtory/src/algorithms/algorithm_result.rs b/raphtory/src/algorithms/algorithm_result.rs index db76825d09..e46060227e 100644 --- a/raphtory/src/algorithms/algorithm_result.rs +++ b/raphtory/src/algorithms/algorithm_result.rs @@ -522,7 +522,7 @@ mod algorithm_result_test { let algo_result = create_algo_result_tuple(); assert_eq!(algo_result.get(node_c.clone()).unwrap().0, 30.0f32); let algo_result = create_algo_result_hashmap_vec(); - let answer = algo_result.get(node_c.clone()).unwrap().get(0).unwrap().0; + let answer = algo_result.get(node_c.clone()).unwrap().first().unwrap().0; assert_eq!(answer, 22i32); } @@ -617,7 +617,7 @@ mod algorithm_result_test { let algo_result = create_algo_result_hashmap_vec(); let algo_results_hashmap = algo_result.get_all_with_names(); let tuple_result = algo_results_hashmap.get("A").unwrap(); - assert_eq!(tuple_result.clone().get(0).unwrap().0, 11); + assert_eq!(tuple_result.clone().first().unwrap().0, 11); assert_eq!(algo_result.get_all_values().len(), 3); } diff --git a/raphtory/src/algorithms/components/lcc.rs b/raphtory/src/algorithms/components/lcc.rs index d31a902041..2727ea4463 100644 --- a/raphtory/src/algorithms/components/lcc.rs +++ b/raphtory/src/algorithms/components/lcc.rs @@ -86,9 +86,8 @@ mod largest_connected_component_test { let expected_nodes = vec![1, 2, 3]; for node in expected_nodes { - assert_eq!( + assert!( subgraph.has_node(node), - true, "Node {} should be in the largest connected component.", node ); @@ -113,9 +112,8 @@ mod largest_connected_component_test { let subgraph = graph.largest_connected_component(); let expected_nodes = vec![1, 2, 3]; for node in expected_nodes { - assert_eq!( + assert!( subgraph.has_node(node), - true, "Node {} should be in the largest connected component.", node ); diff --git a/raphtory/src/algorithms/components/scc.rs b/raphtory/src/algorithms/components/scc.rs index 5523a70d9a..f46f423517 100644 --- a/raphtory/src/algorithms/components/scc.rs +++ b/raphtory/src/algorithms/components/scc.rs @@ -41,7 +41,7 @@ fn tarjan<'graph, G>( for neighbor in node.out_neighbours() { if !indices.contains_key(&neighbor.node) { tarjan( - neighbor.clone(), + neighbor, index, stack, indices, diff --git a/raphtory/src/algorithms/motifs/local_temporal_three_node_motifs.rs b/raphtory/src/algorithms/motifs/local_temporal_three_node_motifs.rs index 96013b45b8..794dbdf5ec 100644 --- a/raphtory/src/algorithms/motifs/local_temporal_three_node_motifs.rs +++ b/raphtory/src/algorithms/motifs/local_temporal_three_node_motifs.rs @@ -447,7 +447,6 @@ mod motifs_test { let actual = binding .iter() .map(|(k, v)| (k, v[0].clone())) - .into_iter() .collect::>>(); let expected: HashMap> = HashMap::from([ diff --git a/raphtory/src/algorithms/motifs/three_node_motifs.rs b/raphtory/src/algorithms/motifs/three_node_motifs.rs index 253e3b72f9..b942b57b99 100644 --- a/raphtory/src/algorithms/motifs/three_node_motifs.rs +++ b/raphtory/src/algorithms/motifs/three_node_motifs.rs @@ -382,7 +382,7 @@ mod three_node_motifs_test { #[test] fn triad_test() { - let events = vec![(true, 0, 1, 1, 1), (false, 1, 0, 1, 2), (false, 0, 0, 0, 3)] + let events = [(true, 0, 1, 1, 1), (false, 1, 0, 1, 2), (false, 0, 0, 0, 3)] .iter() .map(|x| TriangleEdge { uv_edge: x.0, diff --git a/raphtory/src/arrow/graph_impl/core_ops.rs b/raphtory/src/arrow/graph_impl/core_ops.rs index b9d9c455f9..33ef9ef5f1 100644 --- a/raphtory/src/arrow/graph_impl/core_ops.rs +++ b/raphtory/src/arrow/graph_impl/core_ops.rs @@ -67,7 +67,7 @@ impl CoreGraphOps for ArrowGraph { LayerIds::All => Box::new( self.inner .layer_names() - .into_iter() + .iter() .map(|s| ArcStr::from(s.as_str())) .collect::>() .into_iter(), @@ -78,7 +78,7 @@ impl CoreGraphOps for ArrowGraph { .get(*id) .cloned() .into_iter() - .map(|s| ArcStr::from(s)), + .map(ArcStr::from), ), LayerIds::Multiple(ids) => Box::new( ids.iter() @@ -86,7 +86,7 @@ impl CoreGraphOps for ArrowGraph { .filter_map(|id| self.inner.layer_names().get(id).cloned()) .collect_vec() .into_iter() - .map(|s| ArcStr::from(s)), + .map(ArcStr::from), ), } } @@ -117,12 +117,11 @@ impl CoreGraphOps for ArrowGraph { fn internalise_node(&self, v: NodeRef) -> Option { match v { - NodeRef::Internal(vid) => Some(vid.into()), - NodeRef::External(vid) => self.inner.find_node(&GID::U64(vid)).map(|v| v.into()), + NodeRef::Internal(vid) => Some(vid), + NodeRef::External(vid) => self.inner.find_node(&GID::U64(vid)), NodeRef::ExternalStr(string) => self .inner - .find_node(&GID::Str(string.into())) - .map(|v| v.into()), + .find_node(&GID::Str(string.into())), } } @@ -141,7 +140,7 @@ impl CoreGraphOps for ArrowGraph { fn constant_node_prop(&self, v: VID, id: usize) -> Option { match &self.inner.node_properties() { None => None, - Some(props) => const_props(props, v.into(), id), + Some(props) => const_props(props, v, id), } } @@ -150,7 +149,7 @@ impl CoreGraphOps for ArrowGraph { None => Box::new(std::iter::empty()), Some(props) => Box::new( (0..props.const_props.num_props()) - .filter(move |id| props.const_props.has_prop(v.into(), *id)), + .filter(move |id| props.const_props.has_prop(v, *id)), ), } } diff --git a/raphtory/src/arrow/graph_impl/edge_storage_ops.rs b/raphtory/src/arrow/graph_impl/edge_storage_ops.rs index bf3ac60d6e..a77764e4c2 100644 --- a/raphtory/src/arrow/graph_impl/edge_storage_ops.rs +++ b/raphtory/src/arrow/graph_impl/edge_storage_ops.rs @@ -17,18 +17,18 @@ use std::{iter, ops::Range}; impl<'a> EdgeStorageOps<'a> for Edge<'a> { fn in_ref(self) -> EdgeRef { EdgeRef::new_incoming( - self.eid().into(), - self.src_id().into(), - self.dst_id().into(), + self.eid(), + self.src_id(), + self.dst_id(), ) .at_layer(self.layer_id()) } fn out_ref(self) -> EdgeRef { EdgeRef::new_outgoing( - self.eid().into(), - self.src_id().into(), - self.dst_id().into(), + self.eid(), + self.src_id(), + self.dst_id(), ) .at_layer(self.layer_id()) } @@ -43,11 +43,11 @@ impl<'a> EdgeStorageOps<'a> for Edge<'a> { } fn src(self) -> VID { - self.src_id().into() + self.src_id() } fn dst(self) -> VID { - self.dst_id().into() + self.dst_id() } fn layer_ids_iter(self, layer_ids: &'a LayerIds) -> impl Iterator + 'a { @@ -101,7 +101,7 @@ impl<'a> EdgeStorageOps<'a> for Edge<'a> { self, layer_id: usize, prop_id: usize, - ) -> impl TPropOps<'a> + Send + Sync + 'a { + ) -> impl TPropOps<'a> + Sync + 'a { if layer_id == self.layer_id() { self.temporal_property_field(prop_id) .and_then(|field| read_tprop_column(prop_id, field, self)) diff --git a/raphtory/src/arrow/graph_impl/interop.rs b/raphtory/src/arrow/graph_impl/interop.rs index 9dd184815a..22b1bffb44 100644 --- a/raphtory/src/arrow/graph_impl/interop.rs +++ b/raphtory/src/arrow/graph_impl/interop.rs @@ -58,7 +58,7 @@ impl GraphLike for Graph { fn in_edges(&self, vid: VID, layer: usize, map: impl Fn(VID, EID) -> B) -> Vec { let node = self.core_node_entry(vid.0.into()); node.edges_iter(&LayerIds::One(layer), Direction::IN) - .map(|edge| map(edge.src().into(), edge.pid().into())) + .map(|edge| map(edge.src(), edge.pid())) .collect() } fn out_edges(&self, vid: VID, layer: usize) -> Vec<(VID, VID, EID)> { @@ -66,9 +66,9 @@ impl GraphLike for Graph { let edges = node .edges_iter(&LayerIds::One(layer), Direction::OUT) .map(|edge| { - let src = edge.src().into(); - let dst = edge.dst().into(); - let eid = edge.pid().into(); + let src = edge.src(); + let dst = edge.dst(); + let eid = edge.pid(); (src, dst, eid) }) .collect(); diff --git a/raphtory/src/arrow/graph_impl/mod.rs b/raphtory/src/arrow/graph_impl/mod.rs index e1f7f541b8..dd27025a24 100644 --- a/raphtory/src/arrow/graph_impl/mod.rs +++ b/raphtory/src/arrow/graph_impl/mod.rs @@ -115,7 +115,7 @@ impl ArrowGraph { ) -> ArrowGraph { // unzip into 4 vectors let (src, (dst, (time, weight))): (Vec<_>, (Vec<_>, (Vec<_>, Vec<_>))) = edges - .into_iter() + .iter() .map(|(a, b, c, d)| (*a, (*b, (*c, *d)))) .unzip(); @@ -251,11 +251,11 @@ impl ArrowGraph { time_col, }| { ExternalEdgeList::new( - *layer, + layer, parquet_dir.as_ref(), - *src_col, - *dst_col, - *time_col, + src_col, + dst_col, + time_col, ) .expect("Failed to load events") }, diff --git a/raphtory/src/arrow/graph_impl/prop_conversion.rs b/raphtory/src/arrow/graph_impl/prop_conversion.rs index 376062933a..6cdbd72b78 100644 --- a/raphtory/src/arrow/graph_impl/prop_conversion.rs +++ b/raphtory/src/arrow/graph_impl/prop_conversion.rs @@ -221,6 +221,6 @@ pub fn schema_from_prop_meta(prop_map: &PropMapper) -> Schema { } } - let schema = Schema::from(schema); - schema + + Schema::from(schema) } diff --git a/raphtory/src/arrow/graph_impl/time_index_into_ops.rs b/raphtory/src/arrow/graph_impl/time_index_into_ops.rs index 2168531c64..bfc269bb72 100644 --- a/raphtory/src/arrow/graph_impl/time_index_into_ops.rs +++ b/raphtory/src/arrow/graph_impl/time_index_into_ops.rs @@ -70,7 +70,6 @@ impl<'a> TimeIndexOps for TimeStamps<'a, TimeIndexEntry> { TimeStamps::new( self.timestamps().slice(start..end), self.sec_index() - .clone() .map(|sec_index| sec_index.sliced(start..end)), ) } @@ -112,7 +111,6 @@ impl<'a> TimeIndexOps for TimeStamps<'a, TimeIndexEntry> { fn iter(&self) -> Box + Send + '_> { let sec_iter: Box + Send + 'a> = self .sec_index() - .clone() .map(|v| v.map(|i| i as usize).into_dyn_boxed()) .unwrap_or(self.timestamps().range().clone().into_dyn_boxed()); Box::new( @@ -141,7 +139,6 @@ impl<'a> TimeIndexOps for TimeStamps<'a, i64> { TimeStamps::new( self.timestamps().slice(start..end), self.sec_index() - .clone() .map(|sec_index| sec_index.sliced(start..end)), ) } diff --git a/raphtory/src/arrow/graph_impl/time_semantics.rs b/raphtory/src/arrow/graph_impl/time_semantics.rs index ffc64dc05f..ac231a277a 100644 --- a/raphtory/src/arrow/graph_impl/time_semantics.rs +++ b/raphtory/src/arrow/graph_impl/time_semantics.rs @@ -121,7 +121,7 @@ impl TimeSemantics for ArrowGraph { .map(|props| { props .temporal_props - .timestamps::(v.vid().into()) + .timestamps::(v.vid()) .active_t(w.clone()) }) .unwrap_or(false) @@ -452,7 +452,7 @@ impl TimeSemantics for ArrowGraph { fn has_temporal_node_prop(&self, v: VID, prop_id: usize) -> bool { match &self.inner.node_properties() { None => false, - Some(props) => props.temporal_props.has_prop(v.into(), prop_id), + Some(props) => props.temporal_props.has_prop(v, prop_id), } } @@ -462,14 +462,14 @@ impl TimeSemantics for ArrowGraph { None => { vec![] } - Some(props) => props.temporal_props.prop(v.into(), id).iter_t().collect(), + Some(props) => props.temporal_props.prop(v, id).iter_t().collect(), } } fn has_temporal_node_prop_window(&self, v: VID, prop_id: usize, w: Range) -> bool { match &self.inner.node_properties() { None => false, - Some(props) => props.temporal_props.has_prop_window(v.into(), prop_id, w), + Some(props) => props.temporal_props.has_prop_window(v, prop_id, w), } } @@ -484,7 +484,7 @@ impl TimeSemantics for ArrowGraph { None => vec![], Some(props) => props .temporal_props - .prop(v.into(), id) + .prop(v, id) .iter_window_t(start..end) .collect(), } diff --git a/raphtory/src/arrow/graph_impl/tprops.rs b/raphtory/src/arrow/graph_impl/tprops.rs index a5426adcc8..da77989cc9 100644 --- a/raphtory/src/arrow/graph_impl/tprops.rs +++ b/raphtory/src/arrow/graph_impl/tprops.rs @@ -24,7 +24,7 @@ impl<'a, T: NativeType + Into> TPropOps<'a> let (props, timestamps) = self.into_inner(); let (t, t_index) = timestamps.last_before(t)?; let v = props.get(t_index)?; - Some((t.into(), v.into())) + Some((t, v.into())) } fn iter(self) -> impl Iterator + Send + 'a { @@ -40,18 +40,18 @@ impl<'a, T: NativeType + Into> TPropOps<'a> r: Range, ) -> impl Iterator + Send + 'a { let (props, timestamps) = self.into_inner(); - let start = timestamps.position(&r.start.into()); - let end = timestamps.position(&r.end.into()); + let start = timestamps.position(&r.start); + let end = timestamps.position(&r.end); timestamps .sliced(start..end) .into_iter() - .zip(props.sliced(start..end).into_iter()) + .zip(props.sliced(start..end)) .filter_map(|(t, v)| v.map(|v| (t, v.into()))) } fn at(self, ti: &TimeIndexEntry) -> Option { let (props, timestamps) = self.into_inner(); - let t_index = timestamps.position(ti.into()); + let t_index = timestamps.position(ti); props.get(t_index).map(|v| v.into()) } @@ -71,7 +71,7 @@ impl<'a, I: Offset> TPropOps<'a> for TPropColumn<'a, StringCol<'a, I>, TimeIndex let (props, timestamps) = self.into_inner(); let (t, t_index) = timestamps.last_before(t)?; let v = props.get(t_index)?; - Some((t.into(), v.into())) + Some((t, v.into())) } fn iter(self) -> impl Iterator + Send + 'a { @@ -87,18 +87,18 @@ impl<'a, I: Offset> TPropOps<'a> for TPropColumn<'a, StringCol<'a, I>, TimeIndex r: Range, ) -> impl Iterator + Send + 'a { let (props, timestamps) = self.into_inner(); - let start = timestamps.position(&r.start.into()); - let end = timestamps.position(&r.end.into()); + let start = timestamps.position(&r.start); + let end = timestamps.position(&r.end); timestamps .sliced(start..end) .into_iter() - .zip(props.sliced(start..end).into_iter()) + .zip(props.sliced(start..end)) .filter_map(|(t, v)| v.map(|v| (t, v.into()))) } fn at(self, ti: &TimeIndexEntry) -> Option { let (props, timestamps) = self.into_inner(); - let t_index = timestamps.position(ti.into()); + let t_index = timestamps.position(ti); props.get(t_index).map(|v| v.into()) } diff --git a/raphtory/src/arrow/mod.rs b/raphtory/src/arrow/mod.rs index be37356346..862342e644 100644 --- a/raphtory/src/arrow/mod.rs +++ b/raphtory/src/arrow/mod.rs @@ -446,7 +446,7 @@ mod test { let dst = dst as u64; times.into_iter().map(move |t| (src, dst, t))}).collect(); v.sort(); - v}).prop_filter("edge list mut have one edge at least",|edges| edges.len() > 0), + v}).prop_filter("edge list mut have one edge at least",|edges| !edges.is_empty()), chunk_size in 1..300usize, ) { compare_raphtory_graph(edges, chunk_size); diff --git a/raphtory/src/arrow/query/ast.rs b/raphtory/src/arrow/query/ast.rs index 77ed485ecb..574d8e6091 100644 --- a/raphtory/src/arrow/query/ast.rs +++ b/raphtory/src/arrow/query/ast.rs @@ -28,6 +28,12 @@ pub struct Query { pub hops: Vec, } +impl Default for Query { + fn default() -> Self { + Self::new() + } +} + impl Query { pub fn new() -> Self { Self { diff --git a/raphtory/src/arrow/query/executors/rayon2.rs b/raphtory/src/arrow/query/executors/rayon2.rs index b55fac8c9b..6a86ff0387 100644 --- a/raphtory/src/arrow/query/executors/rayon2.rs +++ b/raphtory/src/arrow/query/executors/rayon2.rs @@ -85,8 +85,8 @@ pub fn execute_static_graph( - _s: &'b Scope<'a>, +fn node_view<'a, G: StaticGraphViewOps>( + _s: &Scope<'a>, graph: &'a G, node: VID, ) -> NodeView<&'a G> { @@ -97,10 +97,10 @@ fn lookup_layer(layer: &str, graph: &ArrowGraph) -> usize { graph.inner.find_layer_id(layer).expect("No layer") } -fn get_writer<'a>( +fn get_writer( dir: impl AsRef, - tl: &'a thread_local::ThreadLocal>>, -) -> &'a RefCell> { + tl: &thread_local::ThreadLocal>>, +) -> &RefCell> { let out = tl.get_or(|| { let thread_index = current_thread_index().expect("No thread index"); let path = dir.as_ref().join(format!("part_{}.bin", thread_index)); @@ -132,7 +132,7 @@ fn hop_arrow_graph<'a, S: HopState + 'a>( { let layer = lookup_layer(layer, graph); if *variable { - do_sink(sink, s, state.clone(), vid.into(), tl); + do_sink(sink, s, state.clone(), vid, tl); } let limit = limit.unwrap_or(usize::MAX); match dir { @@ -173,7 +173,7 @@ fn hop_arrow_graph<'a, S: HopState + 'a>( } } } else { - do_sink(sink, s, state, vid.into(), tl); + do_sink(sink, s, state, vid, tl); } } diff --git a/raphtory/src/arrow/query/mod.rs b/raphtory/src/arrow/query/mod.rs index e5f43a4ab1..421cf6a298 100644 --- a/raphtory/src/arrow/query/mod.rs +++ b/raphtory/src/arrow/query/mod.rs @@ -27,20 +27,18 @@ pub enum NodeSource { impl NodeSource { fn into_iter(self, graph: &ArrowGraph) -> Box + '_> { match self { - NodeSource::All => Box::new((0..graph.inner.num_nodes()).into_iter().map(VID)), + NodeSource::All => Box::new((0..graph.inner.num_nodes()).map(VID)), NodeSource::NodeIds(ids) => Box::new(ids.into_iter()), NodeSource::Filter(filter) => Box::new( graph .inner .all_nodes() - .filter(move |node| filter(Into::::into(*node), graph)) - .map(|node| node.into()), + .filter(move |node| filter(Into::::into(*node), graph)), ), NodeSource::ExternalIds(ext_ids) => Box::new( ext_ids .into_iter() - .filter_map(move |gid| graph.inner.find_node(&gid)) - .map(|node| node.into()), + .filter_map(move |gid| graph.inner.find_node(&gid)), ), } } @@ -59,8 +57,7 @@ impl NodeSource { .and_then(|gid| graph.node(NodeRef::External(gid))) }) }) - .map(|node| node.node) - .into_iter(), + .map(|node| node.node), ), NodeSource::Filter(_) => todo!(), } @@ -78,7 +75,7 @@ impl ForwardState { pub fn at_time(node: Node, t: i64, hop_n_limit: usize) -> Self { ForwardState { time: t, - path: rpds::List::new_sync().push_front(node.vid().into()), + path: rpds::List::new_sync().push_front(node.vid()), hop_n_limit, } } @@ -96,7 +93,7 @@ impl HopState for ForwardState { next_time.first_t().map(|t| ForwardState { time: t, - path: self.path.push_front(node.vid().into()), + path: self.path.push_front(node.vid()), hop_n_limit: self.hop_n_limit, }) } @@ -176,7 +173,7 @@ mod test { let graph = ArrowGraph::from_graph(&g, graph_dir.path()).unwrap(); let result = - rayon2::execute::(query, NodeSource::All, &graph, |n| VecState::new(n)); + rayon2::execute::(query, NodeSource::All, &graph, VecState::new); assert!(result.is_ok()); let mut actual = receiver.into_iter().map(|(state, _)| state.0).collect_vec(); actual.sort(); @@ -210,7 +207,7 @@ mod test { let graph = ArrowGraph::from_graph(&g, graph_dir.path()).unwrap(); let result = - rayon2::execute::(query, NodeSource::All, &graph, |n| VecState::new(n)); + rayon2::execute::(query, NodeSource::All, &graph, VecState::new); assert!(result.is_ok()); let (path, vid) = receiver.recv().unwrap(); assert_eq!(vid, VID(2)); @@ -236,7 +233,7 @@ mod test { let graph = ArrowGraph::from_graph(&g, graph_dir.path()).unwrap(); let result = - rayon2::execute::(query, NodeSource::All, &graph, |n| VecState::new(n)); + rayon2::execute::(query, NodeSource::All, &graph, VecState::new); assert!(result.is_ok()); let mut results = receiver.into_iter().collect::>(); diff --git a/raphtory/src/arrow/query/state.rs b/raphtory/src/arrow/query/state.rs index f30e58fa58..e91a89015e 100644 --- a/raphtory/src/arrow/query/state.rs +++ b/raphtory/src/arrow/query/state.rs @@ -22,6 +22,12 @@ pub trait StaticGraphHopState: Send + Sync + Clone + std::fmt::Debug { #[derive(Clone, PartialEq, Debug, PartialOrd)] pub struct NoState; +impl Default for NoState { + fn default() -> Self { + Self::new() + } +} + impl NoState { pub fn new() -> Self { NoState @@ -38,14 +44,14 @@ pub struct VecState(pub Vec); impl VecState { pub fn new(node: Node) -> Self { - VecState(vec![node.vid().into()]) + VecState(vec![node.vid()]) } } impl HopState for VecState { fn hop_with_state(&self, node: Node, _edge: Edge) -> Option { let VecState(mut vec) = self.clone(); - vec.push(node.vid().into()); + vec.push(node.vid()); Some(VecState(vec)) } } diff --git a/raphtory/src/arrow/storage_interface/edges.rs b/raphtory/src/arrow/storage_interface/edges.rs index 3d608a5cff..02ce4bfd9c 100644 --- a/raphtory/src/arrow/storage_interface/edges.rs +++ b/raphtory/src/arrow/storage_interface/edges.rs @@ -30,18 +30,18 @@ impl ArrowEdges { LayerIds::All => LayerVariants::All((0..self.layers.len()).flat_map(move |layer_id| { self.layers[layer_id] .all_edge_ids() - .map(move |e| (e.into(), layer_id)) + .map(move |e| (e, layer_id)) })), LayerIds::One(layer_id) => LayerVariants::One( self.layers[layer_id] .all_edge_ids() - .map(move |e| (e.into(), layer_id)), + .map(move |e| (e, layer_id)), ), LayerIds::Multiple(ids) => LayerVariants::Multiple((0..ids.len()).flat_map(move |i| { let layer_id = ids[i]; self.layers[layer_id] .all_edge_ids() - .map(move |e| (e.into(), layer_id)) + .map(move |e| (e, layer_id)) })), } } @@ -56,20 +56,20 @@ impl ArrowEdges { move |layer_id| { self.layers[layer_id] .all_edge_ids_par() - .map(move |e| (e.into(), layer_id)) + .map(move |e| (e, layer_id)) }, )), LayerIds::One(layer_id) => LayerVariants::One( self.layers[layer_id] .all_edge_ids_par() - .map(move |e| (e.into(), layer_id)), + .map(move |e| (e, layer_id)), ), LayerIds::Multiple(ids) => { LayerVariants::Multiple((0..ids.len()).into_par_iter().flat_map(move |i| { let layer_id = ids[i]; self.layers[layer_id] .all_edge_ids_par() - .map(move |e| (e.into(), layer_id)) + .map(move |e| (e, layer_id)) })) } } diff --git a/raphtory/src/arrow/storage_interface/node.rs b/raphtory/src/arrow/storage_interface/node.rs index b41c01ea69..299205d1b0 100644 --- a/raphtory/src/arrow/storage_interface/node.rs +++ b/raphtory/src/arrow/storage_interface/node.rs @@ -48,7 +48,7 @@ impl<'a> ArrowNode<'a> { .nodes_storage() .out_adj_list(self.vid) .map(move |(eid, dst)| { - EdgeRef::new_outgoing(eid.into(), self.vid.into(), dst.into()) + EdgeRef::new_outgoing(eid, self.vid, dst) .at_layer(layer_id) }) }) @@ -59,7 +59,7 @@ impl<'a> ArrowNode<'a> { .nodes_storage() .out_adj_list(self.vid) .map(move |(eid, dst)| { - EdgeRef::new_outgoing(eid.into(), self.vid.into(), dst.into()) + EdgeRef::new_outgoing(eid, self.vid, dst) .at_layer(*layer_id) }), ), @@ -70,7 +70,7 @@ impl<'a> ArrowNode<'a> { .nodes_storage() .out_adj_list(self.vid) .map(move |(eid, dst)| { - EdgeRef::new_outgoing(eid.into(), self.vid.into(), dst.into()) + EdgeRef::new_outgoing(eid, self.vid, dst) .at_layer(layer_id) }) }) @@ -91,7 +91,7 @@ impl<'a> ArrowNode<'a> { .nodes_storage() .in_adj_list(self.vid) .map(move |(eid, src)| { - EdgeRef::new_incoming(eid.into(), src.into(), self.vid.into()) + EdgeRef::new_incoming(eid, src, self.vid) .at_layer(layer_id) }) }) @@ -102,7 +102,7 @@ impl<'a> ArrowNode<'a> { .nodes_storage() .in_adj_list(self.vid) .map(move |(eid, src)| { - EdgeRef::new_incoming(eid.into(), src.into(), self.vid.into()) + EdgeRef::new_incoming(eid, src, self.vid) .at_layer(*layer_id) }), ), @@ -113,7 +113,7 @@ impl<'a> ArrowNode<'a> { .nodes_storage() .in_adj_list(self.vid) .map(move |(eid, src)| { - EdgeRef::new_incoming(eid.into(), src.into(), self.vid.into()) + EdgeRef::new_incoming(eid, src, self.vid) .at_layer(layer_id) }) }) @@ -166,7 +166,7 @@ impl<'a> ArrowNode<'a> { } }; if let Some(props) = self.properties { - let timestamps = props.temporal_props.timestamps::(self.vid.into()); + let timestamps = props.temporal_props.timestamps::(self.vid); if timestamps.len() > 0 { let ts = timestamps.times(); additions.push(ts); @@ -230,7 +230,7 @@ impl<'a> NodeStorageOps<'a> for ArrowNode<'a> { self.properties .unwrap() .temporal_props - .prop(self.vid.into(), prop_id) + .prop(self.vid, prop_id) } fn edges_iter( @@ -264,13 +264,13 @@ impl<'a> NodeStorageOps<'a> for ArrowNode<'a> { 0 => None, 1 => { let eid = self.layers[0].nodes_storage().find_edge(self.vid, dst)?; - Some(EdgeRef::new_outgoing(eid.into(), self.vid.into(), dst.into()).at_layer(0)) + Some(EdgeRef::new_outgoing(eid, self.vid, dst).at_layer(0)) } _ => todo!("multilayer edge views not implemented in arrow yet"), }, LayerIds::One(id) => { let eid = self.layers[*id].nodes_storage().find_edge(self.vid, dst)?; - Some(EdgeRef::new_outgoing(eid.into(), self.vid.into(), dst.into()).at_layer(*id)) + Some(EdgeRef::new_outgoing(eid, self.vid, dst).at_layer(*id)) } LayerIds::Multiple(ids) => match ids.len() { 0 => None, @@ -280,7 +280,7 @@ impl<'a> NodeStorageOps<'a> for ArrowNode<'a> { .nodes_storage() .find_edge(self.vid, dst)?; Some( - EdgeRef::new_outgoing(eid.into(), self.vid.into(), dst.into()) + EdgeRef::new_outgoing(eid, self.vid, dst) .at_layer(layer), ) } diff --git a/raphtory/src/arrow/storage_interface/nodes_ref.rs b/raphtory/src/arrow/storage_interface/nodes_ref.rs index 6a21f6e7b9..a2f9c5d20e 100644 --- a/raphtory/src/arrow/storage_interface/nodes_ref.rs +++ b/raphtory/src/arrow/storage_interface/nodes_ref.rs @@ -17,7 +17,7 @@ impl<'a> ArrowNodesRef<'a> { Self { num_nodes: graph.num_nodes(), properties: graph.node_properties(), - layers: &graph.arc_layers(), + layers: graph.arc_layers(), } } diff --git a/raphtory/src/core/entities/mod.rs b/raphtory/src/core/entities/mod.rs index 1deb0e08cc..0f9e73d165 100644 --- a/raphtory/src/core/entities/mod.rs +++ b/raphtory/src/core/entities/mod.rs @@ -93,7 +93,6 @@ impl LayerIds { let all_layer_ids: Vec = graph .unique_layers() .map(|name| graph.get_layer_id(name.as_ref()).unwrap()) - .into_iter() .filter(|id| !other.contains(id)) .collect(); match all_layer_ids.len() { diff --git a/raphtory/src/core/mod.rs b/raphtory/src/core/mod.rs index b2615f4a1b..c0dc043d36 100644 --- a/raphtory/src/core/mod.rs +++ b/raphtory/src/core/mod.rs @@ -397,7 +397,7 @@ impl Prop { Prop::U32(v) => Some(*v as f64), Prop::U64(v) => Some(*v as f64), Prop::F32(v) => Some(*v as f64), - Prop::F64(v) => Some(*v as f64), + Prop::F64(v) => Some(*v), _ => None, } } diff --git a/raphtory/src/core/storage/lazy_vec.rs b/raphtory/src/core/storage/lazy_vec.rs index 92def963be..f422c84642 100644 --- a/raphtory/src/core/storage/lazy_vec.rs +++ b/raphtory/src/core/storage/lazy_vec.rs @@ -157,9 +157,15 @@ mod lazy_vec_tests { }); assert_eq!(vec.get(5), Some(&100)); - vec.update(6, |n| Ok(*n += 1)); + vec.update(6, |n| { + *n += 1; + Ok(()) + }); assert_eq!(vec.get(6), Some(&1)); - vec.update(9, |n| Ok(*n += 1)); + vec.update(9, |n| { + *n += 1; + Ok(()) + }); assert_eq!(vec.get(9), Some(&1)); assert_eq!(vec.filled_ids().collect_vec(), vec![1, 5, 6, 8, 9]); diff --git a/raphtory/src/core/storage/timeindex.rs b/raphtory/src/core/storage/timeindex.rs index 006bd844f6..1347fbfc1c 100644 --- a/raphtory/src/core/storage/timeindex.rs +++ b/raphtory/src/core/storage/timeindex.rs @@ -348,7 +348,7 @@ impl TimeIndexOps for TimeIndex { fn active(&self, w: Range) -> bool { match &self { TimeIndex::Empty => false, - TimeIndex::One(t) => w.contains(&t), + TimeIndex::One(t) => w.contains(t), TimeIndex::Set(ts) => ts.range(w).next().is_some(), } } @@ -357,7 +357,7 @@ impl TimeIndexOps for TimeIndex { match &self { TimeIndex::Empty => TimeIndexWindow::Empty, TimeIndex::One(t) => { - if w.contains(&t) { + if w.contains(t) { TimeIndexWindow::All(self) } else { TimeIndexWindow::Empty diff --git a/raphtory/src/db/api/mutation/property_addition_ops.rs b/raphtory/src/db/api/mutation/property_addition_ops.rs index 9c26585270..a973d61f25 100644 --- a/raphtory/src/db/api/mutation/property_addition_ops.rs +++ b/raphtory/src/db/api/mutation/property_addition_ops.rs @@ -1,6 +1,5 @@ use crate::{ core::{ - storage::timeindex::TimeIndexEntry, utils::{errors::GraphError, time::TryIntoTime}, }, db::api::mutation::{ diff --git a/raphtory/src/db/api/storage/edges/edge_entry.rs b/raphtory/src/db/api/storage/edges/edge_entry.rs index bcff48c750..915b9f1950 100644 --- a/raphtory/src/db/api/storage/edges/edge_entry.rs +++ b/raphtory/src/db/api/storage/edges/edge_entry.rs @@ -130,7 +130,7 @@ impl<'a, 'b: 'a> EdgeStorageOps<'a> for &'a EdgeStorageEntry<'b> { self, layer_id: usize, prop_id: usize, - ) -> impl TPropOps<'a> + Send + Sync + 'a { + ) -> impl TPropOps<'a> + Sync + 'a { self.as_ref().temporal_prop_layer(layer_id, prop_id) } diff --git a/raphtory/src/db/api/storage/edges/edge_owned_entry.rs b/raphtory/src/db/api/storage/edges/edge_owned_entry.rs index 8fed0474f9..ed0f633074 100644 --- a/raphtory/src/db/api/storage/edges/edge_owned_entry.rs +++ b/raphtory/src/db/api/storage/edges/edge_owned_entry.rs @@ -152,7 +152,7 @@ impl<'a> EdgeStorageOps<'a> for &'a EdgeOwnedEntry { self, layer_id: usize, prop_id: usize, - ) -> impl TPropOps<'a> + Send + Sync + 'a { + ) -> impl TPropOps<'a> + Sync + 'a { self.as_ref().temporal_prop_layer(layer_id, prop_id) } diff --git a/raphtory/src/db/api/storage/edges/edge_ref.rs b/raphtory/src/db/api/storage/edges/edge_ref.rs index 9f41af75b2..458ad998df 100644 --- a/raphtory/src/db/api/storage/edges/edge_ref.rs +++ b/raphtory/src/db/api/storage/edges/edge_ref.rs @@ -57,7 +57,7 @@ impl<'a> EdgeStorageRef<'a> { match self { EdgeStorageRef::Mem(e) => e.eid, #[cfg(feature = "arrow")] - EdgeStorageRef::Arrow(e) => e.eid().into(), + EdgeStorageRef::Arrow(e) => e.eid(), } } } @@ -156,7 +156,7 @@ impl<'a> EdgeStorageOps<'a> for EdgeStorageRef<'a> { self, layer_id: usize, prop_id: usize, - ) -> impl TPropOps<'a> + Send + Sync + 'a { + ) -> impl TPropOps<'a> + Sync + 'a { for_all_iter!(self, edge => edge.temporal_prop_layer(layer_id, prop_id)) } } diff --git a/raphtory/src/db/api/storage/edges/edge_storage_ops.rs b/raphtory/src/db/api/storage/edges/edge_storage_ops.rs index fd1e5fb26e..f81cf148e0 100644 --- a/raphtory/src/db/api/storage/edges/edge_storage_ops.rs +++ b/raphtory/src/db/api/storage/edges/edge_storage_ops.rs @@ -44,7 +44,7 @@ impl<'a> TimeIndexOps for TimeIndexRef<'a> { fn active(&self, w: Range) -> bool { match self { - TimeIndexRef::Ref(ref t) => t.active(w), + TimeIndexRef::Ref(t) => t.active(w), TimeIndexRef::Range(ref t) => t.active(w), #[cfg(feature = "arrow")] TimeIndexRef::External(ref t) => t.active(w), @@ -216,7 +216,7 @@ pub trait EdgeStorageOps<'a>: Copy + Sized + Send + Sync + 'a { self, layer_id: usize, prop_id: usize, - ) -> impl TPropOps<'a> + Send + Sync + 'a; + ) -> impl TPropOps<'a> + Sync + 'a; fn temporal_prop_iter( self, diff --git a/raphtory/src/db/api/view/edge.rs b/raphtory/src/db/api/view/edge.rs index b3ac6eb398..2da1b63438 100644 --- a/raphtory/src/db/api/view/edge.rs +++ b/raphtory/src/db/api/view/edge.rs @@ -382,7 +382,7 @@ mod test_edge_view { let test_dir = TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G, expected_prop_values: &[i32]) { let prop_values: Vec<_> = graph @@ -459,7 +459,7 @@ mod test_edge_view { let test_dir = TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let mut exploded_edges: Vec<_> = graph.edges().explode().iter().collect(); diff --git a/raphtory/src/db/api/view/graph.rs b/raphtory/src/db/api/view/graph.rs index 2b55c03932..b6b13b60da 100644 --- a/raphtory/src/db/api/view/graph.rs +++ b/raphtory/src/db/api/view/graph.rs @@ -569,10 +569,10 @@ mod test_materialize { fn testing_node_types() { let graph = Graph::new(); graph.add_node(0, "A", NO_PROPS, None).unwrap(); - graph.add_node(1, "B", NO_PROPS, Some(&"H")).unwrap(); + graph.add_node(1, "B", NO_PROPS, Some("H")).unwrap(); let test_dir = TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let node_a = graph.node("A").unwrap(); let node_b = graph.node("B").unwrap(); diff --git a/raphtory/src/db/graph/edge.rs b/raphtory/src/db/graph/edge.rs index e5ae56d652..a370d82c41 100644 --- a/raphtory/src/db/graph/edge.rs +++ b/raphtory/src/db/graph/edge.rs @@ -10,7 +10,7 @@ use chrono::{DateTime, Utc}; use crate::{ core::{ entities::{edges::edge_ref::EdgeRef, LayerIds, VID}, - storage::timeindex::{AsTime, TimeIndexEntry}, + storage::timeindex::{AsTime}, utils::{errors::GraphError, time::IntoTime}, ArcStr, }, @@ -449,7 +449,7 @@ mod test_edge { let test_dir = TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { assert_eq!( diff --git a/raphtory/src/db/graph/graph.rs b/raphtory/src/db/graph/graph.rs index f2eb47f048..f7231e8e2a 100644 --- a/raphtory/src/db/graph/graph.rs +++ b/raphtory/src/db/graph/graph.rs @@ -390,10 +390,10 @@ mod db_tests { let e = g.add_edge(0, "A", "B", NO_PROPS, None).unwrap(); e.add_constant_properties(vec![("aprop".to_string(), Prop::Bool(true))], None) .unwrap(); - let ee = g.add_edge(0, "A", "B", NO_PROPS, Some(&"LAYERA")).unwrap(); + let ee = g.add_edge(0, "A", "B", NO_PROPS, Some("LAYERA")).unwrap(); ee.add_constant_properties( vec![("aprop".to_string(), Prop::Bool(false))], - Some(&"LAYERA"), + Some("LAYERA"), ) .unwrap(); let json_res = g @@ -409,11 +409,11 @@ mod db_tests { assert_eq!(json_as_map.get("LAYERA"), Some(&Value::Bool(false))); assert_eq!(json_as_map.get("_default"), Some(&Value::Bool(true))); - let eee = g.add_edge(0, "A", "B", NO_PROPS, Some(&"LAYERB")).unwrap(); + let eee = g.add_edge(0, "A", "B", NO_PROPS, Some("LAYERB")).unwrap(); let v: Vec = vec![Prop::Bool(true), Prop::Bool(false), Prop::U64(0)]; eee.add_constant_properties( vec![("bprop".to_string(), Prop::List(Arc::new(v)))], - Some(&"LAYERB"), + Some("LAYERB"), ) .unwrap(); let json_res = g @@ -427,14 +427,14 @@ mod db_tests { let list_res = json_res.as_object().unwrap().get("LAYERB").unwrap(); assert_eq!(list_res.as_array().unwrap().len(), 3); - let eeee = g.add_edge(0, "A", "B", NO_PROPS, Some(&"LAYERC")).unwrap(); + let eeee = g.add_edge(0, "A", "B", NO_PROPS, Some("LAYERC")).unwrap(); let v: HashMap = HashMap::from([ (ArcStr::from("H".to_string()), Prop::Bool(false)), (ArcStr::from("Y".to_string()), Prop::U64(0)), ]); eeee.add_constant_properties( vec![("mymap".to_string(), Prop::Map(Arc::new(v)))], - Some(&"LAYERC"), + Some("LAYERC"), ) .unwrap(); let json_res = g @@ -888,7 +888,7 @@ mod db_tests { let test_dir = tempfile::TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let wg = graph.window(3, 15); @@ -1046,7 +1046,7 @@ mod db_tests { let test_dir = tempfile::TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { assert!(graph.has_edge(11, 22)); @@ -1176,7 +1176,7 @@ mod db_tests { let exploded = g.edge(1, 2).unwrap().explode(); let res = exploded .properties() - .map(|p| p.as_vec().iter().count()) + .map(|p| p.as_vec().len()) .collect_vec(); assert_eq!(res, vec![1, 1, 0]); } @@ -1364,7 +1364,7 @@ mod db_tests { let test_dir = tempfile::TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let times_of_one = graph.node(1).unwrap().history(); @@ -1476,7 +1476,7 @@ mod db_tests { let test_dir = tempfile::TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let times_of_one = graph.node(1).unwrap().history(); @@ -1618,7 +1618,7 @@ mod db_tests { ("key2".into(), Prop::I64(20)), ("key3".into(), Prop::I64(30)), ]; - let props_map = HashMap::from(data.into_iter().collect::>()); + let props_map = data.into_iter().collect::>(); let as_props: Vec<(&str, Prop)> = vec![("mylist2", Prop::Map(Arc::from(props_map)))]; g.add_constant_properties(as_props.clone()).unwrap(); @@ -1776,7 +1776,7 @@ mod db_tests { let test_dir = tempfile::TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { assert_eq!(graph.node(1).unwrap().earliest_time(), Some(1)); @@ -1805,7 +1805,7 @@ mod db_tests { let test_dir = tempfile::TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { assert_eq!(graph.nodes().id().collect::>(), vec![1, 2, 3]); @@ -1826,7 +1826,7 @@ mod db_tests { let test_dir = TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let what = graph.edges().id().collect_vec(); @@ -1848,7 +1848,7 @@ mod db_tests { let test_dir = tempfile::TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { assert!(graph.edge(1, 2).is_some()); @@ -1873,7 +1873,7 @@ mod db_tests { let test_dir = tempfile::TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let g_layers = graph.layers(vec!["layer1", "layer3"]).expect("layer"); @@ -1946,7 +1946,7 @@ mod db_tests { let test_dir = tempfile::TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let e = graph.edge(1, 2).expect("edge"); @@ -1979,7 +1979,7 @@ mod db_tests { let test_dir = tempfile::TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let g = graph.window(0, 3); @@ -2013,7 +2013,7 @@ mod db_tests { let test_dir = tempfile::TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let e = graph.edge(1, 2).expect("edge"); @@ -2051,7 +2051,7 @@ mod db_tests { let test_dir = tempfile::TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let g = graph.window(0, 3); @@ -2096,7 +2096,7 @@ mod db_tests { let test_dir = tempfile::TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let e = graph.edge(1, 2).expect("failed to get edge"); @@ -2425,7 +2425,7 @@ mod db_tests { let test_dir = TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let wl = graph.window(0, 3).layers(vec!["1", "2"]).unwrap(); @@ -2445,7 +2445,7 @@ mod db_tests { g.add_edge(0, 0, 1, NO_PROPS, None).unwrap(); let dir = tempfile::tempdir().unwrap(); let file_path = dir.path().join("abcd11"); - g.save_to_file(&file_path).unwrap(); + g.save_to_file(file_path).unwrap(); } #[test] @@ -2470,7 +2470,7 @@ mod db_tests { let test_dir = TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { assert_eq!( diff --git a/raphtory/src/db/graph/node.rs b/raphtory/src/db/graph/node.rs index d12e59edc7..da7329fe7b 100644 --- a/raphtory/src/db/graph/node.rs +++ b/raphtory/src/db/graph/node.rs @@ -3,7 +3,6 @@ use crate::{ core::{ entities::{edges::edge_ref::EdgeRef, nodes::node_ref::NodeRef, VID}, - storage::timeindex::TimeIndexEntry, utils::errors::GraphError, ArcStr, }, @@ -388,7 +387,7 @@ mod node_test { let test_dir = TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let view = graph.before(2); @@ -425,7 +424,7 @@ mod node_test { let test_dir = TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let v1 = graph.node(1).unwrap(); diff --git a/raphtory/src/db/graph/views/deletion_graph.rs b/raphtory/src/db/graph/views/deletion_graph.rs index 4760c97624..cac3cbbcaa 100644 --- a/raphtory/src/db/graph/views/deletion_graph.rs +++ b/raphtory/src/db/graph/views/deletion_graph.rs @@ -552,7 +552,7 @@ impl TimeSemantics for PersistentGraph { fn edge_is_valid_at_end(&self, e: EdgeRef, layer_ids: &LayerIds, end: i64) -> bool { let edge = self.0.core_edge(e.into()); - edge_alive_at_end(edge.as_ref(), end, &layer_ids) + edge_alive_at_end(edge.as_ref(), end, layer_ids) } #[inline] @@ -646,7 +646,7 @@ impl TimeSemantics for PersistentGraph { ) -> Vec<(i64, Prop)> { let entry = self.core_edge(e.into()); entry - .temporal_prop_iter(&layer_ids, prop_id) + .temporal_prop_iter(layer_ids, prop_id) .map(|(l, prop)| { let first_prop = prop .last_before(start.saturating_add(1)) diff --git a/raphtory/src/db/graph/views/layer_graph.rs b/raphtory/src/db/graph/views/layer_graph.rs index a4bb83f5e5..5f1bf55a03 100644 --- a/raphtory/src/db/graph/views/layer_graph.rs +++ b/raphtory/src/db/graph/views/layer_graph.rs @@ -143,7 +143,7 @@ mod test_layers { let test_dir = TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let neighbours = graph @@ -213,7 +213,7 @@ mod test_layers { let test_dir = TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let e = graph.edge(1, 2).unwrap(); diff --git a/raphtory/src/db/graph/views/node_subgraph.rs b/raphtory/src/db/graph/views/node_subgraph.rs index cfe3185d39..5b062bf6eb 100644 --- a/raphtory/src/db/graph/views/node_subgraph.rs +++ b/raphtory/src/db/graph/views/node_subgraph.rs @@ -118,7 +118,7 @@ mod subgraph_tests { let test_dir = TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let sg = graph.subgraph([1, 2]); @@ -185,7 +185,7 @@ mod subgraph_tests { let test_dir = TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let sg = graph.subgraph([1, 2]); diff --git a/raphtory/src/db/graph/views/window_graph.rs b/raphtory/src/db/graph/views/window_graph.rs index 0b5e3a4a59..9c53cf4af9 100644 --- a/raphtory/src/db/graph/views/window_graph.rs +++ b/raphtory/src/db/graph/views/window_graph.rs @@ -668,7 +668,7 @@ mod views_test { let test_dir = TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let wg = graph.window(1, 2); @@ -1146,7 +1146,7 @@ mod views_test { let test_dir = TempDir::new().unwrap(); #[cfg(feature = "arrow")] - let arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); + let _arrow_graph = graph.persist_as_arrow(test_dir.path()).unwrap(); fn test(graph: &G) { let e = graph.edge(1, 2).unwrap(); diff --git a/raphtory/src/db/task/edge/eval_edges.rs b/raphtory/src/db/task/edge/eval_edges.rs index 5021b24962..d11bd896fe 100644 --- a/raphtory/src/db/task/edge/eval_edges.rs +++ b/raphtory/src/db/task/edge/eval_edges.rs @@ -170,7 +170,7 @@ impl< let base_graph = self.edges.base_graph; EvalPathFromNode { graph: base_graph, - base_graph: base_graph, + base_graph, op: path.op, ss, node_state, diff --git a/raphtory/src/db/task/mod.rs b/raphtory/src/db/task/mod.rs index 6d7925dd9d..afb69622d4 100644 --- a/raphtory/src/db/task/mod.rs +++ b/raphtory/src/db/task/mod.rs @@ -75,7 +75,7 @@ mod task_tests { let count = state::accumulator_id::accumulators::sum::(0); - ctx.global_agg(count.clone()); + ctx.global_agg(count); let step1 = ATask::new(move |vv: &mut EvalNodeView<_, ()>| { vv.global_update(&count, 1); From 097e8e802008df49915971043c015f9f5214fc05 Mon Sep 17 00:00:00 2001 From: Fabian Murariu Date: Fri, 24 May 2024 17:19:07 +0100 Subject: [PATCH 3/8] fmt --- raphtory/src/algorithms/components/scc.rs | 10 +------- raphtory/src/arrow/graph_impl/core_ops.rs | 4 +--- .../src/arrow/graph_impl/edge_storage_ops.rs | 20 +++------------- raphtory/src/arrow/graph_impl/mod.rs | 10 ++------ .../src/arrow/graph_impl/prop_conversion.rs | 1 - raphtory/src/arrow/query/mod.rs | 9 +++----- raphtory/src/arrow/storage_interface/node.rs | 23 ++++++------------- .../db/api/mutation/property_addition_ops.rs | 4 +--- .../src/db/api/storage/edges/edge_entry.rs | 6 +---- .../db/api/storage/edges/edge_owned_entry.rs | 6 +---- raphtory/src/db/api/storage/edges/edge_ref.rs | 6 +---- .../db/api/storage/edges/edge_storage_ops.rs | 6 +---- raphtory/src/db/graph/edge.rs | 2 +- 13 files changed, 23 insertions(+), 84 deletions(-) diff --git a/raphtory/src/algorithms/components/scc.rs b/raphtory/src/algorithms/components/scc.rs index f46f423517..61bec62185 100644 --- a/raphtory/src/algorithms/components/scc.rs +++ b/raphtory/src/algorithms/components/scc.rs @@ -40,15 +40,7 @@ fn tarjan<'graph, G>( for neighbor in node.out_neighbours() { if !indices.contains_key(&neighbor.node) { - tarjan( - neighbor, - index, - stack, - indices, - lowlink, - on_stack, - result, - ); + tarjan(neighbor, index, stack, indices, lowlink, on_stack, result); lowlink.insert(node.node, lowlink[&node.node].min(lowlink[&neighbor.node])); } else if on_stack.contains(&neighbor.node) { lowlink.insert(node.node, lowlink[&node.node].min(indices[&neighbor.node])); diff --git a/raphtory/src/arrow/graph_impl/core_ops.rs b/raphtory/src/arrow/graph_impl/core_ops.rs index 33ef9ef5f1..ba032f2095 100644 --- a/raphtory/src/arrow/graph_impl/core_ops.rs +++ b/raphtory/src/arrow/graph_impl/core_ops.rs @@ -119,9 +119,7 @@ impl CoreGraphOps for ArrowGraph { match v { NodeRef::Internal(vid) => Some(vid), NodeRef::External(vid) => self.inner.find_node(&GID::U64(vid)), - NodeRef::ExternalStr(string) => self - .inner - .find_node(&GID::Str(string.into())), + NodeRef::ExternalStr(string) => self.inner.find_node(&GID::Str(string.into())), } } diff --git a/raphtory/src/arrow/graph_impl/edge_storage_ops.rs b/raphtory/src/arrow/graph_impl/edge_storage_ops.rs index a77764e4c2..21b32fbb00 100644 --- a/raphtory/src/arrow/graph_impl/edge_storage_ops.rs +++ b/raphtory/src/arrow/graph_impl/edge_storage_ops.rs @@ -16,21 +16,11 @@ use std::{iter, ops::Range}; impl<'a> EdgeStorageOps<'a> for Edge<'a> { fn in_ref(self) -> EdgeRef { - EdgeRef::new_incoming( - self.eid(), - self.src_id(), - self.dst_id(), - ) - .at_layer(self.layer_id()) + EdgeRef::new_incoming(self.eid(), self.src_id(), self.dst_id()).at_layer(self.layer_id()) } fn out_ref(self) -> EdgeRef { - EdgeRef::new_outgoing( - self.eid(), - self.src_id(), - self.dst_id(), - ) - .at_layer(self.layer_id()) + EdgeRef::new_outgoing(self.eid(), self.src_id(), self.dst_id()).at_layer(self.layer_id()) } fn active(self, layer_ids: &LayerIds, w: Range) -> bool { @@ -97,11 +87,7 @@ impl<'a> EdgeStorageOps<'a> for Edge<'a> { layer_ids.contains(&self.layer_id()) && self.has_temporal_prop_inner(prop_id) } - fn temporal_prop_layer( - self, - layer_id: usize, - prop_id: usize, - ) -> impl TPropOps<'a> + Sync + 'a { + fn temporal_prop_layer(self, layer_id: usize, prop_id: usize) -> impl TPropOps<'a> + Sync + 'a { if layer_id == self.layer_id() { self.temporal_property_field(prop_id) .and_then(|field| read_tprop_column(prop_id, field, self)) diff --git a/raphtory/src/arrow/graph_impl/mod.rs b/raphtory/src/arrow/graph_impl/mod.rs index dd27025a24..e75ebd8732 100644 --- a/raphtory/src/arrow/graph_impl/mod.rs +++ b/raphtory/src/arrow/graph_impl/mod.rs @@ -250,14 +250,8 @@ impl ArrowGraph { dst_col, time_col, }| { - ExternalEdgeList::new( - layer, - parquet_dir.as_ref(), - src_col, - dst_col, - time_col, - ) - .expect("Failed to load events") + ExternalEdgeList::new(layer, parquet_dir.as_ref(), src_col, dst_col, time_col) + .expect("Failed to load events") }, ) .collect::>(); diff --git a/raphtory/src/arrow/graph_impl/prop_conversion.rs b/raphtory/src/arrow/graph_impl/prop_conversion.rs index 6cdbd72b78..afc2a08764 100644 --- a/raphtory/src/arrow/graph_impl/prop_conversion.rs +++ b/raphtory/src/arrow/graph_impl/prop_conversion.rs @@ -221,6 +221,5 @@ pub fn schema_from_prop_meta(prop_map: &PropMapper) -> Schema { } } - Schema::from(schema) } diff --git a/raphtory/src/arrow/query/mod.rs b/raphtory/src/arrow/query/mod.rs index 421cf6a298..6d8356732b 100644 --- a/raphtory/src/arrow/query/mod.rs +++ b/raphtory/src/arrow/query/mod.rs @@ -172,8 +172,7 @@ mod test { let graph = ArrowGraph::from_graph(&g, graph_dir.path()).unwrap(); - let result = - rayon2::execute::(query, NodeSource::All, &graph, VecState::new); + let result = rayon2::execute::(query, NodeSource::All, &graph, VecState::new); assert!(result.is_ok()); let mut actual = receiver.into_iter().map(|(state, _)| state.0).collect_vec(); actual.sort(); @@ -206,8 +205,7 @@ mod test { let graph = ArrowGraph::from_graph(&g, graph_dir.path()).unwrap(); - let result = - rayon2::execute::(query, NodeSource::All, &graph, VecState::new); + let result = rayon2::execute::(query, NodeSource::All, &graph, VecState::new); assert!(result.is_ok()); let (path, vid) = receiver.recv().unwrap(); assert_eq!(vid, VID(2)); @@ -232,8 +230,7 @@ mod test { let graph = ArrowGraph::from_graph(&g, graph_dir.path()).unwrap(); - let result = - rayon2::execute::(query, NodeSource::All, &graph, VecState::new); + let result = rayon2::execute::(query, NodeSource::All, &graph, VecState::new); assert!(result.is_ok()); let mut results = receiver.into_iter().collect::>(); diff --git a/raphtory/src/arrow/storage_interface/node.rs b/raphtory/src/arrow/storage_interface/node.rs index 299205d1b0..06c95d2f9c 100644 --- a/raphtory/src/arrow/storage_interface/node.rs +++ b/raphtory/src/arrow/storage_interface/node.rs @@ -48,8 +48,7 @@ impl<'a> ArrowNode<'a> { .nodes_storage() .out_adj_list(self.vid) .map(move |(eid, dst)| { - EdgeRef::new_outgoing(eid, self.vid, dst) - .at_layer(layer_id) + EdgeRef::new_outgoing(eid, self.vid, dst).at_layer(layer_id) }) }) .kmerge_by(|e1, e2| e1.remote() <= e2.remote()), @@ -59,8 +58,7 @@ impl<'a> ArrowNode<'a> { .nodes_storage() .out_adj_list(self.vid) .map(move |(eid, dst)| { - EdgeRef::new_outgoing(eid, self.vid, dst) - .at_layer(*layer_id) + EdgeRef::new_outgoing(eid, self.vid, dst).at_layer(*layer_id) }), ), LayerIds::Multiple(ids) => LayerVariants::Multiple( @@ -70,8 +68,7 @@ impl<'a> ArrowNode<'a> { .nodes_storage() .out_adj_list(self.vid) .map(move |(eid, dst)| { - EdgeRef::new_outgoing(eid, self.vid, dst) - .at_layer(layer_id) + EdgeRef::new_outgoing(eid, self.vid, dst).at_layer(layer_id) }) }) .kmerge_by(|e1, e2| e1.remote() <= e2.remote()), @@ -91,8 +88,7 @@ impl<'a> ArrowNode<'a> { .nodes_storage() .in_adj_list(self.vid) .map(move |(eid, src)| { - EdgeRef::new_incoming(eid, src, self.vid) - .at_layer(layer_id) + EdgeRef::new_incoming(eid, src, self.vid).at_layer(layer_id) }) }) .kmerge_by(|e1, e2| e1.remote() <= e2.remote()), @@ -102,8 +98,7 @@ impl<'a> ArrowNode<'a> { .nodes_storage() .in_adj_list(self.vid) .map(move |(eid, src)| { - EdgeRef::new_incoming(eid, src, self.vid) - .at_layer(*layer_id) + EdgeRef::new_incoming(eid, src, self.vid).at_layer(*layer_id) }), ), LayerIds::Multiple(ids) => LayerVariants::Multiple( @@ -113,8 +108,7 @@ impl<'a> ArrowNode<'a> { .nodes_storage() .in_adj_list(self.vid) .map(move |(eid, src)| { - EdgeRef::new_incoming(eid, src, self.vid) - .at_layer(layer_id) + EdgeRef::new_incoming(eid, src, self.vid).at_layer(layer_id) }) }) .kmerge_by(|e1, e2| e1.remote() <= e2.remote()), @@ -279,10 +273,7 @@ impl<'a> NodeStorageOps<'a> for ArrowNode<'a> { let eid = self.layers[layer] .nodes_storage() .find_edge(self.vid, dst)?; - Some( - EdgeRef::new_outgoing(eid, self.vid, dst) - .at_layer(layer), - ) + Some(EdgeRef::new_outgoing(eid, self.vid, dst).at_layer(layer)) } _ => todo!("multtilayer edge views not implemented in arrow yet"), }, diff --git a/raphtory/src/db/api/mutation/property_addition_ops.rs b/raphtory/src/db/api/mutation/property_addition_ops.rs index a973d61f25..cd31b040dc 100644 --- a/raphtory/src/db/api/mutation/property_addition_ops.rs +++ b/raphtory/src/db/api/mutation/property_addition_ops.rs @@ -1,7 +1,5 @@ use crate::{ - core::{ - utils::{errors::GraphError, time::TryIntoTime}, - }, + core::utils::{errors::GraphError, time::TryIntoTime}, db::api::mutation::{ internal::{InternalAdditionOps, InternalPropertyAdditionOps}, TryIntoInputTime, diff --git a/raphtory/src/db/api/storage/edges/edge_entry.rs b/raphtory/src/db/api/storage/edges/edge_entry.rs index 915b9f1950..dbcd431741 100644 --- a/raphtory/src/db/api/storage/edges/edge_entry.rs +++ b/raphtory/src/db/api/storage/edges/edge_entry.rs @@ -126,11 +126,7 @@ impl<'a, 'b: 'a> EdgeStorageOps<'a> for &'a EdgeStorageEntry<'b> { self.as_ref().has_temporal_prop(layer_ids, prop_id) } - fn temporal_prop_layer( - self, - layer_id: usize, - prop_id: usize, - ) -> impl TPropOps<'a> + Sync + 'a { + fn temporal_prop_layer(self, layer_id: usize, prop_id: usize) -> impl TPropOps<'a> + Sync + 'a { self.as_ref().temporal_prop_layer(layer_id, prop_id) } diff --git a/raphtory/src/db/api/storage/edges/edge_owned_entry.rs b/raphtory/src/db/api/storage/edges/edge_owned_entry.rs index ed0f633074..f21741f420 100644 --- a/raphtory/src/db/api/storage/edges/edge_owned_entry.rs +++ b/raphtory/src/db/api/storage/edges/edge_owned_entry.rs @@ -148,11 +148,7 @@ impl<'a> EdgeStorageOps<'a> for &'a EdgeOwnedEntry { self.as_ref().has_temporal_prop(layer_ids, prop_id) } - fn temporal_prop_layer( - self, - layer_id: usize, - prop_id: usize, - ) -> impl TPropOps<'a> + Sync + 'a { + fn temporal_prop_layer(self, layer_id: usize, prop_id: usize) -> impl TPropOps<'a> + Sync + 'a { self.as_ref().temporal_prop_layer(layer_id, prop_id) } diff --git a/raphtory/src/db/api/storage/edges/edge_ref.rs b/raphtory/src/db/api/storage/edges/edge_ref.rs index 458ad998df..fed46c0f62 100644 --- a/raphtory/src/db/api/storage/edges/edge_ref.rs +++ b/raphtory/src/db/api/storage/edges/edge_ref.rs @@ -152,11 +152,7 @@ impl<'a> EdgeStorageOps<'a> for EdgeStorageRef<'a> { for_all!(self, edge => EdgeStorageOps::has_temporal_prop(edge, layer_ids, prop_id)) } - fn temporal_prop_layer( - self, - layer_id: usize, - prop_id: usize, - ) -> impl TPropOps<'a> + Sync + 'a { + fn temporal_prop_layer(self, layer_id: usize, prop_id: usize) -> impl TPropOps<'a> + Sync + 'a { for_all_iter!(self, edge => edge.temporal_prop_layer(layer_id, prop_id)) } } diff --git a/raphtory/src/db/api/storage/edges/edge_storage_ops.rs b/raphtory/src/db/api/storage/edges/edge_storage_ops.rs index f81cf148e0..599ef51cde 100644 --- a/raphtory/src/db/api/storage/edges/edge_storage_ops.rs +++ b/raphtory/src/db/api/storage/edges/edge_storage_ops.rs @@ -212,11 +212,7 @@ pub trait EdgeStorageOps<'a>: Copy + Sized + Send + Sync + 'a { .any(move |id| !self.temporal_prop_layer(id, prop_id).is_empty()) } - fn temporal_prop_layer( - self, - layer_id: usize, - prop_id: usize, - ) -> impl TPropOps<'a> + Sync + 'a; + fn temporal_prop_layer(self, layer_id: usize, prop_id: usize) -> impl TPropOps<'a> + Sync + 'a; fn temporal_prop_iter( self, diff --git a/raphtory/src/db/graph/edge.rs b/raphtory/src/db/graph/edge.rs index a370d82c41..86d3a61662 100644 --- a/raphtory/src/db/graph/edge.rs +++ b/raphtory/src/db/graph/edge.rs @@ -10,7 +10,7 @@ use chrono::{DateTime, Utc}; use crate::{ core::{ entities::{edges::edge_ref::EdgeRef, LayerIds, VID}, - storage::timeindex::{AsTime}, + storage::timeindex::AsTime, utils::{errors::GraphError, time::IntoTime}, ArcStr, }, From 5f50843ce2cfd7f0734b08c00acac9eb0c7c3ea5 Mon Sep 17 00:00:00 2001 From: Fabian Murariu Date: Fri, 24 May 2024 17:21:10 +0100 Subject: [PATCH 4/8] no raphtory-arrow --- Cargo.lock | 48 ---- raphtory-arrow/Cargo.toml | 50 +--- raphtory-arrow/src/lib.rs | 476 +------------------------------------- 3 files changed, 19 insertions(+), 555 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b8704669aa..1a89c148d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4020,31 +4020,6 @@ dependencies = [ [[package]] name = "raphtory-arrow" version = "0.8.1" -dependencies = [ - "ahash", - "bincode", - "bytemuck", - "itertools 0.12.1", - "memmap2", - "num-traits", - "once_cell", - "parking_lot", - "polars-arrow", - "polars-parquet", - "polars-utils", - "proptest", - "raphtory-api", - "rayon", - "serde", - "serde_json", - "strum 0.26.2", - "tempfile", - "thiserror", - "tracing", - "tracing-subscriber", - "tracing-test", - "twox-hash", -] [[package]] name = "raphtory-benchmark" @@ -5517,29 +5492,6 @@ dependencies = [ "tracing-log", ] -[[package]] -name = "tracing-test" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a2c0ff408fe918a94c428a3f2ad04e4afd5c95bbc08fcf868eff750c15728a4" -dependencies = [ - "lazy_static", - "tracing-core", - "tracing-subscriber", - "tracing-test-macro", -] - -[[package]] -name = "tracing-test-macro" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bc1c4f8e2e73a977812ab339d503e6feeb92700f6d07a6de4d321522d5c08" -dependencies = [ - "lazy_static", - "quote", - "syn 1.0.109", -] - [[package]] name = "triomphe" version = "0.1.11" diff --git a/raphtory-arrow/Cargo.toml b/raphtory-arrow/Cargo.toml index 36635f234f..870cf69956 100644 --- a/raphtory-arrow/Cargo.toml +++ b/raphtory-arrow/Cargo.toml @@ -1,46 +1,16 @@ [package] name = "raphtory-arrow" -version = "0.8.1" -documentation = "https://raphtory.readthedocs.io/en/latest/" -repository = "https://github.com/Raphtory/raphtory-arrow/" -license = "GPL-3.0" -readme = "README.md" -homepage = "https://github.com/Raphtory/raphtory-arrow/" -keywords = ["graph", "temporal-graph", "temporal"] -authors = ["Pometry"] -rust-version = "1.77" -edition = "2021" - -[profile.release-with-debug] -inherits = "release" -debug = true - +version.workspace = true +documentation.workspace = true +repository.workspace = true +license.workspace = true +readme.workspace = true +homepage.workspace = true +keywords.workspace = true +authors.workspace = true +rust-version.workspace = true +edition.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -raphtory-api = { path = "../raphtory-api", version = "0.8.1" } -ahash = { version = "0.8", features = ["serde"] } -bincode = "1.3.3" -bytemuck = "1.16.0" -itertools = "0.12.1" -memmap2 = "0.9.4" -num-traits = "0.2.19" -once_cell = "1.19.0" -parking_lot = "0.12.2" -polars-arrow = "0.39.2" -polars-parquet = { version = "0.39.2", features = ["compression"] } -polars-utils = "0.39.2" -rayon = "1.10.0" -serde = "1.0.201" -serde_json = "1.0.117" -strum = { version = "0.26.2", features = ["derive"] } -tempfile = "3.10.1" -thiserror = "1.0.60" -tracing = "0.1.40" -tracing-subscriber = "0.3.18" -twox-hash = "1.6.3" - -[dev-dependencies] -proptest = "1.4.0" -tracing-test = "0.2.4" diff --git a/raphtory-arrow/src/lib.rs b/raphtory-arrow/src/lib.rs index 415877292b..7d12d9af81 100644 --- a/raphtory-arrow/src/lib.rs +++ b/raphtory-arrow/src/lib.rs @@ -1,472 +1,14 @@ -use std::{ - borrow::Cow, - num::TryFromIntError, - ops::Range, - path::{Path, PathBuf}, -}; - -use crate::arrow2::{ - array::{Array, StructArray}, - compute::concatenate::concatenate, - datatypes::{ArrowDataType as DataType, ArrowSchema as Schema, Field}, -}; -use itertools::Itertools; -use num_traits::ToPrimitive; -use polars_arrow::record_batch::RecordBatch; -use serde::{Deserialize, Serialize}; - -use crate::{ - arrow2::legacy::error, - load::parquet_reader::{NumRows, TrySlice}, -}; - -pub mod algorithms; -pub mod arrow_hmap; -pub mod chunked_array; -pub mod edge; -pub mod edges; -pub mod global_order; -pub mod graph; -pub mod graph_builder; -pub mod graph_fragment; -pub mod interop; -pub mod load; -pub mod nodes; -pub mod properties; -pub mod timestamps; -pub mod tprops; - -mod compute; - -pub type Time = i64; - -pub mod prelude { - pub use super::chunked_array::array_ops::*; -} - -#[derive(thiserror::Error, Debug)] -pub enum RAError { - #[error("Failed to memory map file {file:?}, source: {source}")] - MMap { - file: PathBuf, - source: error::PolarsError, - }, - #[error("Arrow error: {0}")] - Arrow(#[from] error::PolarsError), - #[error("IO error: {0}")] - IO(#[from] std::io::Error), - //serde error - #[error("Serde error: {0}")] - Serde(#[from] serde_json::Error), - #[error("Bad data type for node column: {0:?}")] - DType(DataType), - #[error("Graph directory is not empty before loading")] - GraphDirNotEmpty, - #[error("Invalid type for column: {0}")] - InvalidTypeColumn(String), - #[error("Column not found: {0}")] - ColumnNotFound(String), - #[error("No Edge lists found in input path")] - NoEdgeLists, - #[error("Unable to open graph: {0:?}")] - EmptyGraphDir(PathBuf), - #[error("Empty parquet chunk")] - EmptyChunk, - #[error("Conversion error: {0}")] - ArgumentError(#[from] TryFromIntError), - #[error("Invalid file: {0:?}")] - InvalidFile(PathBuf), - #[error("Invalid metadata: {0:?}")] - MetadataError(#[from] Box), - #[error("Failed to cast mmap_mut to [i64]: {0:?}")] - SliceCastError(bytemuck::PodCastError), - #[error("Failed to cast array")] - TypeCastError, - #[error("Missing chunk {0}")] - MissingChunk(usize), -} - -const TIME_COLUMN: &str = "rap_time"; -const TIME_COLUMN_IDX: usize = 0; - -pub(crate) const V_COLUMN: &str = "v"; -pub(crate) const E_COLUMN: &str = "e"; - -#[inline] -pub fn adj_schema() -> DataType { - DataType::Struct(vec![ - Field::new(V_COLUMN, DataType::UInt64, false), - Field::new(E_COLUMN, DataType::UInt64, false), - ]) -} - -pub(crate) mod file_prefix { - use std::{ - path::{Path, PathBuf}, - str::FromStr, - }; - - use itertools::Itertools; - use strum::{AsRefStr, EnumString}; - - use super::RAError; - - #[derive(AsRefStr, EnumString, PartialEq, Debug, Ord, PartialOrd, Eq, Copy, Clone)] - pub enum GraphPaths { - NodeAdditions, - NodeAdditionsOffsets, - NodeTProps, - NodeTPropsTimestamps, - NodeTPropsSecondaryIndex, - NodeTPropsOffsets, - NodeConstProps, - AdjOutSrcs, - AdjOutDsts, - AdjOutOffsets, - EdgeTPropsOffsets, - EdgeTProps, - AdjInSrcs, - AdjInEdges, - AdjInOffsets, - Metadata, - HashMap, - } - - #[derive(Debug, PartialEq, Ord, PartialOrd, Eq, Copy, Clone)] - pub struct GraphFile { - pub prefix: GraphPaths, - pub chunk: usize, - } - - impl GraphFile { - pub fn try_from_path(path: impl AsRef) -> Option { - let name = path.as_ref().file_stem()?.to_str()?; - let mut name_parts = name.split('-'); - let prefix = GraphPaths::from_str(name_parts.next()?).ok()?; - let chunk_str = name_parts.next(); - let chunk: usize = chunk_str?.parse().ok()?; - Some(Self { prefix, chunk }) - } - } - - impl GraphPaths { - pub fn try_from(path: impl AsRef) -> Option { - let path = path.as_ref(); - let name = path.file_name().and_then(|name| name.to_str())?; - let prefix = name.split('-').next()?; - GraphPaths::from_str(prefix).ok() - } - - pub fn to_path(&self, location_path: impl AsRef, id: usize) -> PathBuf { - let prefix: &str = self.as_ref(); - make_path(location_path, prefix, id) - } - } - - pub fn make_path(location_path: impl AsRef, prefix: &str, id: usize) -> PathBuf { - let file_path = location_path - .as_ref() - .join(format!("{}-{:08}.ipc", prefix, id)); - file_path - } - - pub fn sorted_file_list( - dir: impl AsRef, - prefix: GraphPaths, - ) -> Result, RAError> { - let mut files = dir - .as_ref() - .read_dir()? - .filter_map_ok(|f| { - let path = f.path(); - GraphFile::try_from_path(&path) - .filter(|f| f.prefix == prefix) - .map(|f| (f.chunk, path)) - }) - .collect::, _>>()?; - files.sort(); - for (i, (chunk, _)) in files.iter().enumerate() { - if &i != chunk { - return Err(RAError::MissingChunk(i)); - } - } - Ok(files.into_iter().map(|(_, path)| path)) - } -} - -#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)] -pub enum GID { - U64(u64), - I64(i64), - Str(String), -} - -impl GID { - pub fn into_str(self) -> Option { - match self { - GID::Str(v) => Some(v), - _ => None, - } - } - - pub fn into_i64(self) -> Option { - match self { - GID::I64(v) => Some(v), - _ => None, - } - } - - pub fn into_u64(self) -> Option { - match self { - GID::U64(v) => Some(v), - _ => None, - } - } - - pub fn as_str(&self) -> Option<&str> { - match self { - GID::Str(v) => Some(v.as_str()), - _ => None, - } - } - - pub fn as_i64(&self) -> Option { - match self { - GID::I64(v) => Some(*v), - _ => None, - } - } - - pub fn as_u64(&self) -> Option { - match self { - GID::U64(v) => Some(*v), - _ => None, - } - } - - pub fn to_str(&self) -> Cow { - match self { - GID::U64(v) => Cow::Owned(v.to_string()), - GID::I64(v) => Cow::Owned(v.to_string()), - GID::Str(v) => Cow::Borrowed(v), - } - } - - pub fn to_i64(&self) -> Option { - match self { - GID::U64(v) => v.to_i64(), - GID::I64(v) => Some(*v), - GID::Str(v) => parse_u64_strict(v)?.to_i64(), - } - } - - pub fn to_u64(&self) -> Option { - match self { - GID::U64(v) => Some(*v), - GID::I64(v) => v.to_u64(), - GID::Str(v) => parse_u64_strict(v), - } - } -} - -const MAX_U64_BYTES: [u8; 20] = [ - 49, 56, 52, 52, 54, 55, 52, 52, 48, 55, 51, 55, 48, 57, 53, 53, 49, 54, 49, 53, -]; - -pub fn parse_u64_strict(input: &str) -> Option { - if input.len() > 20 { - // a u64 string has at most 20 bytes - return None; - } - let byte_0 = b'0'; - let byte_1 = b'1'; - let byte_9 = b'9'; - let mut input_iter = input.bytes(); - let first = input_iter.next()?; - if first == byte_0 { - return input_iter.next().is_none().then_some(0); - } - if input.len() == 20 && (byte_1..=MAX_U64_BYTES[0]).contains(&first) { - let mut result = (first - byte_0) as u64; - for (next_byte, max_byte) in input_iter.zip(MAX_U64_BYTES[1..].iter().copied()) { - if !(byte_0..=max_byte).contains(&next_byte) { - return None; - } - result = result * 10 + (next_byte - byte_0) as u64; - } - return Some(result); - } - if (byte_1..=byte_9).contains(&first) { - let mut result = (first - byte_0) as u64; - for next_byte in input_iter { - if !(byte_0..=byte_9).contains(&next_byte) { - return None; - } - result = result * 10 + (next_byte - byte_0) as u64; - } - return Some(result); - } - - None -} - -impl From for GID { - fn from(id: u64) -> Self { - Self::U64(id) - } -} - -impl From for GID { - fn from(id: i64) -> Self { - Self::I64(id) - } -} - -impl From for GID { - fn from(id: String) -> Self { - Self::Str(id) - } -} - -impl From<&str> for GID { - fn from(id: &str) -> Self { - Self::Str(id.to_string()) - } -} - -#[derive(Debug, Clone)] -pub(crate) struct GraphChunk { - srcs: Box, - dsts: Box, -} - -impl GraphChunk { - pub fn to_chunk(&self) -> RecordBatch> { - RecordBatch::new(vec![self.srcs.clone(), self.dsts.clone()]) - } -} - -#[derive(Debug, Clone)] -pub(crate) struct PropsChunk(pub StructArray); - -impl NumRows for &PropsChunk { - fn num_rows(&self) -> usize { - self.0.len() - } -} - -impl TrySlice for &PropsChunk { - fn try_slice(&self, range: Range) -> Result { - self.0.try_slice(range) - } -} - -pub fn concat(arrays: Vec) -> Result { - let mut refs: Vec<&dyn Array> = Vec::with_capacity(arrays.len()); - for array in arrays.iter() { - refs.push(array); - } - Ok(concatenate(&refs)? - .as_any() - .downcast_ref::() - .unwrap() - .clone()) -} - -pub(crate) fn split_struct_chunk( - chunk: StructArray, - src_col_idx: usize, - dst_col_idx: usize, - time_col_idx: usize, -) -> (GraphChunk, PropsChunk) { - let (fields, cols, _) = chunk.into_data(); - split_chunk( - cols.to_vec(), - src_col_idx, - dst_col_idx, - time_col_idx, - fields.into(), - ) -} - -pub(crate) fn split_chunk>>( - columns_in_chunk: I, - src_col_idx: usize, - dst_col_idx: usize, - time_col_idx: usize, - chunk_schema: Schema, -) -> (GraphChunk, PropsChunk) { - let all_cols = columns_in_chunk.into_iter().collect_vec(); - - let time_d_type = all_cols[time_col_idx].data_type().clone(); - assert_eq!(time_d_type, DataType::Int64, "time column must be i64"); - let first_len = all_cols.first().unwrap().len(); - if all_cols.iter().any(|arr| arr.len() != first_len) { - panic!("All arrays in a chunk must have the same length"); - } - - let mut temporal_props = vec![all_cols[time_col_idx].clone()]; - for (i, column) in all_cols.iter().enumerate() { - if !(i == src_col_idx || i == dst_col_idx || i == time_col_idx) { - temporal_props.push(column.clone()); - } - } - - let mut props_only_schema = - chunk_schema.filter(|i, _| !(i == src_col_idx || i == dst_col_idx || i == time_col_idx)); - // put time as the first column in the struct - props_only_schema - .fields - .insert(0, Field::new(TIME_COLUMN, time_d_type, false)); - let data_type = DataType::Struct(props_only_schema.fields); - let t_prop_cols = StructArray::new(data_type, temporal_props, None); - - ( - GraphChunk { - srcs: all_cols[src_col_idx].clone(), - dsts: all_cols[dst_col_idx].clone(), - // time: all_cols[time_col_idx].clone(), - }, - PropsChunk(t_prop_cols), - ) +pub fn add(left: usize, right: usize) -> usize { + left + right } -fn prepare_graph_dir>(graph_dir: P) -> Result<(), RAError> { - // create graph dir if it does not exist - // if it exists make sure it's empty - std::fs::create_dir_all(&graph_dir)?; +#[cfg(test)] +mod tests { + use super::*; - let mut dir_iter = std::fs::read_dir(&graph_dir)?; - if dir_iter.next().is_some() { - return Err(RAError::GraphDirNotEmpty); + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); } - - Ok(()) } -pub mod utils { - - use std::hash::{Hash, Hasher}; - use twox_hash::XxHash64; - - use crate::GID; - - pub fn calculate_hash(t: &T) -> u64 { - let mut s = XxHash64::default(); - t.hash(&mut s); - s.finish() - } - - pub fn calculate_hash_spark(gid: &GID) -> i64 { - let mut s = XxHash64::with_seed(42); - match gid { - GID::U64(x) => s.write_u64(*x), - GID::I64(x) => s.write_i64(*x), - GID::Str(t) => { - t.chars().for_each(|c| s.write_u8(c as u8)); - } - } - s.finish() as i64 - } -} - -pub use polars_arrow as arrow2; From 88623133493699283422c6dbac7eb8f715e4f1a5 Mon Sep 17 00:00:00 2001 From: Fabian Murariu Date: Fri, 24 May 2024 17:22:19 +0100 Subject: [PATCH 5/8] no default features --- raphtory-arrow/src/lib.rs | 14 -------------- raphtory/Cargo.toml | 2 +- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/raphtory-arrow/src/lib.rs b/raphtory-arrow/src/lib.rs index 7d12d9af81..e69de29bb2 100644 --- a/raphtory-arrow/src/lib.rs +++ b/raphtory-arrow/src/lib.rs @@ -1,14 +0,0 @@ -pub fn add(left: usize, right: usize) -> usize { - left + right -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} diff --git a/raphtory/Cargo.toml b/raphtory/Cargo.toml index cf61f0fe7b..c2aab2e7fd 100644 --- a/raphtory/Cargo.toml +++ b/raphtory/Cargo.toml @@ -89,7 +89,7 @@ streaming-stats = { workspace = true } proptest = { workspace = true } [features] -default = ["arrow"] +default = [] # Enables the graph loader io module io = [ "dep:zip", From d6f888c678602c9bc246a50d48cf36727a3efa3e Mon Sep 17 00:00:00 2001 From: Fabian Murariu Date: Fri, 24 May 2024 17:24:27 +0100 Subject: [PATCH 6/8] no changes to ra --- raphtory-arrow/Cargo.toml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/raphtory-arrow/Cargo.toml b/raphtory-arrow/Cargo.toml index 870cf69956..3d9a59067a 100644 --- a/raphtory-arrow/Cargo.toml +++ b/raphtory-arrow/Cargo.toml @@ -1,16 +1,3 @@ [package] name = "raphtory-arrow" -version.workspace = true -documentation.workspace = true -repository.workspace = true -license.workspace = true -readme.workspace = true -homepage.workspace = true -keywords.workspace = true -authors.workspace = true -rust-version.workspace = true -edition.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] +version = "0.8.1" \ No newline at end of file From d00114b157559e860e9a4f3c58a6a88d519a42ba Mon Sep 17 00:00:00 2001 From: Fabian Murariu Date: Fri, 24 May 2024 17:28:37 +0100 Subject: [PATCH 7/8] more fmt --- raphtory-arrow/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/raphtory-arrow/src/lib.rs b/raphtory-arrow/src/lib.rs index e69de29bb2..8b13789179 100644 --- a/raphtory-arrow/src/lib.rs +++ b/raphtory-arrow/src/lib.rs @@ -0,0 +1 @@ + From 597be1a47b2655b2a345785fe3ac1211617cd5ae Mon Sep 17 00:00:00 2001 From: Fabian Murariu Date: Fri, 24 May 2024 20:56:36 +0100 Subject: [PATCH 8/8] add raphtory-api to publish as well --- .github/workflows/_release_rust.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/_release_rust.yml b/.github/workflows/_release_rust.yml index a05fcdceb9..48e37003c3 100644 --- a/.github/workflows/_release_rust.yml +++ b/.github/workflows/_release_rust.yml @@ -54,6 +54,12 @@ jobs: with: command: install args: cargo-release --force + - name: "Publish raphtory-api to crates.io" + if: ${{ !inputs.dry_run }} + uses: actions-rs/cargo@v1 + with: + command: publish + args: --token ${{ secrets.CRATES_TOKEN }} --package raphtory-api --allow-dirty - name: "Publish raphtory-arrow to crates.io" if: ${{ !inputs.dry_run }} uses: actions-rs/cargo@v1