Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 如何在代码中使用私有函数[mllib]?_Scala_Apache Spark_Cluster Analysis_Private_Apache Spark Mllib - Fatal编程技术网

Scala 如何在代码中使用私有函数[mllib]?

Scala 如何在代码中使用私有函数[mllib]?,scala,apache-spark,cluster-analysis,private,apache-spark-mllib,Scala,Apache Spark,Cluster Analysis,Private,Apache Spark Mllib,我开始使用spark,特别是mllib库。一些函数在范围和私有语句中受到限制。如何在代码中使用这些函数? 例子: 斯卡拉角豆 private[mllib] def pointCost( centers: TraversableOnce[BreezeVectorWithNorm], point: BreezeVectorWithNorm): Double = findClosest(centers, point)._2 如果我创建了一个扩展kmeans的类并尝试使

我开始使用spark,特别是mllib库。一些函数在范围和私有语句中受到限制。如何在代码中使用这些函数? 例子: 斯卡拉角豆

private[mllib] def pointCost(
      centers: TraversableOnce[BreezeVectorWithNorm],
      point: BreezeVectorWithNorm): Double =
    findClosest(centers, point)._2
如果我创建了一个扩展kmeans的类并尝试使用这个函数,那么我将无法访问它。显示以下错误:

error: method MethodInClassKMeans in class KMeans cannot be accessed in myClass
有谁能给我举一些例子来说明如何避开这个问题吗?
感谢并问候

如果您使用与要使用的类相同的名称空间,您可以访问私有[package]成员

但是这些方法之所以是包私有的,可能有一个很好的原因:该方法可能会在下一次发布时消失

因此,如果您需要一些小而孤立的代码,只要在许可证允许的情况下将代码复制到您的项目中即可