Convert a decoded `ArrayOp` (from sync) into a `PhysicalPlan::Array` variant.
(
&self,
op: &ArrayOp,
)
| 211 | |
| 212 | /// Convert a decoded `ArrayOp` (from sync) into a `PhysicalPlan::Array` variant. |
| 213 | pub(super) fn op_to_data_plane_plan( |
| 214 | &self, |
| 215 | op: &ArrayOp, |
| 216 | ) -> Result<crate::bridge::envelope::PhysicalPlan, Option<ArrayRejectMsg>> { |
| 217 | use nodedb_array::sync::op::ArrayOpKind; |
| 218 | use nodedb_physical::physical_plan::ArrayOp as DataArrayOp; |
| 219 | |
| 220 | let array_id = nodedb_array::types::ArrayId::new(self.tenant_id(), &op.header.array); |
| 221 | |
| 222 | let data_op = match op.kind { |
| 223 | ArrayOpKind::Put => { |
| 224 | let cells = vec![crate::engine::array::wal::ArrayPutCell { |
| 225 | coord: op.coord.clone(), |
| 226 | attrs: op.attrs.clone().unwrap_or_default(), |
| 227 | surrogate: nodedb_types::Surrogate::ZERO, |
| 228 | system_from_ms: op.header.system_from_ms, |
| 229 | valid_from_ms: op.header.valid_from_ms, |
| 230 | valid_until_ms: op.header.valid_until_ms, |
| 231 | }]; |
| 232 | let cells_msgpack = zerompk::to_msgpack_vec(&cells).map_err(|e| { |
| 233 | Some(build_reject( |
| 234 | &op.header.array, |
| 235 | op.header.hlc, |
| 236 | ArrayRejectReason::ShapeInvalid, |
| 237 | format!("cells encode: {e}"), |
| 238 | )) |
| 239 | })?; |
| 240 | DataArrayOp::Put { |
| 241 | array_id, |
| 242 | cells_msgpack, |
| 243 | wal_lsn: 0, |
| 244 | } |
| 245 | } |
| 246 | ArrayOpKind::Delete | ArrayOpKind::Erase => { |
| 247 | let coords = vec![op.coord.clone()]; |
| 248 | let coords_msgpack = zerompk::to_msgpack_vec(&coords).map_err(|e| { |
| 249 | Some(build_reject( |
| 250 | &op.header.array, |
| 251 | op.header.hlc, |
| 252 | ArrayRejectReason::ShapeInvalid, |
| 253 | format!("coords encode: {e}"), |
| 254 | )) |
| 255 | })?; |
| 256 | DataArrayOp::Delete { |
| 257 | array_id, |
| 258 | coords_msgpack, |
| 259 | wal_lsn: 0, |
| 260 | } |
| 261 | } |
| 262 | }; |
| 263 | |
| 264 | Ok(crate::bridge::envelope::PhysicalPlan::Array(data_op)) |
| 265 | } |
| 266 | } |
no test coverage detected