1

I started working with spark, specifically with mllib library. several of the functions are limited in scope and private statements. How can I use these functions in my code? Example: KMeans.scala

private[mllib] def pointCost(
      centers: TraversableOnce[BreezeVectorWithNorm],
      point: BreezeVectorWithNorm): Double =
    findClosest(centers, point)._2

If I make a class that extends kmeans and try to use this function appears I can not access it. The following error is shown:

error: method MethodInClassKMeans in class KMeans cannot be accessed in myClass

Can anyone give me any examples of how to get around this? Thanks and regards

zero323
  • 322,348
  • 103
  • 959
  • 935
Gilberto
  • 11
  • 1

1 Answers1

1

If you use the same namespace as the class you want to use, you can access private[package] members.

But there is probably a good reason why these methods are package private: the method might be gone with the next point release.

So if there is something small and isolated you need, just copy the code to your project if the license permits it.

RĂ¼diger Klaehn
  • 12,445
  • 3
  • 41
  • 57