MoonBit streaming sketches with bounded windows, metrics, validated frames, and distributed merge planning
| Area | Packages and use cases |
|---|---|
| Cardinality | hll, hllplus, linear, and window for distinct users, devices, and time windows |
| Frequency | countmin, topk, and bloom for weighted counts, heavy hitters, admission, and duplicate filtering |
| Similarity | minhash and multitenant for Jaccard-style set comparison and tenant UV |
| Distribution | stream for event-time aggregation, watermarks, routing, reordering, checkpoints, and snapshot catalogs |
| Summaries | quantile and metrics for bounded ranks, histograms, registry queries, deltas, and health exports |
| Interchange | serde for legacy sketch formats plus checksummed versioned frames and frame batches |
| Coordination | distributed for partition validation, replay protection, merge reports, and reduction traces |
moon update
moon check --target all --deny-warn
moon test --target wasm-gc --deny-warnlet sketch = @hll.HyperLogLog::new(14)
sketch.add_string("user-42")
let estimate = sketch.cardinality()
println(estimate.to_string())moon run cmd/main -- help
moon run cmd/main -- demo
moon run cmd/main -- version
moon run cmd/main -- benchmarkevent records ──> reorder buffer ──> watermark tracker ──> partition router
│
┌──────────────────────────────────────────┘
▼
StreamAggregator per shard
├─ MetricRegistry (counter/gauge/histogram/distinct)
├─ SpaceSaving heavy hitters
└─ HLL-backed window snapshots
sketches ──> validated snapshots ──> versioned serde frames ──> distributed merge plans| algorithm | input_count | estimate | tracked_items | serialized_bytes | repeat_count | elapsed_ms | throughput_events_per_second |
|---|---|---|---|---|---|---|---|
| hll | 6000 | 500 | 0 | 4010 | 3 | 150 | 40000 |
| hllplus | 6000 | 497.47172860769325 | 0 | 0 | 3 | 150 | 40000 |
| countmin | 6000 | 12 | 0 | 0 | 3 | 150 | 40000 |
| space_saving | 6000 | 6000 | 20 | 0 | 3 | 150 | 40000 |
| quantile | 6000 | 464 | 64 | 1594 | 3 | 150 | 40000 |
| histogram | 6000 | 499.5 | 5 | 126 | 3 | 150 | 40000 |
| bloom | 6000 | 0 | 2000 | 0 | 3 | 150 | 40000 |
| stream | 6000 | 482.8849676492496 | 1 | 0 | 3 | 150 | 40000 |
powershell -NoProfile -ExecutionPolicy Bypass -File tools/count-moonbit-lines.ps1moon fmt --check
moon info
moon check --target all --deny-warn
moon test --target wasm-gc --deny-warn
moon coverage analyze
git diff --exit-codemoon publish --frozenInstall
Download zipMoonBit streaming sketches with bounded windows, metrics, validated frames, and distributed merge planning