Skip to content

Commit 40e5541

Browse files
authored
Merge pull request #164 from linkedin/xiyan/skip
Add skipReshuffleForParDo option to FlinkPipelineOptions
2 parents 53b2ed6 + 13c012b commit 40e5541

4 files changed

Lines changed: 22 additions & 5 deletions

File tree

‎buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ class BeamModulePlugin implements Plugin<Project> {
398398

399399
// Automatically use the official release version if we are performing a release
400400
// otherwise append '-SNAPSHOT'
401-
project.version = '2.45.53'
401+
project.version = '2.45.54'
402402
if (isLinkedin(project)) {
403403
project.ext.mavenGroupId = 'com.linkedin.beam'
404404
}

‎gradle.properties‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ signing.gnupg.useLegacyGpg=true
3030
# buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy.
3131
# To build a custom Beam version make sure you change it in both places, see
3232
# https://github.com/apache/beam/issues/21302.
33-
version=2.45.53
34-
sdk_version=2.45.53
33+
version=2.45.54
34+
sdk_version=2.45.54
3535

3636
javaVersion=1.8
3737

‎runners/flink/src/main/java/org/apache/beam/runners/flink/FlinkPipelineOptions.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,18 @@ public interface FlinkPipelineOptions
305305

306306
void setFlinkConfDir(String confDir);
307307

308+
@Description(
309+
"When true, stateful ParDo operators use DataStreamUtils.reinterpretAsKeyedStream() instead"
310+
+ " of DataStream.keyBy(), eliminating the HASH network exchange before stateful DoFns."
311+
+ " Requires that every input PCollection is already correctly key-partitioned by the"
312+
+ " Flink-compatible hash function (Kafka producer must use a MurmurHash3-aligned"
313+
+ " partitioner matching Flink's KvToByteBufferKeySelector). Incorrect alignment causes"
314+
+ " silent state corruption.")
315+
@Default.Boolean(false)
316+
Boolean getSkipReshuffleForParDo();
317+
318+
void setSkipReshuffleForParDo(Boolean value);
319+
308320
static FlinkPipelineOptions defaults() {
309321
return PipelineOptionsFactory.as(FlinkPipelineOptions.class);
310322
}

‎runners/flink/src/main/java/org/apache/beam/runners/flink/FlinkStreamingTransformTranslators.java‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,14 @@ static <InputT, OutputT> void translateParDo(
613613
producer != null
614614
? PTransformTranslation.urnForTransformOrNull(context.getProducer(input))
615615
: null;
616-
// We can skip reshuffle in case previous transform was CPK or GBK
616+
// We can skip reshuffle in case previous transform was CPK or GBK,
617+
// or if the caller asserts input is already correctly key-partitioned.
617618
if (PTransformTranslation.COMBINE_PER_KEY_TRANSFORM_URN.equals(previousUrn)
618-
|| PTransformTranslation.GROUP_BY_KEY_TRANSFORM_URN.equals(previousUrn)) {
619+
|| PTransformTranslation.GROUP_BY_KEY_TRANSFORM_URN.equals(previousUrn)
620+
|| context
621+
.getPipelineOptions()
622+
.as(FlinkPipelineOptions.class)
623+
.getSkipReshuffleForParDo()) {
619624
inputDataStream = DataStreamUtils.reinterpretAsKeyedStream(inputDataStream, keySelector);
620625
} else {
621626
inputDataStream = inputDataStream.keyBy(keySelector);

0 commit comments

Comments
 (0)