| 875 | signature = (data, time, src, dst, properties = None, metadata = None, shared_metadata = None, layer = None, layer_col = None, schema = None, csv_options = None, event_id = None) |
| 876 | )] |
| 877 | fn load_edges( |
| 878 | &self, |
| 879 | data: &Bound<PyAny>, |
| 880 | time: &str, |
| 881 | src: &str, |
| 882 | dst: &str, |
| 883 | properties: Option<Vec<PyBackedStr>>, |
| 884 | metadata: Option<Vec<PyBackedStr>>, |
| 885 | shared_metadata: Option<HashMap<String, Prop>>, |
| 886 | layer: Option<&str>, |
| 887 | layer_col: Option<&str>, |
| 888 | schema: Option<Bound<PyAny>>, |
| 889 | csv_options: Option<CsvReadOptions>, |
| 890 | event_id: Option<&str>, |
| 891 | ) -> Result<(), GraphError> { |
| 892 | let properties = convert_py_prop_args(properties.as_deref()).unwrap_or_default(); |
| 893 | let metadata = convert_py_prop_args(metadata.as_deref()).unwrap_or_default(); |
| 894 | let column_schema = convert_py_schema(schema)?; |
| 895 | if data.hasattr("__arrow_c_stream__")? { |
| 896 | load_edges_from_arrow_c_stream( |
| 897 | &self.graph, |
| 898 | data, |
| 899 | time, |
| 900 | src, |
| 901 | dst, |
| 902 | &properties, |
| 903 | &metadata, |
| 904 | shared_metadata.as_ref(), |
| 905 | layer, |
| 906 | layer_col, |
| 907 | column_schema, |
| 908 | event_id, |
| 909 | ) |
| 910 | } else if let Ok(path) = data.extract::<PathBuf>() { |
| 911 | // extracting PathBuf handles Strings too |
| 912 | let is_parquet = is_parquet_path(&path)?; |
| 913 | let is_csv = is_csv_path(&path)?; |
| 914 | |
| 915 | // fail before loading anything at all to avoid loading partial data |
| 916 | if !is_csv && csv_options.is_some() { |
| 917 | return Err(GraphError::from(PyValueError::new_err(format!( |
| 918 | "CSV options were passed but no CSV files were detected at {}.", |
| 919 | path.display() |
| 920 | )))); |
| 921 | } |
| 922 | |
| 923 | // wrap in Arc to avoid cloning the entire schema for Parquet, CSV, and inner loops in CSV path |
| 924 | let arced_schema = column_schema.map(Arc::new); |
| 925 | |
| 926 | // if-if instead of if-else to support directories with mixed parquet and CSV files |
| 927 | if is_parquet { |
| 928 | load_edges_from_parquet( |
| 929 | &self.graph, |
| 930 | &path, |
| 931 | ColumnNames::new(time, event_id, src, dst, layer_col), |
| 932 | true, |
| 933 | &properties, |
| 934 | &metadata, |