-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[BEAM-5097] Increment counter for "small words" in go SDK example #15399
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
[BEAM-5097] Increment counter for "small words" in go SDK example #15399
Conversation
|
R: @lostluck |
|
Run Go PostCommit |
lostluck
left a comment
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.
Approved after the small changes are made. Thanks for your patience!
|
|
||
| func (f *extractFn) ProcessElement(row WordRow, emit func(string, string)) { | ||
| func (f *extractFn) ProcessElement(ctx context.Context, row WordRow, emit func(string, string)) { | ||
|
|
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.
nit: rm spare line
| lineLen = beam.NewDistribution("extract", "lineLenDistro") | ||
| wordRE = regexp.MustCompile(`[a-zA-Z]+('[a-z])?`) | ||
| empty = beam.NewCounter("extract", "emptyLines") | ||
| minLength = flag.Int("min_length", 9, "Minimum word length") |
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.
Since this is a new flag, and this example doesn't filter words, we might want to just call it "small_word_length" instead, and clarify that it determines what gets counted.
|
Run Go PostCommit |
| for _, word := range wordRE.FindAllString(line, -1) { | ||
| // increment the counter for small words if length of words is | ||
| // less than small_word_length | ||
| if len(word) < *small_word_length { |
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.
Flags aren't available on workers. They'd only have their default values. extractFn needs to change to a structural DoFn (like it is in the other example being updated) so the flag functions properly.
lostluck
left a comment
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.
LGTM I'll merge this. Thanks!
Added counter to Go SDK examples for small words.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username).[BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replaceBEAM-XXXwith the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
ValidatesRunnercompliance status (on master branch)Examples testing status on various runners
Post-Commit SDK/Transform Integration Tests Status (on master branch)
Pre-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI.