-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-21050][ML] Word2vec persistence overflow bug fix #18265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import org.apache.spark.ml.util.TestingUtils._ | |
| import org.apache.spark.mllib.feature.{Word2VecModel => OldWord2VecModel} | ||
| import org.apache.spark.mllib.util.MLlibTestSparkContext | ||
| import org.apache.spark.sql.Row | ||
| import org.apache.spark.util.Utils | ||
|
|
||
| class Word2VecSuite extends SparkFunSuite with MLlibTestSparkContext with DefaultReadWriteTest { | ||
|
|
||
|
|
@@ -188,6 +189,15 @@ class Word2VecSuite extends SparkFunSuite with MLlibTestSparkContext with Defaul | |
| assert(math.abs(similarity(5) - similarityLarger(5) / similarity(5)) > 1E-5) | ||
| } | ||
|
|
||
| test("Word2Vec read/write numPartitions calculation") { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this test hardcode a specific
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point; I'll do that. |
||
| val smallModelNumPartitions = Word2VecModel.Word2VecModelWriter.calculateNumberOfPartitions( | ||
| Utils.byteStringAsBytes("64m"), numWords = 10, vectorSize = 5) | ||
| assert(smallModelNumPartitions === 1) | ||
| val largeModelNumPartitions = Word2VecModel.Word2VecModelWriter.calculateNumberOfPartitions( | ||
| Utils.byteStringAsBytes("64m"), numWords = 1000000, vectorSize = 5000) | ||
| assert(largeModelNumPartitions > 1) | ||
| } | ||
|
|
||
| test("Word2Vec read/write") { | ||
| val t = new Word2Vec() | ||
| .setInputCol("myInputCol") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this failure truly necessary? Can we make this a WARN and use a best-attempt (
Int.MAX?) partitions instead? The models that would fail here would be so huge that they likely took days to trainThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure it is necessary. If we cap it at Int.MAX and the user hits that cap, then it means that we'll fail when trying to write the partitions.