[
https://issues.apache.org/jira/browse/FLINK-5059?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15719999#comment-15719999
]
ASF GitHub Bot commented on FLINK-5059:
---------------------------------------
Github user uce commented on a diff in the pull request:
https://github.com/apache/flink/pull/2805#discussion_r90777962
--- Diff:
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/api/writer/ResultPartitionWriter.java
---
@@ -71,21 +68,26 @@ public void writeBuffer(Buffer buffer, int
targetChannel) throws IOException {
partition.add(buffer, targetChannel);
}
- public void writeEvent(AbstractEvent event, int targetChannel) throws
IOException {
- partition.add(EventSerializer.toBuffer(event), targetChannel);
- }
-
- public void writeEventToAllChannels(AbstractEvent event) throws
IOException {
- for (int i = 0; i < partition.getNumberOfSubpartitions(); i++) {
- Buffer buffer = EventSerializer.toBuffer(event);
- partition.add(buffer, i);
- }
- }
-
- public void writeEndOfSuperstep() throws IOException {
- for (int i = 0; i < partition.getNumberOfSubpartitions(); i++) {
- Buffer buffer =
EventSerializer.toBuffer(EndOfSuperstepEvent.INSTANCE);
- partition.add(buffer, i);
+ /**
+ * Writes the given buffer to all available target channels.
+ *
+ * The buffer is taken over and used for each of the channels.
+ * It will be recycled afterwards.
+ *
+ * @param eventBuffer the buffer to write
+ * @throws IOException
+ */
+ public void writeBufferToAllChannels(final Buffer eventBuffer) throws
IOException {
+ try {
+ for (int targetChannel = 0; targetChannel <
partition.getNumberOfSubpartitions(); targetChannel++) {
+ // retain the buffer so that it can be recycled
by each channel of targetPartition
+ eventBuffer.retain();
--- End diff --
Similar comments as in the `RecordWriter` apply here.
> only serialise events once in RecordWriter#broadcastEvent
> ---------------------------------------------------------
>
> Key: FLINK-5059
> URL: https://issues.apache.org/jira/browse/FLINK-5059
> Project: Flink
> Issue Type: Improvement
> Components: Network
> Reporter: Nico Kruber
> Assignee: Nico Kruber
>
> Currently,
> org.apache.flink.runtime.io.network.api.writer.RecordWriter#broadcastEvent
> serialises the event once per target channel. Instead, it could serialise the
> event only once and use the serialised form for every channel and thus save
> resources.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)