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_r209290889
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/api/serialization/RecordSerializer.java
##########
@@ -66,29 +66,33 @@ public boolean isFullBuffer() {
}
/**
- * Starts serializing and copying the given record to the target buffer
- * (if available).
+ * Starts serializing the given record to an intermediate data buffer.
*
* @param record the record to serialize
- * @return how much information was written to the target buffer and
- * whether this buffer is full
*/
- SerializationResult addRecord(T record) throws IOException;
+ void serializeRecord(T record) throws IOException;
Review comment:
I'm thinking about refactoring this class and splitting it into two:
```
class RecordSerializer {
SerializedRecord serializeRecord(T record);
};
class SerializedRecord implements Autoclosable {
CopingResult copyToBufferBuilder(BufferBuilder bufferBuilder);
void close() {
serializer.prune();
// and code to return state (serializationBuffer) to serializer for
reuse
}
}
```
and usage:
```
public void randomEmit(T record) throws IOException,
InterruptedException {
try (SerializedRecord serializedRecord =
serializer.serializeRecord(record)) {
copyToTarget(serializedRecord,
rng.nextInt(numChannels));
}
}
```
somehow always was/is tickling my brain in current `RecordSerializer` is
confusing to me and I have to always check it's implementation whenever I
revisit the code. Maybe with this split it would be easier to understand? But
I'm not sure about this. What do you think?
----------------------------------------------------------------
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]
With regards,
Apache Git Services