You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "svetakvsundhar (via GitHub)" <gi...@apache.org> on 2025/07/29 18:56:18 UTC
[PR] Controlling reshuffle in `FileIO.MatchAll` [beam]
svetakvsundhar opened a new pull request, #35730:
URL: https://github.com/apache/beam/pull/35730
Fixes https://github.com/apache/beam/issues/33330
------------------------
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
- [ ] Mention the appropriate issue in your description (for example: `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, comment `fixes #<ISSUE NUMBER>` instead.
- [ ] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
[](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI or the [workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Controlling reshuffle in `FileIO.MatchAll` [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35730:
URL: https://github.com/apache/beam/pull/35730#issuecomment-3202390397
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment `assign set of reviewers`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Controlling reshuffle in `FileIO.MatchAll` [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn commented on code in PR #35730:
URL: https://github.com/apache/beam/pull/35730#discussion_r2240852518
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileIO.java:
##########
@@ -373,9 +373,11 @@ public static Match match() {
public static MatchAll matchAll() {
return new AutoValue_FileIO_MatchAll.Builder()
.setConfiguration(MatchConfiguration.create(EmptyMatchTreatment.ALLOW_IF_WILDCARD))
+ .setAvoidReshuffle(false)
Review Comment:
There are similar configs in different IOs under different names. I recommend use `withOutputParallelization` / `setOutputParallelization` (used by several IOs e.g. JdbcIO, redisIO, SinglestoreIO)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Controlling reshuffle in `FileIO.MatchAll` [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn commented on code in PR #35730:
URL: https://github.com/apache/beam/pull/35730#discussion_r2286079969
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileIO.java:
##########
@@ -674,16 +675,37 @@ public abstract static class MatchAll
@AutoValue.Builder
abstract static class Builder {
+ protected boolean outputParallelization;
+
abstract Builder setConfiguration(MatchConfiguration configuration);
abstract MatchAll build();
+
+ abstract Builder setOutputParallelization(boolean b);
}
/** Like {@link Match#withConfiguration}. */
public MatchAll withConfiguration(MatchConfiguration configuration) {
return toBuilder().setConfiguration(configuration).build();
}
+ /**
+ * Specifies to avoid the reshuffle operation.
+ *
+ * <p>This is a performance optimization for pipelines that match a small number of
+ * filepatterns.
+ *
+ * <p>By default, a {@link org.apache.beam.sdk.transforms.Reshuffle} is applied to the matched
+ * files to break fusion and improve parallelism.
+ */
+ public MatchAll outputParallelization() {
Review Comment:
Optional: As `matchAll()` returns a MatchAll with outputParallelization to true by default, Probably we do not need to introduce outputParallelization() shortcut method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Controlling reshuffle in `FileIO.MatchAll` [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn merged PR #35730:
URL: https://github.com/apache/beam/pull/35730
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Controlling reshuffle in `FileIO.MatchAll` [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn commented on code in PR #35730:
URL: https://github.com/apache/beam/pull/35730#discussion_r2286004726
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileIO.java:
##########
@@ -373,6 +373,7 @@ public static Match match() {
public static MatchAll matchAll() {
return new AutoValue_FileIO_MatchAll.Builder()
.setConfiguration(MatchConfiguration.create(EmptyMatchTreatment.ALLOW_IF_WILDCARD))
+ .setOutputParallelization(false)
Review Comment:
If OutputParallelization means adding a reshuffle, then we default to true here to keep default behavior the same
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileIO.java:
##########
@@ -723,8 +744,15 @@ public PCollection<MatchResult.Metadata> expand(PCollection<String> input) {
res = input.apply(createWatchTransform(new ExtractFilenameFn())).apply(Values.create());
}
}
- return res.apply(Reshuffle.viaRandomKey());
+ // Apply Reshuffle conditionally based on the new flag
+ if (getOutputParallelization()) {
Review Comment:
I think outputParallelization=true means adding a ReShuffle.
##########
sdks/java/io/file-based-io-tests/src/test/java/org/apache/beam/sdk/io/text/TextIOIT.java:
##########
@@ -136,7 +136,7 @@ public void writeThenReadAll() {
PCollection<String> consolidatedHashcode =
testFilenames
- .apply("Match all files", FileIO.matchAll())
+ .apply("Match all files", FileIO.matchAll().withOutputParallelization(true))
Review Comment:
We don't need to change this after default set to true
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Controlling reshuffle in `FileIO.MatchAll` [beam]
Posted by "svetakvsundhar (via GitHub)" <gi...@apache.org>.
svetakvsundhar commented on code in PR #35730:
URL: https://github.com/apache/beam/pull/35730#discussion_r2286022644
##########
sdks/java/io/file-based-io-tests/src/test/java/org/apache/beam/sdk/io/text/TextIOIT.java:
##########
@@ -136,7 +136,7 @@ public void writeThenReadAll() {
PCollection<String> consolidatedHashcode =
testFilenames
- .apply("Match all files", FileIO.matchAll())
+ .apply("Match all files", FileIO.matchAll().withOutputParallelization(true))
Review Comment:
setting this to `false`, the idea here is to check the performance test to see if theres a meaningful improvement with skipping the reshuffle vs not.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Controlling reshuffle in `FileIO.MatchAll` [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn commented on code in PR #35730:
URL: https://github.com/apache/beam/pull/35730#discussion_r2240852518
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileIO.java:
##########
@@ -373,9 +373,11 @@ public static Match match() {
public static MatchAll matchAll() {
return new AutoValue_FileIO_MatchAll.Builder()
.setConfiguration(MatchConfiguration.create(EmptyMatchTreatment.ALLOW_IF_WILDCARD))
+ .setAvoidReshuffle(false)
Review Comment:
There are similar configs in different IOs under different names. I recommend use `withOutputParallelization` (used by several IOs e.g. JdbcIO, redisIO, SinglestoreIO)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Controlling reshuffle in `FileIO.MatchAll` [beam]
Posted by "svetakvsundhar (via GitHub)" <gi...@apache.org>.
svetakvsundhar commented on PR #35730:
URL: https://github.com/apache/beam/pull/35730#issuecomment-3206524866
failure appears unrelated, are you ok if i merge @Abacn ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Controlling reshuffle in `FileIO.MatchAll` [beam]
Posted by "derrickaw (via GitHub)" <gi...@apache.org>.
derrickaw commented on PR #35730:
URL: https://github.com/apache/beam/pull/35730#issuecomment-3179482774
waiting on author
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Controlling reshuffle in `FileIO.MatchAll` [beam]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #35730:
URL: https://github.com/apache/beam/pull/35730#discussion_r2240698776
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileIO.java:
##########
@@ -723,9 +735,16 @@
res = input.apply(createWatchTransform(new ExtractFilenameFn())).apply(Values.create());
}
}
- return res.apply(Reshuffle.viaRandomKey());
+ // Apply Reshuffle conditionally based on the new flag
+ if (getAvoidReshuffle()) {
+ return res; // No reshuffle
+ } else {
+ return res.apply(Reshuffle.viaRandomKey());
+ }
}
+ public abstract boolean getAvoidReshuffle();
Review Comment:

This new public method should have Javadoc to document its purpose.
```suggestion
/** Returns whether to avoid the reshuffle operation. */
public abstract boolean getAvoidReshuffle();
```
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileIO.java:
##########
@@ -373,9 +373,11 @@ public static Match match() {
public static MatchAll matchAll() {
return new AutoValue_FileIO_MatchAll.Builder()
.setConfiguration(MatchConfiguration.create(EmptyMatchTreatment.ALLOW_IF_WILDCARD))
+ .setAvoidReshuffle(false)
Review Comment:

The indentation here is inconsistent with the surrounding code. To improve readability and maintain consistency, please align this line with the `.setConfiguration` call on the preceding line.
```suggestion
.setAvoidReshuffle(false)
```
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileIO.java:
##########
@@ -677,13 +679,23 @@
abstract Builder setConfiguration(MatchConfiguration configuration);
abstract MatchAll build();
+
+ abstract Builder setAvoidReshuffle(boolean b);
}
/** Like {@link Match#withConfiguration}. */
public MatchAll withConfiguration(MatchConfiguration configuration) {
return toBuilder().setConfiguration(configuration).build();
}
+ public MatchAll avoidReshuffle() {
+ return toBuilder().setAvoidReshuffle(true).build();
+ }
+
+ public MatchAll withAvoidReshuffle(boolean avoidReshuffle) {
+ return toBuilder().setAvoidReshuffle(avoidReshuffle).build();
+ }
Review Comment:

These new public methods are part of the API and should have Javadoc to explain their purpose and the performance implications of using them. This will help users understand when and how to use this new feature.
```java
/**
* Specifies to avoid the reshuffle operation.
*
* <p>This is a performance optimization for pipelines that match a small number of filepatterns. Disabling reshuffling may cause performance degradation if the number of filepatterns is large, as it may cause matcher operations to be fused with downstream transforms.
*
* <p>By default, a {@link org.apache.beam.sdk.transforms.Reshuffle} is applied to the matched files to break fusion and improve parallelism.
*/
public MatchAll avoidReshuffle() {
return toBuilder().setAvoidReshuffle(true).build();
}
/**
* Specifies whether to avoid the reshuffle operation.
*
* <p>This is a performance optimization for pipelines that match a small number of filepatterns. Disabling reshuffling may cause performance degradation if the number of filepatterns is large, as it may cause matcher operations to be fused with downstream transforms.
*
* <p>By default, a {@link org.apache.beam.sdk.transforms.Reshuffle} is applied to the matched files to break fusion and improve parallelism.
*/
public MatchAll withAvoidReshuffle(boolean avoidReshuffle) {
return toBuilder().setAvoidReshuffle(avoidReshuffle).build();
}
```
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileIO.java:
##########
@@ -677,13 +679,23 @@
abstract Builder setConfiguration(MatchConfiguration configuration);
abstract MatchAll build();
+
+ abstract Builder setAvoidReshuffle(boolean b);
Review Comment:

The parameter name `b` is not descriptive. Please consider using a more descriptive name like `avoidReshuffle` to improve code clarity and maintainability.
```suggestion
abstract Builder setAvoidReshuffle(boolean avoidReshuffle);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org