SPARK-3389: New public method for RDD's to have consistent way of obtain...

...ing the number of RDD partitions across languages.