Returns `None` if the data is not a valid ReplicatedEntry (e.g., ConfChange or no-op). `assigner`, when `Some`, drives follower-local surrogate binding for the variants that carry one: each insert/upsert/put re-derives its stable identity by calling `assigner.assign(collection, pk_bytes)`, which writes the binding to the local catalog and emits a `SurrogateBind` WAL record. When `None`, all surro
(
data: &[u8],
assigner: Option<&SurrogateAssigner>,
)
| 19 | /// back to `Surrogate::ZERO` (used by tests that exercise the decoder |
| 20 | /// in isolation without spinning up `SharedState`). |
| 21 | pub fn from_replicated_entry( |
| 22 | data: &[u8], |
| 23 | assigner: Option<&SurrogateAssigner>, |
| 24 | ) -> crate::Result<Option<(TenantId, VShardId, PhysicalPlan)>> { |
| 25 | let entry = match ReplicatedEntry::from_bytes(data) { |
| 26 | Some(e) => e, |
| 27 | None => return Ok(None), |
| 28 | }; |
| 29 | // Array CRDT variants are handled by the distributed applier before this |
| 30 | // function is called. Return None so the applier skips the generic dispatch |
| 31 | // path for them. |
| 32 | match &entry.write { |
| 33 | ReplicatedWrite::ArrayOp { .. } | ReplicatedWrite::ArraySchema { .. } => { |
| 34 | return Ok(None); |
| 35 | } |
| 36 | _ => {} |
| 37 | } |
| 38 | let plan = to_physical_plan(&entry.write, assigner)?; |
| 39 | Ok(Some(( |
| 40 | TenantId::new(entry.tenant_id), |
| 41 | VShardId::new(entry.vshard_id), |
| 42 | plan, |
| 43 | ))) |
| 44 | } |
| 45 | |
| 46 | fn assign_or_zero( |
| 47 | assigner: Option<&SurrogateAssigner>, |