Reference implementation for aggregation