MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / execute_graph_algo

Method execute_graph_algo

nodedb/src/data/executor/handlers/graph_algo.rs:24–73  ·  view source on GitHub ↗
(
        &self,
        task: &ExecutionTask,
        tid: u64,
        algorithm: &GraphAlgorithm,
        params: &AlgoParams,
    )

Source from the content-addressed store, hash-verified

22
23impl 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 &params.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)`,

Callers 1

dispatch_graphMethod · 0.80

Calls 6

build_csr_for_collectionFunction · 0.85
run_algorithmFunction · 0.85
response_errorMethod · 0.80
response_with_payloadMethod · 0.80
node_countMethod · 0.45
to_msgpackMethod · 0.45

Tested by

no test coverage detected