Skip to content

Add support for session window #917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

petrpan26
Copy link
Contributor

Session Windows Implementation for Quix Streams

This PR introduces Session Windows - dynamic windowing that groups events by activity sessions rather than fixed time intervals.

Key Features

  • Activity-driven sessions: Sessions extend automatically when events arrive within timeout period
  • Flexible configuration: Configurable timeout and grace periods for late events
  • Full aggregation support: Works with all existing aggregation functions (sum, count, mean, max, min, reduce, collect)
  • Both modes supported: .current() for real-time updates, .final() for complete sessions
  • Closing strategies: Both "key" and "partition" level session expiration

Usage Examples

# User session tracking (30min timeout, 5min grace)
sdf.session_window(timeout_ms=timedelta(minutes=30), grace_ms=timedelta(minutes=5)) \
   .agg(page_views=Count(), actions=Collect("action_type")) \
   .final()

# Real-time fraud detection
sdf.session_window(timeout_ms=timedelta(minutes=10)) \
   .agg(transaction_count=Count(), total_amount=Sum("amount")) \
   .current()

Use Cases Enabled

  • User activity tracking (web/app sessions)
  • Fraud detection (transaction patterns)
  • IoT device monitoring (activity sessions)
  • Gaming analytics (player sessions)

Testing & Documentation

  • 32 comprehensive tests covering all session window functionality
  • Complete documentation added to docs/windowing.md with examples
  • Session merging scenarios and edge cases tested
  • Multi-key session management validated

Technical Implementation

  • Smart session extension logic with grace period support
  • Efficient RocksDB-backed state management
  • Proper transaction handling for concurrent access
  • Memory-efficient session garbage collection

This enables sophisticated streaming analytics use cases that were previously difficult to implement with fixed-time windows.

@petrpan26 petrpan26 force-pushed the petrpan26/session-window branch from d2b4108 to a8b14a2 Compare June 3, 2025 15:38
@petrpan26 petrpan26 force-pushed the petrpan26/session-window branch from a8b14a2 to 07ac02a Compare June 3, 2025 15:41
Copy link
Contributor

@gwaramadze gwaramadze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello. Once again, thanks for your contributions. Here is the first batch of comments. Please take a look. We will continue to review and test it.

@gwaramadze
Copy link
Contributor

Closing this PR as it was superseded by #994

@gwaramadze gwaramadze closed this Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants