aegis-timeseries
Time series engine for the Aegis Database Platform.
Overview
aegis-timeseries provides specialized storage and query capabilities for time-stamped data. It features Gorilla compression, time-based partitioning, automatic retention policies, and efficient aggregation functions.
Features
- Gorilla Compression - Facebook's algorithm for floating-point time series
- Time Partitioning - Automatic partition management by time range
- Retention Policies - Automatic data expiration
- Downsampling - Configurable data rollup
- Aggregations - Sum, mean, min, max, percentiles, and more
Architecture
┌─────────────────────────────────────────────────┐
│ Time Series Engine │
├─────────────────────────────────────────────────┤
│ Query Processor │
│ ┌──────────┬──────────────┬─────────────────┐ │
│ │ Parser │ Aggregator │ Downsampler │ │
│ └──────────┴──────────────┴─────────────────┘ │
├─────────────────────────────────────────────────┤
│ Partition Manager │
│ ┌─────────┬─────────┬─────────┬─────────────┐ │
│ │ Active │ Recent │ Cold │ Archive │ │
│ │Partition│Partitions│Partitions│ │ │
│ └─────────┴─────────┴─────────┴─────────────┘ │
├─────────────────────────────────────────────────┤
│ Compression Layer │
│ (Gorilla / Delta / Dictionary) │
└─────────────────────────────────────────────────┘
Modules
| Module | Description |
|---|---|
engine |
Main time series engine |
compression |
Gorilla and delta compression |
partition |
Time-based partition management |
aggregation |
Aggregation functions |
retention |
Retention policy enforcement |
query |
Time series query execution |
index |
Time-based indexing |
types |
Time series data types |
Usage
[]
= { = "../aegis-timeseries" }
Writing Data
use ;
use Utc;
let engine = new?;
// Write a single point
engine.write?;
// Batch write
let points = vec!;
engine.write_batch?;
Querying Data
use ;
// Simple query
let results = engine.query?;
// With aggregation
let results = engine.query?;
Aggregation Functions
use AggFunc;
// Available aggregations
Sum // Sum of values
Mean // Average
Min // Minimum
Max // Maximum
Count // Count of points
First // First value in window
Last // Last value in window
StdDev // Standard deviation
Percentile // 95th percentile
Retention Policies
use ;
// Keep raw data for 7 days, then downsample
let policy = RetentionPolicy ;
engine.set_retention_policy?;
// Delete data older than 30 days
let delete_policy = RetentionPolicy ;
Downsampling
use ;
let config = DownsampleConfig ;
engine.configure_downsampling?;
Compression
Gorilla compression achieves ~12x compression ratio for typical time series data:
| Data Type | Compression Ratio |
|---|---|
| Timestamps | 1.37 bits/point |
| Float values | 0.92 bits/point (for similar values) |
| Overall | ~12x typical |
Configuration
[]
= "1d" # Partition size
= "gorilla" # gorilla, delta, none
= "64MB"
[]
= "30d"
= "1h"
[]
= true
= "0 * * * *" # Hourly
Tests
Test count: 634 tests (workspace total)
License
Apache-2.0