'Update current mapreduce state by aggregating shard states.
Args:
mapreduce_state: current mapreduce state as MapreduceState.
shard_states: all shard states (active and inactive). list of ShardState.'

def aggregate_state(self, mapreduce_state, shard_states):

    processed_counts = []
    mapreduce_state.counters_map.clear()
    for shard_state in shard_states:
        mapreduce_state.counters_map.add_map(shard_state.counters_map)
        processed_counts.append(shard_state.counters_map.get(context.COUNTER_MAPPER_CALLS))
    mapreduce_state.set_processed_counts(processed_counts)
