.stateQuery(nameToAge, new Fields("actor"), new MapGet(), new Fields("age"))
.each(new Fields("actor","location","age"), new Print())
.groupBy(new Fields("location"))
.chainedAgg()
.aggregate(new Count(), new Fields("count"))
.aggregate(new Fields("age"), new Sum(), new Fields("sum"))
.chainEnd()
.each(new Fields("sum", "count"), new DivideAsDouble(), new Fields("avg"))
.project(new Fields("location", "count", "avg"))
;