Example 1
Input
WindowJoiner 3
push_a x 10 5
push_a y 20 1
push_b x 12 7
push_b y 30 9Output
null
null
null
nullImplement WindowJoiner, a time-windowed joiner between two event streams. Events are matched by key and timestamp proximity, with strict correctness rules.
This mirrors real streaming/analytics components and emphasizes state management, policy decisions, and temporal reasoning.
Each A event has:
keyt (timestamp)a_valEach B event has:
keyt (timestamp)b_valabs(tA - tB) <= WWhen multiple join candidates exist for the incoming event:
Once matched, both events become consumed and cannot be used again.
current_time as the maximum timestamp observed so far across both streams.t < current_time - W can no longer be matched and must be evicted.WindowJoiner(W)W.push_a(key, t, a_val)null.push_b(key, t, b_val)null.Each joined result must contain the key and both events’ timestamps and values:
key, tA, a_val, tB, b_valIf you output joined results, they should be represented consecutively and space-separated per result.
WindowJoiner 3
push_a x 10 5
push_a y 20 1
push_b x 12 7
push_b y 30 9null
null
null
nullWindowJoiner 10
push_b x 14 3
push_b x 11 2
push_a x 10 1null
null
x 10 1 11 2