pnowojski commented on a change in pull request #6417: [FLINK-9913][runtime] 
Improve output serialization only once in RecordWriter
URL: https://github.com/apache/flink/pull/6417#discussion_r209284512
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/api/writer/RecordWriter.java
 ##########
 @@ -188,24 +192,32 @@ public void setMetricGroup(TaskIOMetricGroup metrics) {
 
        /**
         * Marks the current {@link BufferBuilder} as finished and clears the 
state for next one.
-        *
-        * @return true if some data were written
         */
-       private boolean tryFinishCurrentBufferBuilder(int targetChannel, 
RecordSerializer<T> serializer) {
-
-               if (!bufferBuilders[targetChannel].isPresent()) {
-                       return false;
+       private void tryFinishCurrentBufferBuilder(int targetChannel) {
+               if (bufferBuilders[targetChannel].isPresent()) {
+                       BufferBuilder bufferBuilder = 
bufferBuilders[targetChannel].get();
+                       bufferBuilders[targetChannel] = Optional.empty();
+                       numBytesOut.inc(bufferBuilder.finish());
                }
-               BufferBuilder bufferBuilder = 
bufferBuilders[targetChannel].get();
-               bufferBuilders[targetChannel] = Optional.empty();
+       }
 
-               numBytesOut.inc(bufferBuilder.finish());
-               serializer.clear();
-               return true;
+       /**
+        * The {@link BufferBuilder} may already exist if not filled up last 
time, otherwise we need
+        * request a new one for this target channel.
+        */
+       @Nonnull
 
 Review comment:
   Imo you don't have to add `@Nonnull` annotation. I'm implicitly assuming 
that any non `@Nullable` marked field is automatically `@Nonnull`.

----------------------------------------------------------------
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


With regards,
Apache Git Services

Reply via email to