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

    https://github.com/apache/spark/pull/16607#discussion_r96327379
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/feature/Word2Vec.scala 
---
    @@ -302,16 +303,36 @@ class Word2VecModel private[ml] (
     @Since("1.6.0")
     object Word2VecModel extends MLReadable[Word2VecModel] {
     
    +  private case class Data(word: String, vector: Seq[Float])
    +
       private[Word2VecModel]
       class Word2VecModelWriter(instance: Word2VecModel) extends MLWriter {
     
    -    private case class Data(wordIndex: Map[String, Int], wordVectors: 
Seq[Float])
    -
         override protected def saveImpl(path: String): Unit = {
           DefaultParamsWriter.saveMetadata(instance, path, sc)
    -      val data = Data(instance.wordVectors.wordIndex, 
instance.wordVectors.wordVectors.toSeq)
    +
    +      val wordVectors = instance.wordVectors.getVectors
    +      val dataArray = wordVectors.toSeq.map { case (word, vector) => 
Data(word, vector) }
           val dataPath = new Path(path, "data").toString
    -      
sparkSession.createDataFrame(Seq(data)).repartition(1).write.parquet(dataPath)
    +      sparkSession.createDataFrame(dataArray)
    +        .repartition(calculateNumberOfPartitions)
    +        .write
    +        .parquet(dataPath)
    +    }
    +
    +    val FloatSize = 4
    --- End diff --
    
    I was trying to follow the scala naming conventions for constants 
(http://docs.scala-lang.org/style/naming-conventions.html), which to my 
understanding state that constants should be UpperCamelCase. Coming from Java, 
I was looking for the equivalent of ``private static final float FLOAT_SIZE``. 
Happy to just use local vals if that's more idiomatic. 


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