![ci](https://github.com/uwheel/uwheel/actions/workflows/rust.yml/badge.svg) [![Cargo](https://img.shields.io/badge/crates.io-v0.2.1-orange)](https://crates.io/crates/uwheel) [![Documentation](https://docs.rs/uwheel/badge.svg)](https://docs.rs/uwheel) [![unsafe forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance/) [![Discord](https://img.shields.io/discord/1245309039940993085?label=µWheel%20discord)](https://discord.gg/dhRxfck9jN) [![Apache](https://img.shields.io/badge/license-Apache-blue.svg)](https://github.com/uwheel/uwheel/blob/main/LICENSE-APACHE) [![MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/uwheel/uwheel/blob/main/LICENSE-MIT) # µWheel µWheel is an Embeddable Aggregate Management System for Streams and Queries. See more about its design [here](DESIGN.md) and try it out directly on the [web](https://uwheel.github.io/uwheel/). ## Features - Streaming window aggregation - Built-in warehousing capabilities - Wheel-based query optimizer + vectorized execution. - Out-of-order support using ``low watermarking``. - High-throughput stream ingestion. - User-defined aggregation. - Low space footprint. - Incremental checkpointing support. - Compatible with ``#[no_std]`` (requires ``alloc``). ## When should I use µWheel? µWheel unifies the aggregate management for online streaming and offline analytical queries in a single system. µWheel is not a general purpose solution but a specialized system tailored for a pre-defined aggregation function. µWheel is an execellent choice when: - You know the aggregation function apriori. - You need high-throughput ingestion of out-of-order streams. - You need support for streaming window queries (e.g., Sliding/Tumbling). - You need support for exploratory analysis of historical data. - You need a lightweight and highly embeddable solution. **Example use cases:** - A mini stream processor ([see example](examples/window)) - A real-time OLAP index (e.g., Top-N) ([see example](examples/top-n)) - A compact and mergeable system for analytics at the edge ([see example](examples/aggregator)). ## Pre-defined Aggregators | Function | Description | Types | SIMD | | ---- | ------| ----- |----- | | SUM | Sum of all inputs | u16, u32, u64, i16, i32, i64, f32, f64 | ✓ | | MIN | Minimum value of all inputs | u16, u32, u64, i32, i16, i64, f32, f64 | ✓| | MAX | Maximum value of all inputs | u16, u32, u64, i16, i32, i64, f32, f64 | ✓| | MINMAX | Minimum and Maximum value of all inputs | u16, u32, u64, i16, i32, i64, f32, f64 | ✗| | AVG | Arithmetic mean of all inputs | u16, u32, u64, i16, i32, i64, f32, f64 | ✗ | | ALL | Pre-computed SUM, AVG, MIN, MAX, COUNT | f64 | ✗| | TOP N | Top N of all inputs | ``Aggregator`` with aggregate data that implements ``Ord`` | ✗| See a user-defined aggregator example [here](examples/aggregator/). ## Feature Flags - `std` (_enabled by default_) - Enables features that rely on the standard library - `sum` (_enabled by default_) - Enables sum aggregation - `avg` (_enabled by default_) - Enables avg aggregation - `min` (_enabled by default_) - Enables min aggregation - `max` (_enabled by default_) - Enables max aggregation - `min_max` (_enabled by default_) - Enables min-max aggregation - `all` (_enabled by default_) - Enables all aggregation - `top_n` - Enables Top-N aggregation - `simd` (_requires `nightly`_) - Enables support to speed up aggregation functions with SIMD operations - `sync` (_implicitly enables `std`_) - Enables a sync version of ``ReaderWheel`` that can be shared and queried across threads - `profiler` (_implicitly enables `std`_) - Enables recording of latencies for various operations - `serde` - Enables serde support - `timer` - Enables scheduling user-defined functions ## Usage For ``std`` support and compilation of built-in aggregators: ```toml uwheel = "0.2.1" ``` For ``no_std`` support and minimal compile time: ```toml uwheel = { version = "0.2.1", default-features = false } ``` ## Examples The following code is from the [hello world](examples/hello_world) example. ```rust use uwheel::{aggregator::sum::U32SumAggregator, WheelRange, NumericalDuration, Entry, RwWheel}; // Initial start watermark 2023-11-09 00:00:00 (represented as milliseconds) let mut watermark = 1699488000000; // Create a Reader-Writer Wheel with U32 Sum Aggregation using the default configuration let mut wheel: RwWheel