Instead of making this a private method and having the 2nd argument here, why don't you just remove the 2nd argument, and make this public? (You can then remove the other compute method). This also applies to the computePCA version that takes RDD.