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-12639] Allow for zero splits in SplitAndSizeRestriction #15191
Conversation
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.
Looks good to me!
// each method will flip the corresponding flag in the passed in VetRestriction, | ||
// overwrite the restriction's Key and Val with the last seen input elements, | ||
// and retain the other fields in the VetRestriction. | ||
type VetEmptyInitialSplitSdf struct { |
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.
Style Nit: This could probably be implemented more succinctly through type embedding (kinda like inheritance, you can use all the methods of VetSdf, just changing SplitRestriction). Not worth blocking the PR on since the code works perfectly fine, just throwing it out there for future reference.
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.
That looks so convenient but was unable to get it to work since the ProcessElement method was not being found.
Code I used was:
// VetEmptyInitialSplitSdf runs an SDF in order to test that these methods get called properly,
// each method will flip the corresponding flag in the passed in VetRestriction,
// overwrite the restriction's Key and Val with the last seen input elements,
// and retain the other fields in the VetRestriction.
type VetEmptyInitialSplitSdf struct {
sdf *VetSdf `default:"{}"`
}
// SplitRestriction outputs zero restrictions.
func (fn *VetEmptyInitialSplitSdf) SplitRestriction(i int, rest *VetRestriction) []*VetRestriction {
return []*VetRestriction{}
}
Error I got was:
=== RUN TestSdfNodes
--- FAIL: TestSdfNodes (0.00s)
sdf_test.go:62: invalid function: graph.AsDoFn: for Fn named github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec.VetEmptyInitialSplitSdf
failed to find ProcessElement method
Will merge as-is. Using the type embedding seems very convenient to have.
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.
That sounds about right. The compiler does hoist embeded type methods to the parent type, but the reflect libraries don't automatically hoist methods on embedded types. We'd need to add it to the analysis to get it working. Not hard, just hasn't been required to add.
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-XXX
with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
ValidatesRunner
compliance 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.