You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by ke...@apache.org on 2016/11/22 20:11:16 UTC
[12/50] incubator-beam git commit: Restores
StateContexts.stateContextFromComponents
Restores StateContexts.stateContextFromComponents
It must be temporarily restored for compatibility with
current Dataflow worker in order for integration tests
to pass.
Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/a23ae207
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/a23ae207
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/a23ae207
Branch: refs/heads/python-sdk
Commit: a23ae20760011634338e1c1eca9ec1891335fd6b
Parents: 90a0d0e
Author: Eugene Kirpichov <ki...@google.com>
Authored: Wed Nov 16 13:52:52 2016 -0800
Committer: Eugene Kirpichov <ki...@google.com>
Committed: Thu Nov 17 13:18:36 2016 -0800
----------------------------------------------------------------------
.../beam/sdk/util/state/StateContexts.java | 39 ++++++++++++++++++++
1 file changed, 39 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/a23ae207/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 81121e1..858d6fe 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
@@ -17,8 +17,10 @@
*/
package org.apache.beam.sdk.util.state;
+import javax.annotation.Nullable;
import org.apache.beam.sdk.options.PipelineOptions;
import org.apache.beam.sdk.transforms.windowing.BoundedWindow;
+import org.apache.beam.sdk.util.WindowingInternals;
import org.apache.beam.sdk.values.PCollectionView;
/**
@@ -49,4 +51,41 @@ public class StateContexts {
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
+ public static <W extends BoundedWindow> StateContext<W> createFromComponents(
+ @Nullable final PipelineOptions options,
+ final WindowingInternals<?, ?> windowingInternals,
+ final W window) {
+ @SuppressWarnings("unchecked")
+ StateContext<W> typedNullContext = (StateContext<W>) NULL_CONTEXT;
+ if (options == null) {
+ return typedNullContext;
+ } else {
+ return new StateContext<W>() {
+
+ @Override
+ public PipelineOptions getPipelineOptions() {
+ return options;
+ }
+
+ @Override
+ public <T> T sideInput(PCollectionView<T> view) {
+ return windowingInternals.sideInput(view, window);
+ }
+
+ @Override
+ public W window() {
+ return window;
+ }
+ };
+ }
+ }
}