Remove a document's geometry from the per-field R-tree and the sparse document store on behalf of a Lite client. Keyed by the same hex-encoded surrogate used at insert time. A delete of a non-existent surrogate is a no-op (idempotent). Fails fast if the sparse store delete returns an error (other than "not found", which the sparse engine surfaces as `Ok`).
(
&mut self,
task: &ExecutionTask,
tid: u64,
collection: &str,
field: &str,
surrogate: Surrogate,
)
| 150 | /// Fails fast if the sparse store delete returns an error (other than |
| 151 | /// "not found", which the sparse engine surfaces as `Ok`). |
| 152 | pub(in crate::data::executor) fn execute_spatial_delete( |
| 153 | &mut self, |
| 154 | task: &ExecutionTask, |
| 155 | tid: u64, |
| 156 | collection: &str, |
| 157 | field: &str, |
| 158 | surrogate: Surrogate, |
| 159 | ) -> Response { |
| 160 | let doc_id = surrogate_to_doc_id(surrogate); |
| 161 | |
| 162 | debug!( |
| 163 | core = self.core_id, |
| 164 | %collection, |
| 165 | %field, |
| 166 | doc_id = %doc_id, |
| 167 | surrogate = surrogate.as_u32(), |
| 168 | "spatial sync: delete geometry" |
| 169 | ); |
| 170 | |
| 171 | if let Err(e) = self.sparse.delete(tid, collection, &doc_id) { |
| 172 | error!( |
| 173 | core = self.core_id, |
| 174 | %collection, |
| 175 | doc_id = %doc_id, |
| 176 | error = %e, |
| 177 | "spatial sync: sparse document delete failed" |
| 178 | ); |
| 179 | return self.response_error(task, e); |
| 180 | } |
| 181 | |
| 182 | let tenant_id = TenantId::new(tid); |
| 183 | let spatial_key = (tenant_id, collection.to_string(), field.to_string()); |
| 184 | let entry_id = fnv1a_hash(doc_id.as_bytes()); |
| 185 | let doc_map_key = ( |
| 186 | tenant_id, |
| 187 | collection.to_string(), |
| 188 | field.to_string(), |
| 189 | entry_id, |
| 190 | ); |
| 191 | |
| 192 | if let Some(rtree) = self.spatial_indexes.get_mut(&spatial_key) { |
| 193 | rtree.delete(entry_id); |
| 194 | } |
| 195 | self.spatial_doc_map.remove(&doc_map_key); |
| 196 | |
| 197 | self.response_ok(task) |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | /// Convert a `Geometry` into a `nodedb_types::Value` for msgpack serialisation. |
no test coverage detected