[ 
https://issues.apache.org/jira/browse/BEAM-2898?focusedWorklogId=86824&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-86824
 ]

ASF GitHub Bot logged work on BEAM-2898:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 02/Apr/18 22:44
            Start Date: 02/Apr/18 22:44
    Worklog Time Spent: 10m 
      Work Description: bsidhom commented on a change in pull request #4783: 
[BEAM-2898] Support Impulse transforms in Flink batch runner
URL: https://github.com/apache/beam/pull/4783#discussion_r178670179
 
 

 ##########
 File path: 
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/ImpulseInputFormat.java
 ##########
 @@ -0,0 +1,96 @@
+/*
+ * 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.flink.translation.wrappers;
+
+import org.apache.beam.sdk.util.WindowedValue;
+import org.apache.flink.api.common.io.DefaultInputSplitAssigner;
+import org.apache.flink.api.common.io.RichInputFormat;
+import org.apache.flink.api.common.io.statistics.BaseStatistics;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.io.GenericInputSplit;
+import org.apache.flink.core.io.InputSplitAssigner;
+
+/** Flink input format that implements impulses. */
+public class ImpulseInputFormat extends RichInputFormat<WindowedValue<byte[]>, 
GenericInputSplit> {
+
+  // Whether the input format has remaining output that has not yet been read.
+  private boolean availableOutput = false;
+
+  public ImpulseInputFormat() {}
+
+  @Override
+  public void configure(Configuration configuration) {
+    // Do nothing.
+  }
+
+  @Override
+  public BaseStatistics getStatistics(BaseStatistics baseStatistics) {
+    return new BaseStatistics() {
+      @Override
+      public long getTotalInputSize() {
+        return 1;
+      }
+
+      @Override
+      public long getNumberOfRecords() {
+        return 1;
+      }
+
+      @Override
+      public float getAverageRecordWidth() {
+        return 1;
+      }
+    };
+  }
+
+  @Override
+  public GenericInputSplit[] createInputSplits(int numSplits) {
+    // Always return a single split because only one global "impulse" will 
ever be sent.
+    return new GenericInputSplit[]{new GenericInputSplit(1, 1)};
+  }
+
+  @Override
+  public InputSplitAssigner getInputSplitAssigner(GenericInputSplit[] 
genericInputSplits) {
+    return new DefaultInputSplitAssigner(genericInputSplits);
+  }
+
+  @Override
+  public void open(GenericInputSplit genericInputSplit) {
+    availableOutput = true;
+  }
+
+  @Override
+  public boolean reachedEnd() {
+    return !availableOutput;
+  }
+
+  @Override
+  public WindowedValue<byte[]> nextRecord(WindowedValue<byte[]> windowedValue) 
{
+    availableOutput = false;
 
 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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 86824)
    Time Spent: 3h 40m  (was: 3.5h)

> Flink supports chaining/fusion of single-SDK stages
> ---------------------------------------------------
>
>                 Key: BEAM-2898
>                 URL: https://issues.apache.org/jira/browse/BEAM-2898
>             Project: Beam
>          Issue Type: Sub-task
>          Components: runner-flink
>            Reporter: Henning Rohde
>            Priority: Major
>              Labels: portability
>          Time Spent: 3h 40m
>  Remaining Estimate: 0h
>
> The Fn API supports fused stages, which avoids unnecessarily round-tripping 
> the data over the Fn API between stages. The Flink runner should use that 
> capability for better performance.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to