[SPARK-59152][ML] Create CountVectorizer broadcast per transform - #58452
Closed
zhengruifeng wants to merge 3 commits into
Closed
[SPARK-59152][ML] Create CountVectorizer broadcast per transform#58452zhengruifeng wants to merge 3 commits into
zhengruifeng wants to merge 3 commits into
Conversation
HyukjinKwon
approved these changes
Sep 1, 2026
Contributor
Author
|
Merge Summary:
Posted by |
zhengruifeng
added a commit
that referenced
this pull request
Sep 2, 2026
### What changes were proposed in this pull request? This PR creates the `CountVectorizerModel` dictionary and its broadcast for each `transform` call instead of caching the broadcast on the model. ### Why are the changes needed? The dictionary broadcast is transformation-only execution state. Retaining it on the model keeps the broadcast alive for the model's lifetime and ties later transformations to the `SparkContext` used by the first transformation. A transform-scoped broadcast follows the lifecycle of the returned lazy DataFrame. This is consistent with the other explicit inference broadcasts in `org.apache.spark.ml`: `Word2VecModel` broadcasts its word-vector model per transform, while `RandomForestRegressionModel` and `GBTRegressionModel` broadcast their models per transform and share each broadcast between the output UDFs created by that transform. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? No tests were added because this is an internal broadcast lifecycle change and the transformation logic is unchanged. The patch was checked with `git diff --check` and source line-length and non-ASCII scans. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: OpenAI Codex (GPT-5) Closes #58452 from zhengruifeng/ml-countvectorizer-transform-broadcast-dev-5. Authored-by: Ruifeng Zheng <ruifengz@apache.org> Signed-off-by: Ruifeng Zheng <ruifengz@foxmail.com> (cherry picked from commit 0653977) Signed-off-by: Ruifeng Zheng <ruifengz@foxmail.com>
Contributor
Author
|
Merge Summary:
Posted by |
zhengruifeng
deleted the
ml-countvectorizer-transform-broadcast-dev-5
branch
September 2, 2026 00:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR creates the
CountVectorizerModeldictionary and its broadcast for eachtransformcallinstead of caching the broadcast on the model.
Why are the changes needed?
The dictionary broadcast is transformation-only execution state. Retaining it on the model keeps the
broadcast alive for the model's lifetime and ties later transformations to the
SparkContextused bythe first transformation. A transform-scoped broadcast follows the lifecycle of the returned lazy
DataFrame. This is consistent with the other explicit inference broadcasts in
org.apache.spark.ml:Word2VecModelbroadcasts its word-vector model per transform, whileRandomForestRegressionModelandGBTRegressionModelbroadcast their models per transform andshare each broadcast between the output UDFs created by that transform.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
No tests were added because this is an internal broadcast lifecycle change and the transformation
logic is unchanged. The patch was checked with
git diff --checkand source line-length andnon-ASCII scans.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex (GPT-5)