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

    https://github.com/apache/spark/pull/16607#discussion_r96328450
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/feature/Word2Vec.scala 
---
    @@ -320,14 +341,29 @@ object Word2VecModel extends 
MLReadable[Word2VecModel] {
         private val className = classOf[Word2VecModel].getName
     
         override def load(path: String): Word2VecModel = {
    +      val spark = sparkSession
    +      import spark.implicits._
    +
           val metadata = DefaultParamsReader.loadMetadata(path, sc, className)
    +
           val dataPath = new Path(path, "data").toString
    -      val data = sparkSession.read.parquet(dataPath)
    -        .select("wordIndex", "wordVectors")
    -        .head()
    -      val wordIndex = data.getAs[Map[String, Int]](0)
    -      val wordVectors = data.getAs[Seq[Float]](1).toArray
    -      val oldModel = new feature.Word2VecModel(wordIndex, wordVectors)
    +      val rawData = spark.read.parquet(dataPath)
    +
    +      val oldModel = if (rawData.columns.contains("wordIndex")) {
    --- End diff --
    
    I'd only ever seen ``SaveLoadV1_0`` used in MLlib, is it still the 
preferred way to mark versions? In ml land I've seen things like relying on the 
spark version:
    
https://github.com/apache/spark/blob/master/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala#L981,
 
https://github.com/apache/spark/blob/f830bb9170f6b853565d9dd30ca7418b93a54fe3/mllib/src/main/scala/org/apache/spark/ml/feature/PCA.scala#L210,
 
https://github.com/apache/spark/blob/7db09abb0168b77697064c69126ee82ca89609a0/mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala#L234
    
    which I don't really like in this case since it relies on something 
extraneous and makes it difficult to backport. 


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