(
&self,
task: &ExecutionTask,
tid: u64,
algorithm: &GraphAlgorithm,
params: &AlgoParams,
)
| 22 | |
| 23 | impl CoreLoop { |
| 24 | pub(in crate::data::executor) fn execute_graph_algo( |
| 25 | &self, |
| 26 | task: &ExecutionTask, |
| 27 | tid: u64, |
| 28 | algorithm: &GraphAlgorithm, |
| 29 | params: &AlgoParams, |
| 30 | ) -> Response { |
| 31 | debug!( |
| 32 | core = self.core_id, |
| 33 | tid, |
| 34 | algorithm = algorithm.name(), |
| 35 | collection = %params.collection, |
| 36 | edge_label = ?params.edge_label, |
| 37 | "graph algorithm dispatch" |
| 38 | ); |
| 39 | |
| 40 | if *algorithm == GraphAlgorithm::Sssp && params.source_node.is_none() { |
| 41 | return self.response_error( |
| 42 | task, |
| 43 | ErrorCode::Internal { |
| 44 | detail: "SSSP requires FROM '<source_node>'".into(), |
| 45 | }, |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | let scoped_csr = match build_csr_for_collection( |
| 50 | &self.edge_store, |
| 51 | tid, |
| 52 | ¶ms.collection, |
| 53 | params.edge_label.as_deref(), |
| 54 | None, |
| 55 | ) { |
| 56 | Ok(c) => c, |
| 57 | Err(e) => return self.response_error(task, ErrorCode::from(e)), |
| 58 | }; |
| 59 | |
| 60 | if scoped_csr.node_count() == 0 { |
| 61 | return match AlgoResultBatch::new(*algorithm).to_msgpack() { |
| 62 | Ok(payload) => self.response_with_payload(task, payload), |
| 63 | Err(e) => self.response_error(task, ErrorCode::from(e)), |
| 64 | }; |
| 65 | } |
| 66 | |
| 67 | run_algorithm(&scoped_csr, algorithm, params, &self.graph_tuning) |
| 68 | .and_then(|batch| batch.to_msgpack()) |
| 69 | .map_or_else( |
| 70 | |e| self.response_error(task, ErrorCode::from(e)), |
| 71 | |payload| self.response_with_payload(task, payload), |
| 72 | ) |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | /// Build a `CsrIndex` containing only the edges for a specific `(tid, collection)`, |
no test coverage detected