scala编译出来的class可以用反射区调用。比如scala代码如下
private def updateWeightsAndGaussians(
mean: BDV[Double],
sigma: BreezeMatrix[Double],
weight: Double,
sumWeights: Double): (Double, MultivariateGaussian) = {
val mu = (mean /= weight)
BLAS.syr(-weight, Vectors.fromBreeze(mu),
Matrices.fromBreeze(sigma).asInstanceOf[DenseMatrix])
val newWeight = weight / sumWeights
val newGaussian = new MultivariateGaussian(mu, sigma / weight)
(newWeight, newGaussian)
}
我们可以用下面的代码调用
Method method = GaussianMixture.class.getDeclaredMethod( "org$apache$spark$mllib$clustering$GaussianMixture$$updateWeightsAndGaussians", DenseVector.class, DenseMatrix.class,double.class,double.class );
method.setAccessible( true );
GaussianMixture