Apply a batched edge insert in a single SPSC round-trip.
(
&mut self,
task: &ExecutionTask,
tid: u64,
edges: &[nodedb_physical::physical_plan::BatchEdge],
)
| 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}"), |
no test coverage detected