.groupBy(new Fields("city"))
.chainedAgg()
.aggregate(new Count(), new Fields("count"))
.aggregate(new Fields("age"), new Sum(), new Fields("age_sum"))
.chainEnd()
.each(new Fields("age_sum", "count"), new DivideAsDouble(), new Fields("mean_age"))
.each(new Fields("city", "mean_age"), new Print())
;
// What if we want to persist results of an aggregation, but want to further process these
// results? You can use "newValuesStream" for that