Skip to content

Commit 08dd3d5

Browse files
committed
Correct docs
1 parent f2c71fc commit 08dd3d5

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

docs/windowing.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ sdf = (
578578
# Expected output (when session expires):
579579
# {
580580
# "start": 1000,
581-
# "end": 2000000 + 1800000, # last event + timeout
581+
# "end": 2000000, # timestamp of last event
582582
# "action_count": 4,
583583
# "actions": ["page_view", "click", "page_view", "purchase"]
584584
# }
@@ -588,6 +588,13 @@ sdf = (
588588

589589
For real-time monitoring, you can use `.current()` mode to get updates as the session progresses:
590590

591+
Input:
592+
```json
593+
{"amount": 25, "timestamp": 1000}
594+
{"amount": 50, "timestamp": 5000}
595+
{"amount": 50, "timestamp": 8000}
596+
```
597+
591598
```python
592599
from datetime import timedelta
593600
from quixstreams import Application
@@ -611,9 +618,9 @@ sdf = (
611618
)
612619

613620
# Output for each incoming event:
614-
# Event 1: {"start": 1000, "end": 11000, "total_amount": 25, "purchase_count": 1}
615-
# Event 2: {"start": 1000, "end": 15000, "total_amount": 75, "purchase_count": 2} # session extended
616-
# Event 3: {"start": 1000, "end": 18000, "total_amount": 125, "purchase_count": 3} # session extended again
621+
# Event 1: {"start": 1000, "end": 1000, "total_amount": 25, "purchase_count": 1}
622+
# Event 2: {"start": 1000, "end": 5000, "total_amount": 75, "purchase_count": 2}
623+
# Event 3: {"start": 1000, "end": 8000, "total_amount": 125, "purchase_count": 3}
617624
```
618625

619626
### Handling Late Events in Sessions
@@ -710,7 +717,9 @@ sdf = (
710717

711718
**Session Extension**: An existing session is extended when an event arrives within `timeout + grace_period` of the session's last activity.
712719

713-
**Session Closure**: A session closes when the current time exceeds `session_end_time + grace_period`, where `session_end_time = last_event_time + timeout`.
720+
**Session Closure**: A session closes when the current time exceeds `last_event_time + timeout + grace_period`. The session end time in the output represents the timestamp of the last event in the session.
721+
722+
**Out-of-Order Events**: When out-of-order events arrive within the grace period, they extend the session but do not change the end time if they are older than the current latest event. The end time always represents the timestamp of the chronologically latest event in the session.
714723

715724
**Key Grouping**: Like all windows in Quix Streams, sessions are grouped by message key. Each key maintains its own independent sessions.
716725

0 commit comments

Comments
 (0)