Calculating histograms using MapReduce