-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[Go SDK]: Add fileio MatchFiles, MatchAll and ReadMatches transforms #25809
Conversation
R: @lostluck |
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control |
Codecov Report
@@ Coverage Diff @@
## master #25809 +/- ##
========================================
Coverage 71.42% 71.43%
========================================
Files 779 783 +4
Lines 102635 102852 +217
========================================
+ Hits 73308 73469 +161
- Misses 27867 27911 +44
- Partials 1460 1472 +12
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
This is great! Thank you! I love that this entirely avoids solving the question of "what type are we reading out?". This
The big counter argument to my suggestion in how options are treated is that enums are trivially serializable, while other approach isn't necessarily trivial to serialize. However, a user who really needs to serialize these things can always manage that process themselves.
Remember, types themselves don't need to be exported to be serialized, only their Fields, so this shouldn't affect using unexported enums for configuring readFn
or matchFn
.
416df16
to
6c1b337
Compare
s = s.Scope("fileio.MatchAll") | ||
|
||
option := &matchOption{ | ||
EmptyTreatment: emptyAllowIfWildcard, |
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.
I haven't provided any option functions for setting what is already the default value, i.e. there is no MatchEmptyAllowIfWildcard()
, because it doesn't make much sense? Unless it should be included for clarity/documentation purposes?
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.
Better to have one for the default if only to explain that it's the default.
Also in complex situations, it might get set multiple times in the list of options, so having the default enables setting it back into the default if desired.
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.
Okay, fixed now. Feel free to merge if approved
6c1b337
to
256ae9c
Compare
} | ||
|
||
// newGzipReader creates a new gzipReader from an io.ReadCloser. | ||
func newGzipReader(rc io.ReadCloser) (*gzipReader, error) { |
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.
I think longer term when if add additional compression formats, we'd want to do something similar to how the Filesystems are set up, so users don't need to have all possible compressions linked in.
I think it's fine to have Gzip built in by default as it's most common, but if we build in support for more, it should be made modular, and hooked into the "auto" support.
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.
Thank you very much!
I think I'm a touch surprised that neither of these are Splittable DoFns. I'd expect Match to be able to "sub element split on it's input globs to allow downstream processing of the files to ultimately be split down to each file (if not within the file itself), since we know/can find the size and so forth, to begin to make decent splitting decisions.
But I think we can leave this as is for the moment, since it took me a week longer than desired to get to this review, and this is still a net good that other file based IOs in the SDK can start to build with.
Hmm I don't see clearly how the incoming glob element in matchFn should be split into restriction pairs. Only after the List operation do we know how many output elements there are per input element. I guess we could create an initial offsetrange.Restriction based on the total count of files that match the glob pattern from a List invocation, then split that into sub-ranges. The downside is that this would impose additional API calls for the same List operation in ProcessElement and require sorting of the list result to determine which files fall under the current restriction. I'm curious to hear what would be your suggestion for how to implement the Match transform with an SDF? As I saw it, the matchFn essentially serves the same purpose as expandFn currently does in textio/avroio/parquetio, plus attaches the size. I was thinking that those IOs could potentially be refactored to make use of the fileio Match and Read tranforms to reduce repetition if we want that. At least textio which would utilize both the file handle and the size from a ReadableFile. |
Fixes #25779 and adds the fileio transforms
MatchFiles
,MatchAll
andReadMatches
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123
), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>
instead.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI.