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

Function from_replicated_entry

nodedb/src/control/wal_replication/decode.rs:21–44  ·  view source on GitHub ↗

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>,
)

Source from the content-addressed store, hash-verified

19/// back to `Surrogate::ZERO` (used by tests that exercise the decoder
20/// in isolation without spinning up `SharedState`).
21pub 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
46fn assign_or_zero(
47 assigner: Option<&SurrogateAssigner>,

Callers 3

run_apply_loopFunction · 0.85

Calls 1

to_physical_planFunction · 0.85