Add function countByValue() and countByKey().

These two lines seem to be repeatedly used in many functions. I think we should create a public function numPartitions(rdd) that just returns this. I think its also useful for the users ? If not, we could add something to utils