-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31270: Reapply "Add Redistribute translation to S…
…amza runner"
- Loading branch information
Showing
5 changed files
with
81 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"comment": "Modify this file in a trivial way to cause this test suite to run", | ||
"https://github.com/apache/beam/pull/31156": "noting that PR #31156 should run this test" | ||
"https://github.com/apache/beam/pull/31156": "noting that PR #31156 should run this test", | ||
"https://github.com/apache/beam/pull/31270": "re-adds specialized Samza translation of Redistribute" | ||
} |
3 changes: 2 additions & 1 deletion
3
.github/trigger_files/beam_PostCommit_Java_ValidatesRunner_Samza.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"comment": "Modify this file in a trivial way to cause this test suite to run", | ||
"https://github.com/apache/beam/pull/31156": "noting that PR #31156 should run this test" | ||
"https://github.com/apache/beam/pull/31156": "noting that PR #31156 should run this test", | ||
"https://github.com/apache/beam/pull/31270": "re-add specialized Samza translation of Redistribute" | ||
} |
64 changes: 64 additions & 0 deletions
64
.../src/main/java/org/apache/beam/runners/samza/translation/RedistributeByKeyTranslator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.beam.runners.samza.translation; | ||
|
||
import com.google.auto.service.AutoService; | ||
import org.apache.beam.model.pipeline.v1.RunnerApi; | ||
import org.apache.beam.sdk.runners.TransformHierarchy; | ||
import org.apache.beam.sdk.transforms.PTransform; | ||
import org.apache.beam.sdk.util.construction.NativeTransforms; | ||
import org.apache.beam.sdk.util.construction.graph.PipelineNode; | ||
import org.apache.beam.sdk.util.construction.graph.QueryablePipeline; | ||
import org.apache.beam.sdk.values.KV; | ||
import org.apache.beam.sdk.values.PCollection; | ||
|
||
/** | ||
* Translates Reshuffle transform into Samza's native partitionBy operator, which will partition | ||
* each incoming message by the key into a Task corresponding to that key. | ||
*/ | ||
public class RedistributeByKeyTranslator<K, V> | ||
implements TransformTranslator<PTransform<PCollection<KV<K, V>>, PCollection<KV<K, V>>>> { | ||
|
||
private final ReshuffleTranslator<K, V, V> reshuffleTranslator = | ||
new ReshuffleTranslator<>("rdstr-"); | ||
|
||
@Override | ||
public void translate( | ||
PTransform<PCollection<KV<K, V>>, PCollection<KV<K, V>>> transform, | ||
TransformHierarchy.Node node, | ||
TranslationContext ctx) { | ||
reshuffleTranslator.translate(transform, node, ctx); | ||
} | ||
|
||
@Override | ||
public void translatePortable( | ||
PipelineNode.PTransformNode transform, | ||
QueryablePipeline pipeline, | ||
PortableTranslationContext ctx) { | ||
reshuffleTranslator.translatePortable(transform, pipeline, ctx); | ||
} | ||
|
||
/** Predicate to determine whether a URN is a Samza native transform. */ | ||
@AutoService(NativeTransforms.IsNativeTransform.class) | ||
public static class IsSamzaNativeTransform implements NativeTransforms.IsNativeTransform { | ||
@Override | ||
public boolean test(RunnerApi.PTransform pTransform) { | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters