You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/07/23 15:09:12 UTC

[GitHub] [flink] pnowojski commented on a change in pull request #16581: [FLINK-23474] Extract internal version of InputStatus

pnowojski commented on a change in pull request #16581:
URL: https://github.com/apache/flink/pull/16581#discussion_r675633835



##########
File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/SourceOperator.java
##########
@@ -276,20 +277,33 @@ public void close() throws Exception {
     }
 
     @Override
-    public InputStatus emitNext(DataOutput<OUT> output) throws Exception {
+    public DataInputStatus emitNext(DataOutput<OUT> output) throws Exception {
         // guarding an assumptions we currently make due to the fact that certain classes
         // assume a constant output
         assert lastInvokedOutput == output || lastInvokedOutput == null;
 
         // short circuit the common case (every invocation except the first)
         if (currentMainOutput != null) {
-            return sourceReader.pollNext(currentMainOutput);
+            return convertToInternalStatus(sourceReader.pollNext(currentMainOutput));
         }
 
         // this creates a batch or streaming output based on the runtime mode
         currentMainOutput = eventTimeLogic.createMainOutput(output);
         lastInvokedOutput = output;
-        return sourceReader.pollNext(currentMainOutput);
+        return convertToInternalStatus(sourceReader.pollNext(currentMainOutput));
+    }
+
+    private DataInputStatus convertToInternalStatus(InputStatus inputStatus) {
+        switch (inputStatus) {
+            case MORE_AVAILABLE:
+                return DataInputStatus.MORE_AVAILABLE;
+            case NOTHING_AVAILABLE:
+                return DataInputStatus.NOTHING_AVAILABLE;
+            case END_OF_INPUT:
+                return DataInputStatus.END_OF_INPUT;
+            default:
+                throw new IllegalArgumentException("Unknown input status: " + inputStatus);
+        }

Review comment:
       I would be curious how well JIT can optimise this... probably as long as `sourceReader.pollNext()` is de-virtualised and inlined this will be for free. But otherwise I would guess it will cost a couple of CPU cycles. Either way I don't expect this to be visible as a performance regression, but I'm just curious...

##########
File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/io/DataInputStatus.java
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.flink.streaming.runtime.io;
+
+import org.apache.flink.annotation.Internal;
+
+/**
+ * An {@code InputStatus} indicates the availability of data from an asynchronous input. When asking
+ * an asynchronous input to produce data, it returns this status to indicate how to proceed.
+ *
+ * <p>It is an internal equivalent of {@link org.apache.flink.core.io.InputStatus} that provides
+ * additional non public statuses.

Review comment:
       nitty nit: reverse order of the paragraphs? Start with:
   > DataInputStatus is an internal equivalent of {@link org.apache.flink.core.io.InputStatus} that provides additional non public statuses.
   
   ?

##########
File path: flink-core/src/main/java/org/apache/flink/core/io/InputStatus.java
##########
@@ -50,9 +50,6 @@
      */
     NOTHING_AVAILABLE,
 
-    /** Indicator that all persisted data of the data exchange has been successfully restored. */
-    END_OF_RECOVERY,
-

Review comment:
       This change requires a release note 🙄 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org