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: Restore StateContexts.windowOnly for temporary compatibility
Date Fri, 18 Nov 2016 23:07:56 GMT
Repository: incubator-beam
Updated Branches:
  refs/heads/master 2a7169b6f -> 3548ffb06


Restore StateContexts.windowOnly for temporary compatibility


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

Branch: refs/heads/master
Commit: 73692b808aa4e0d85c6e20eb19a1bf4a4355a5c1
Parents: 2a7169b
Author: Kenneth Knowles <klk@google.com>
Authored: Fri Nov 18 14:40:59 2016 -0800
Committer: Kenneth Knowles <klk@google.com>
Committed: Fri Nov 18 14:59:41 2016 -0800

----------------------------------------------------------------------
 .../beam/sdk/util/state/StateContexts.java      | 41 +++++++++++++++-----
 1 file changed, 32 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/73692b80/sdks/java/core/src/main/java/org/apache/beam/sdk/util/state/StateContexts.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/util/state/StateContexts.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/util/state/StateContexts.java
index 858d6fe..1d6e949 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/util/state/StateContexts.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/util/state/StateContexts.java
@@ -42,22 +42,45 @@ public class StateContexts {
         @Override
         public BoundedWindow window() {
           throw new IllegalArgumentException("cannot call window() in a null context");
-        }};
+        }
+      };
 
-  /**
-   * Returns a fake {@link StateContext}.
-   */
+  /** Returns a fake {@link StateContext}. */
   @SuppressWarnings("unchecked")
   public static <W extends BoundedWindow> StateContext<W> nullContext() {
     return (StateContext<W>) NULL_CONTEXT;
   }
 
   /**
-   * Deprecated, do not use.
-   *
-   * <p>This exists only for temporary compatibility with Dataflow worker and should
be deleted
-   * once a worker image is released that uses runners-core build after
-   * https://github.com/apache/incubator-beam/pull/1353.
+   * @deprecated This exists only for temporary compatibility with Dataflow worker and should
be
+   *     deleted once a worker image is released that uses runners-core build after
+   *     https://github.com/apache/incubator-beam/pull/1353.
+   */
+  @Deprecated
+  public static <W extends BoundedWindow> StateContext<W> windowOnly(final W
window) {
+    return new StateContext<W>() {
+      @Override
+      public PipelineOptions getPipelineOptions() {
+        throw new IllegalArgumentException(
+            "cannot call getPipelineOptions() in a window only context");
+      }
+
+      @Override
+      public <T> T sideInput(PCollectionView<T> view) {
+        throw new IllegalArgumentException("cannot call sideInput() in a window only context");
+      }
+
+      @Override
+      public W window() {
+        return window;
+      }
+    };
+  }
+
+  /**
+   * @deprecated This exists only for temporary compatibility with Dataflow worker and should
be
+   *     deleted once a worker image is released that uses runners-core build after
+   *     https://github.com/apache/incubator-beam/pull/1353.
    */
   @Deprecated
   public static <W extends BoundedWindow> StateContext<W> createFromComponents(


Mime
View raw message