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.
Hmm, just a general thought here. There are two ways to implement aggregators. First, let them be classes that implement all the aggregation which means we have to replicate for example sum and count for different aggregators. Second, let the aggregate operator do the aggregation work and use flags to control which computations are actually needed. We chose the latter. Are there any other reasons for one or the other implementation?