oxirs_stream/window/joins/mod.rs
1//! Watermark-driven window joins.
2//!
3//! Three join semantics are implemented:
4//!
5//! 1. [`tumbling_tumbling::TumblingTumblingJoin`] — both sides use the same
6//! fixed tumbling window; only events whose timestamps fall in the same
7//! window pane are considered for joining. Closure: when the watermark
8//! advances past `pane_end + allowed_lateness_ms`.
9//!
10//! 2. [`tumbling_sliding::TumblingSlidingJoin`] — the *left* stream uses
11//! tumbling windows; the *right* stream uses sliding windows. An event
12//! on either side is considered against every active right-pane that
13//! overlaps with its tumbling pane.
14//!
15//! 3. [`session_session::SessionSessionJoin`] — both sides use session
16//! windows defined by an inactivity gap. Two events join when their
17//! sessions overlap (at least one event timestamp from each side falls
18//! within the union session).
19//!
20//! All three implementations share:
21//!
22//! * Per-stream key extraction via a closure (`F: Fn(&L) -> K`).
23//! * Deterministic state cleanup driven by an externally supplied watermark.
24//! * Configurable allowed lateness measured in milliseconds.
25//! * Statistics ([`WindowJoinStats`]) tracking emitted / dropped / late
26//! events.
27//!
28//! Refer to `docs/engine_overview.md` for the watermark/window/join contract.
29
30pub mod session_session;
31pub mod tumbling_sliding;
32pub mod tumbling_tumbling;
33
34pub use session_session::{SessionSessionJoin, SessionSessionJoinConfig};
35pub use tumbling_sliding::{TumblingSlidingJoin, TumblingSlidingJoinConfig};
36pub use tumbling_tumbling::{TumblingTumblingJoin, TumblingTumblingJoinConfig};
37
38// ─── Shared types ────────────────────────────────────────────────────────────
39
40/// Join key extracted from each event.
41pub type WindowJoinKey = String;
42
43/// A successful join result.
44#[derive(Debug, Clone, PartialEq)]
45pub struct WindowJoinResult<L, R> {
46 pub key: WindowJoinKey,
47 pub left: L,
48 pub right: R,
49 /// Pane end (or session end) at which this join is emitted.
50 pub pane_end_ms: i64,
51}
52
53/// Per-join statistics.
54#[derive(Debug, Clone, Default, PartialEq, Eq)]
55pub struct WindowJoinStats {
56 pub left_events: u64,
57 pub right_events: u64,
58 pub joined_pairs: u64,
59 pub late_events_dropped: u64,
60 pub windows_closed: u64,
61}