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

Method execute_edge_put_batch

nodedb/src/data/executor/handlers/graph.rs:110–178  ·  view source on GitHub ↗

Apply a batched edge insert in a single SPSC round-trip.

(
        &mut self,
        task: &ExecutionTask,
        tid: u64,
        edges: &[nodedb_physical::physical_plan::BatchEdge],
    )

Source from the content-addressed store, hash-verified

108
109 /// Apply a batched edge insert in a single SPSC round-trip.
110 pub(in crate::data::executor) fn execute_edge_put_batch(
111 &mut self,
112 task: &ExecutionTask,
113 tid: u64,
114 edges: &[nodedb_physical::physical_plan::BatchEdge],
115 ) -> Response {
116 debug!(core = self.core_id, count = edges.len(), "edge put batch");
117 for (idx, edge) in edges.iter().enumerate() {
118 if self.is_node_deleted(tid, &edge.src_id) {
119 return self.response_error(
120 task,
121 ErrorCode::RejectedDanglingEdge {
122 missing_node: edge.src_id.clone(),
123 },
124 );
125 }
126 if self.is_node_deleted(tid, &edge.dst_id) {
127 return self.response_error(
128 task,
129 ErrorCode::RejectedDanglingEdge {
130 missing_node: edge.dst_id.clone(),
131 },
132 );
133 }
134 let ord = self.hlc.next_ordinal();
135 let valid_from_ms = nodedb_types::ordinal_to_ms(ord);
136 use crate::engine::graph::edge_store::EdgeRef;
137 match self.edge_store.put_edge_versioned(
138 EdgeRef::new(
139 TenantId::new(tid),
140 &edge.collection,
141 &edge.src_id,
142 &edge.label,
143 &edge.dst_id,
144 ),
145 &[],
146 ord,
147 valid_from_ms,
148 i64::MAX,
149 ) {
150 Ok(()) => {
151 let partition = self.csr_partition_mut(tid);
152 if let Err(e) = partition.add_edge(&edge.src_id, &edge.label, &edge.dst_id) {
153 return self.response_error(
154 task,
155 ErrorCode::Internal {
156 detail: format!("edge {idx} (label interning): {e}"),
157 },
158 );
159 }
160 partition.set_node_surrogate(&edge.src_id, edge.src_surrogate);
161 partition.set_node_surrogate(&edge.dst_id, edge.dst_surrogate);
162 }
163 Err(e) => {
164 return self.response_error(
165 task,
166 ErrorCode::Internal {
167 detail: format!("edge {idx}: {e}"),

Callers 1

dispatch_graphMethod · 0.80

Calls 14

ordinal_to_msFunction · 0.85
is_node_deletedMethod · 0.80
response_errorMethod · 0.80
next_ordinalMethod · 0.80
put_edge_versionedMethod · 0.80
csr_partition_mutMethod · 0.80
add_edgeMethod · 0.80
set_node_surrogateMethod · 0.80
mark_dirtyMethod · 0.80
response_okMethod · 0.80
iterMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected