code generator for count aggregator