beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject [1/2] incubator-beam git commit: Add static factory methods for DoFnInfo
Date Tue, 01 Nov 2016 02:28:58 GMT
Repository: incubator-beam
Updated Branches:
  refs/heads/master 7e4583027 -> af1764785


Add static factory methods for DoFnInfo

This provides a clearer migration path away from deprecated
code paths than constructor overloads which can only be selected
by upcasting, etc.


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

Branch: refs/heads/master
Commit: d492294520aa721bdb4906177a7ac83e139003b0
Parents: 7e45830
Author: Kenneth Knowles <klk@google.com>
Authored: Thu Oct 27 19:01:03 2016 -0700
Committer: Kenneth Knowles <klk@google.com>
Committed: Mon Oct 31 19:19:40 2016 -0700

----------------------------------------------------------------------
 .../dataflow/DataflowPipelineTranslator.java      |  6 ++++--
 .../beam/runners/dataflow/util/DoFnInfo.java      | 18 ++++++++++++++----
 2 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d4922945/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowPipelineTranslator.java
----------------------------------------------------------------------
diff --git a/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowPipelineTranslator.java
b/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowPipelineTranslator.java
index 12aa696..0c5ac15 100644
--- a/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowPipelineTranslator.java
+++ b/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowPipelineTranslator.java
@@ -1067,8 +1067,10 @@ public class DataflowPipelineTranslator {
     context.addInput(PropertyNames.USER_FN, fn.getClass().getName());
     context.addInput(
         PropertyNames.SERIALIZED_FN,
-        byteArrayToJsonString(serializeToByteArray(
-            new DoFnInfo(fn, windowingStrategy, sideInputs, inputCoder, mainOutput, outputMap))));
+        byteArrayToJsonString(
+            serializeToByteArray(
+                DoFnInfo.forFn(
+                    fn, windowingStrategy, sideInputs, inputCoder, mainOutput, outputMap))));
   }
 
   private static BiMap<Long, TupleTag<?>> translateOutputs(

http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d4922945/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/util/DoFnInfo.java
----------------------------------------------------------------------
diff --git a/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/util/DoFnInfo.java
b/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/util/DoFnInfo.java
index bfa12e2..b84def8 100644
--- a/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/util/DoFnInfo.java
+++ b/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/util/DoFnInfo.java
@@ -44,10 +44,20 @@ public class DoFnInfo<InputT, OutputT> implements Serializable {
   private final Map<Long, TupleTag<?>> outputMap;
 
   /**
-   * Creates a {@link DoFnInfo} for the given {@link DoFn} or {@link OldDoFn} and auxiliary
bits and
-   * pieces.
+   * Creates a {@link DoFnInfo} for the given {@link Serializable} object, which is expected
to be a
+   * {@link DoFn} or {@link OldDoFn} or other context-appropriate UDF blob.
    */
-  public DoFnInfo(
+  public static <InputT, OutputT> DoFnInfo<InputT, OutputT> forFn(
+      Serializable doFn,
+      WindowingStrategy<?, ?> windowingStrategy,
+      Iterable<PCollectionView<?>> sideInputViews,
+      Coder<InputT> inputCoder,
+      long mainOutput,
+      Map<Long, TupleTag<?>> outputMap) {
+    return new DoFnInfo(doFn, windowingStrategy, sideInputViews, inputCoder, mainOutput,
outputMap);
+  }
+
+  private DoFnInfo(
       Serializable doFn,
       WindowingStrategy<?, ?> windowingStrategy,
       Iterable<PCollectionView<?>> sideInputViews,
@@ -63,7 +73,7 @@ public class DoFnInfo<InputT, OutputT> implements Serializable {
   }
 
   /**
-   * @deprecated call the constructor with a {@link Serializable}
+   * @deprecated use {@link #forFn}.
    */
   @Deprecated
   public DoFnInfo(


Mime
View raw message