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

    https://github.com/apache/spark/pull/5450#discussion_r28267250
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/clustering/PowerIterationClustering.scala
 ---
    @@ -38,7 +43,63 @@ import org.apache.spark.util.random.XORShiftRandom
     @Experimental
     class PowerIterationClusteringModel(
         val k: Int,
    -    val assignments: RDD[PowerIterationClustering.Assignment]) extends 
Serializable
    +    val assignments: RDD[PowerIterationClustering.Assignment]) extends 
Saveable with Serializable {
    +
    +  override def save(sc: SparkContext, path: String): Unit = {
    +    PowerIterationClusteringModel.SaveLoadV1_0.save(sc, this, path)
    +  }
    +
    +  override protected def formatVersion: String = "1.0"
    +}
    +
    +object PowerIterationClusteringModel extends 
Loader[PowerIterationClusteringModel] {
    +  override def load(sc: SparkContext, path: String): 
PowerIterationClusteringModel = {
    +    PowerIterationClusteringModel.SaveLoadV1_0.load(sc, path)
    +  }
    +
    +  private[clustering]
    +  object SaveLoadV1_0 {
    +
    +    private val thisFormatVersion = "1.0"
    +
    +    private[clustering]
    +    val thisClassName = 
"org.apache.spark.mllib.clustering.PowerIterationClusteringModel"
    +
    +    def save(sc: SparkContext, model: PowerIterationClusteringModel, path: 
String): Unit = {
    +      val sqlContext = new SQLContext(sc)
    +      import sqlContext.implicits._
    +
    +      val metadata = compact(render(
    +        ("class" -> thisClassName) ~ ("version" -> thisFormatVersion) ~ 
("k" -> model.k)))
    +      sc.parallelize(Seq(metadata), 
1).saveAsTextFile(Loader.metadataPath(path))
    +
    +      val dataRDD = model.assignments.map(x => (x.id, x.cluster)).toDF()
    --- End diff --
    
    That's okay. In general, the issue with case classes is that they are hard 
to extend. For example, changing `case class Assignment(id: Long, cluster: 
Int)` to `case class Assignment(id: Long, cluster: Int, confidence: Double)` 
breaks binary compatibility.


---
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