Github user feynmanliang commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8507#discussion_r38446219
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/clustering/GaussianMixtureModel.scala
 ---
    @@ -159,19 +159,25 @@ object GaussianMixtureModel extends 
Loader[GaussianMixtureModel] {
     
           // Create Parquet data.
           val dataArray = Array.tabulate(weights.length) { i =>
    -        Data(weights(i), gaussians(i).mu, gaussians(i).sigma)
    +        Row(weights(i), gaussians(i).mu, gaussians(i).sigma)
           }
    -      sc.parallelize(dataArray, 
1).toDF().write.parquet(Loader.dataPath(path))
    +      val dataRDD: RDD[Row] = sc.parallelize(dataArray, 1)
    +
    +      sqlContext.createDataFrame(dataRDD, 
schema).write.parquet(Loader.dataPath(path))
         }
    +    private val schema = StructType(
    +      StructField("weight", DoubleType, nullable = false)::
    +      StructField("mu", new VectorUDT, nullable = false)::
    +      StructField("sigma", new MatrixUDT, nullable = false)::Nil)
     
         def load(sc: SparkContext, path: String): GaussianMixtureModel = {
           val dataPath = Loader.dataPath(path)
           val sqlContext = new SQLContext(sc)
           val dataFrame = sqlContext.read.parquet(dataPath)
    -      val dataArray = dataFrame.select("weight", "mu", "sigma").collect()
    --- End diff --
    
    Good idea


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to