User defined aggregates

Review after #594 

@domoritz , you are probably the best reviewer if you have time. UserDefinedAggregator is essentially a fork of StatefulApply, except that the emitters only trigger at EOS and the emitters are not allowed to use the input tuples.
As far as I understand, this interface only supports adding values to the aggregator. Does that mean that support for aggregation of aggregators (for example sum of sums) has to be generated by the optimizer?