Use a Constant TupleTag in GroupAlsoByWindowEvaluator

This avoids the cost of generating a random ID, which is moderately
expensive.


Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/34a236ce
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/34a236ce
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/34a236ce

Branch: refs/heads/apex-runner
Commit: 34a236cead89ec72fded2cf44e6e1b0b540838d3
Parents: 064f18a
Author: Thomas Groh <tg...@google.com>
Authored: Wed Oct 26 14:31:41 2016 -0700
Committer: Kenneth Knowles <k...@google.com>
Committed: Thu Oct 27 12:50:08 2016 -0700

----------------------------------------------------------------------
 .../runners/direct/GroupAlsoByWindowEvaluatorFactory.java    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/34a236ce/runners/direct-java/src/main/java/org/apache/beam/runners/direct/GroupAlsoByWindowEvaluatorFactory.java
----------------------------------------------------------------------
diff --git 
a/runners/direct-java/src/main/java/org/apache/beam/runners/direct/GroupAlsoByWindowEvaluatorFactory.java
 
b/runners/direct-java/src/main/java/org/apache/beam/runners/direct/GroupAlsoByWindowEvaluatorFactory.java
index c7cf9e3..0c2aa1b 100644
--- 
a/runners/direct-java/src/main/java/org/apache/beam/runners/direct/GroupAlsoByWindowEvaluatorFactory.java
+++ 
b/runners/direct-java/src/main/java/org/apache/beam/runners/direct/GroupAlsoByWindowEvaluatorFactory.java
@@ -86,6 +86,7 @@ class GroupAlsoByWindowEvaluatorFactory implements 
TransformEvaluatorFactory {
    */
   private static class GroupAlsoByWindowEvaluator<K, V>
       implements TransformEvaluator<KeyedWorkItem<K, V>> {
+    private static final TupleTag<Object> MAIN_OUTPUT_TAG = new 
TupleTag<Object>() {};
 
     private final TransformEvaluator<KeyedWorkItem<K, V>> gabwParDoEvaluator;
 
@@ -118,8 +119,6 @@ class GroupAlsoByWindowEvaluatorFactory implements 
TransformEvaluatorFactory {
               new ConstantStateInternalsFactory<K>(stateInternals),
               SystemReduceFn.<K, V, BoundedWindow>buffering(valueCoder));
 
-      TupleTag<KV<K, Iterable<V>>> mainOutputTag = new TupleTag<KV<K, 
Iterable<V>>>() {};
-
       // Not technically legit, as the application is not a ParDo
       this.gabwParDoEvaluator =
           ParDoEvaluator.create(
@@ -129,9 +128,10 @@ class GroupAlsoByWindowEvaluatorFactory implements 
TransformEvaluatorFactory {
               application,
               gabwDoFn,
               Collections.<PCollectionView<?>>emptyList(),
-              mainOutputTag,
+              MAIN_OUTPUT_TAG,
               Collections.<TupleTag<?>>emptyList(),
-              ImmutableMap.<TupleTag<?>, PCollection<?>>of(mainOutputTag, 
application.getOutput()));
+              ImmutableMap.<TupleTag<?>, PCollection<?>>of(
+                  MAIN_OUTPUT_TAG, application.getOutput()));
     }
 
     @Override

Reply via email to