Github user feynmanliang commented on a diff in the pull request:
https://github.com/apache/spark/pull/8233#discussion_r37817174
--- Diff: mllib/src/main/scala/org/apache/spark/ml/feature/Word2Vec.scala
---
@@ -194,16 +197,19 @@ class Word2VecModel private[ml] (
*/
override def transform(dataset: DataFrame): DataFrame = {
transformSchema(dataset.schema, logging = true)
- val bWordVectors =
dataset.sqlContext.sparkContext.broadcast(wordVectors)
+ bcWordVectors match {
+ case None => bcWordVectors =
Some(dataset.sqlContext.sparkContext.broadcast(wordVectors))
+ case _ =>
+ }
val word2Vec = udf { sentence: Seq[String] =>
--- End diff --
Create a local variable here (e.g. `val localBcWordVectors =
bcWordVectors`) and use on L209. The current code expands to `val model =
this.bcWordVectors.get...` which means that closure capture will serialize
`this` (the current object) with the task.
---
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]