You pointed out a good question!
1. Considering `tryFinishCurrentBufferBuilder()`, the logic is somewhat
different from before. In the past, the buffer builder may be empty when
calling `tryFinishCurrentBufferBuilder()`, then it returns a boolean value to
indicate the result. But now, we know the buffer builder is always present when
calling `tryFinishCurrentBufferBuilder`, so we may change it to
`finishCurrentBufferBuilder()` seems more appropriate. And adds the check code
instead as following:
```
private void finishCurrentBufferBuilder(int targetChannel) {
checkState(bufferBuilders[targetChannel].isPresent());
BufferBuilder bufferBuilder =
bufferBuilders[targetChannel].get();
bufferBuilders[targetChannel] = Optional.empty();
numBytesOut.inc(bufferBuilder.finish());
}
```
2. But I think we still need call `finishCurrentBufferBuilder()` after
checking every full buffer. Because in the while loop the serialized record may
be copied into several different buffer builders, and each buffer build
referenced by the `bufferBuilders ` needs to be finished when full.
3. It actually seems better than before, as the loop exit not rely on the
return value of `tryFinishCurrentBufferBuilder()`.
[ Full content available at: https://github.com/apache/flink/pull/6417 ]
This message was relayed via gitbox.apache.org for [email protected]