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

    https://github.com/apache/spark/pull/13149#discussion_r63598420
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala 
---
    @@ -206,11 +212,21 @@ object KMeansModel extends MLReadable[KMeansModel] {
           import sqlContext.implicits._
     
           val metadata = DefaultParamsReader.loadMetadata(path, sc, className)
    -
           val dataPath = new Path(path, "data").toString
    -      val data: Dataset[Data] = sqlContext.read.parquet(dataPath).as[Data]
    -      val clusterCenters = 
data.collect().sortBy(_.clusterIdx).map(_.clusterCenter)
    -      val model = new KMeansModel(metadata.uid, new 
MLlibKMeansModel(clusterCenters))
    +
    +      val versionRegex = "([0-9]+)\\.(.+)".r
    +      val versionRegex(major, _) = metadata.sparkVersion
    +
    +      val model = if (major.toInt >= 2) {
    +        val data: Dataset[Data] = 
sqlContext.read.parquet(dataPath).as[Data]
    +        val clusterCenters = 
data.collect().sortBy(_.clusterIdx).map(_.clusterCenter)
    +        new KMeansModel(metadata.uid, new MLlibKMeansModel(clusterCenters))
    --- End diff --
    
    Factor this line out to avoid duplication


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to