[
https://issues.apache.org/jira/browse/BEAM-2939?focusedWorklogId=115668&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-115668
]
ASF GitHub Bot logged work on BEAM-2939:
----------------------------------------
Author: ASF GitHub Bot
Created on: 25/Jun/18 21:46
Start Date: 25/Jun/18 21:46
Worklog Time Spent: 10m
Work Description: jkff commented on a change in pull request #5566:
[BEAM-2939, BEAM-3743, BEAM-3833] Supports SDF in Reference Runner
URL: https://github.com/apache/beam/pull/5566#discussion_r197913192
##########
File path:
runners/direct-java/src/main/java/org/apache/beam/runners/direct/portable/SplittableRemoteStageEvaluatorFactory.java
##########
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.beam.runners.direct.portable;
+
+import com.google.common.collect.Iterables;
+import java.util.ArrayList;
+import java.util.Collection;
+import javax.annotation.Nullable;
+import
org.apache.beam.model.fnexecution.v1.BeamFnApi.ProcessBundleProgressResponse;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi.ProcessBundleResponse;
+import org.apache.beam.model.pipeline.v1.RunnerApi.ExecutableStagePayload;
+import org.apache.beam.runners.core.KeyedWorkItem;
+import org.apache.beam.runners.core.construction.graph.ExecutableStage;
+import
org.apache.beam.runners.core.construction.graph.PipelineNode.PTransformNode;
+import org.apache.beam.runners.fnexecution.control.BundleProgressHandler;
+import org.apache.beam.runners.fnexecution.control.JobBundleFactory;
+import org.apache.beam.runners.fnexecution.control.RemoteBundle;
+import
org.apache.beam.runners.fnexecution.splittabledofn.SDFFeederViaStateAndTimers;
+import org.apache.beam.runners.fnexecution.state.StateRequestHandler;
+import org.apache.beam.runners.fnexecution.wire.WireCoders;
+import org.apache.beam.sdk.coders.Coder;
+import org.apache.beam.sdk.coders.KvCoder;
+import org.apache.beam.sdk.transforms.windowing.BoundedWindow;
+import org.apache.beam.sdk.util.WindowedValue;
+import org.apache.beam.sdk.util.WindowedValue.FullWindowedValueCoder;
+import org.apache.beam.sdk.values.KV;
+
+/**
+ * The {@link TransformEvaluatorFactory} for {@link #URN}, which reads from a
{@link
+ * DirectGroupByKey#DIRECT_GBKO_URN} and feeds the data, using state and
timers, to a {@link
+ * ExecutableStage} whose first instruction is an SDF.
+ */
+class SplittableRemoteStageEvaluatorFactory implements
TransformEvaluatorFactory {
+ public static final String URN =
"urn:beam:directrunner:transforms:splittable_remote_stage:v1";
+
+ // A fictional transform that transforms from KWI<unique key, KV<element,
restriction>>
+ // to simply KV<element, restriction> taken by the SDF inside the
ExecutableStage.
+ public static final String FEED_SDF_URN =
"urn:beam:directrunner:transforms:feed_sdf:v1";
+
+ private final BundleFactory bundleFactory;
+ private final JobBundleFactory jobBundleFactory;
+ private final StepStateAndTimers.Provider stp;
+
+ SplittableRemoteStageEvaluatorFactory(
+ BundleFactory bundleFactory,
+ JobBundleFactory jobBundleFactory,
+ StepStateAndTimers.Provider stepStateAndTimers) {
+ this.bundleFactory = bundleFactory;
+ this.jobBundleFactory = jobBundleFactory;
+ this.stp = stepStateAndTimers;
+ }
+
+ @Nullable
+ @Override
+ public <InputT> TransformEvaluator<InputT> forApplication(
+ PTransformNode application, CommittedBundle<?> inputBundle) throws
Exception {
+ return new SplittableRemoteStageEvaluator(
+ bundleFactory,
+ jobBundleFactory,
+ stp.forStepAndKey(application, inputBundle.getKey()),
+ application);
+ }
+
+ @Override
+ public void cleanup() throws Exception {
+ jobBundleFactory.close();
+ }
+
+ private static class SplittableRemoteStageEvaluator<InputT, RestrictionT>
+ implements TransformEvaluator<KeyedWorkItem<byte[], KV<InputT,
RestrictionT>>> {
+ private final PTransformNode transform;
+ private final ExecutableStage stage;
+
+ private final CopyOnAccessInMemoryStateInternals<byte[]> stateInternals;
+ private final DirectTimerInternals timerInternals;
+ private final RemoteBundle<KV<InputT, RestrictionT>> bundle;
+ private final Collection<UncommittedBundle<?>> outputs;
+
+ private final SDFFeederViaStateAndTimers<InputT, RestrictionT> feeder;
+
+ private SplittableRemoteStageEvaluator(
+ BundleFactory bundleFactory,
+ JobBundleFactory jobBundleFactory,
+ StepStateAndTimers<byte[]> stp,
+ PTransformNode transform)
+ throws Exception {
+ this.stateInternals = stp.stateInternals();
+ this.timerInternals = stp.timerInternals();
+ this.transform = transform;
+ this.stage =
+ ExecutableStage.fromPayload(
+
ExecutableStagePayload.parseFrom(transform.getTransform().getSpec().getPayload()));
+ this.outputs = new ArrayList<>();
+ this.bundle =
+ jobBundleFactory
+ .<KV<InputT, RestrictionT>>forStage(stage)
+ .getBundle(
+ BundleFactoryOutputReceiverFactory.create(
+ bundleFactory, stage.getComponents(), outputs::add),
+ StateRequestHandler.unsupported(),
+ new BundleProgressHandler() {
+ @Override
+ public void onProgress(ProcessBundleProgressResponse
progress) {
+ if (progress.hasSplit()) {
+ feeder.split(progress.getSplit());
Review comment:
Done
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 115668)
Time Spent: 3h 20m (was: 3h 10m)
> Fn API streaming SDF support
> ----------------------------
>
> Key: BEAM-2939
> URL: https://issues.apache.org/jira/browse/BEAM-2939
> Project: Beam
> Issue Type: Improvement
> Components: beam-model
> Reporter: Henning Rohde
> Assignee: Eugene Kirpichov
> Priority: Major
> Labels: portability
> Time Spent: 3h 20m
> Remaining Estimate: 0h
>
> The Fn API should support streaming SDF. Detailed design TBD.
> Once design is ready, expand subtasks similarly to BEAM-2822.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)