| Algorithm 1. Stateful Complex Event Matching in GICEDCAM. |
|
Input: stream of spatial events e = ⟨type, bindings, t, conf, corrected⟩ window W, watermark ω State: partial matches M[q] keyed by (q, bindings) upon spatial event e at time t: // events are pre-filtered & projected // 1) advance existing partials for each (q, b) in M where δ(q, e.type, b, t) is enabled q′ ← δ(q, e.type, b, t) // checks Allen relation & gap constraints b′ ← unify(b, e.bindings) // variable binding; reject on conflict upsert M[q′] with {bindings = b′, start_time(b), last_time = t} // 2) possibly start a new partial if δ(q0, e.type, e.bindings, t) enabled upsert M[q1] with {bindings = e.bindings, start_time = t, last_time = t} // 3) emit completes when safe for each partial in M with state q ∈ F if (last_time − start_time) ≤ W and last_time ≤ ω emit ComplexEvent(partial.bindings, [start_time, last_time]) delete partial // 4) prune stale partials (semantic bound) delete any partial with (current_time − start_time) > W |