beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lc...@apache.org
Subject [1/2] beam git commit: [BEAM-2961] Add missing OnTimeBehavior proto translation to WindowingStrategy translation
Date Fri, 15 Sep 2017 23:35:04 GMT
Repository: beam
Updated Branches:
  refs/heads/master 2693bd726 -> 0b6958636


[BEAM-2961] Add missing OnTimeBehavior proto translation to WindowingStrategy translation


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

Branch: refs/heads/master
Commit: 7944caa2cbfd1869e7a6949c87588c144e545e44
Parents: 2693bd7
Author: Luke Cwik <lcwik@google.com>
Authored: Fri Sep 15 12:09:41 2017 -0700
Committer: Luke Cwik <lcwik@google.com>
Committed: Fri Sep 15 13:58:17 2017 -0700

----------------------------------------------------------------------
 .../construction/WindowingStrategyTranslation.java  | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/7944caa2/runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/WindowingStrategyTranslation.java
----------------------------------------------------------------------
diff --git a/runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/WindowingStrategyTranslation.java
b/runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/WindowingStrategyTranslation.java
index ab50ea2..7e02da8 100644
--- a/runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/WindowingStrategyTranslation.java
+++ b/runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/WindowingStrategyTranslation.java
@@ -123,6 +123,21 @@ public class WindowingStrategyTranslation implements Serializable {
     }
   }
 
+  public static RunnerApi.OnTimeBehavior toProto(OnTimeBehavior onTimeBehavior) {
+    switch (onTimeBehavior) {
+      case FIRE_ALWAYS:
+        return RunnerApi.OnTimeBehavior.FIRE_ALWAYS;
+      case FIRE_IF_NON_EMPTY:
+        return RunnerApi.OnTimeBehavior.FIRE_IF_NONEMPTY;
+      default:
+        throw new IllegalArgumentException(
+            String.format(
+                "Cannot convert unknown %s to %s: %s",
+                OnTimeBehavior.class.getCanonicalName(),
+                RunnerApi.OnTimeBehavior.class.getCanonicalName(),
+                onTimeBehavior));
+    }
+  }
 
   public static OnTimeBehavior fromProto(RunnerApi.OnTimeBehavior proto) {
     switch (proto) {
@@ -299,6 +314,7 @@ public class WindowingStrategyTranslation implements Serializable {
             .setTrigger(TriggerTranslation.toProto(windowingStrategy.getTrigger()))
             .setWindowFn(windowFnSpec)
             .setAssignsToOneWindow(windowingStrategy.getWindowFn().assignsToOneWindow())
+            .setOnTimeBehavior(toProto(windowingStrategy.getOnTimeBehavior()))
             .setWindowCoderId(
                 components.registerCoder(windowingStrategy.getWindowFn().windowCoder()));
 


Mime
View raw message