use of org.apache.flink.runtime.io.network.buffer.BufferBuilder in project flink by apache.
the class BufferWritingResultPartition method appendBroadcastDataForNewRecord.
private BufferBuilder appendBroadcastDataForNewRecord(final ByteBuffer record) throws IOException {
BufferBuilder buffer = broadcastBufferBuilder;
if (buffer == null) {
buffer = requestNewBroadcastBufferBuilder();
createBroadcastBufferConsumers(buffer, 0, record.remaining());
}
buffer.appendAndCommit(record);
return buffer;
}
use of org.apache.flink.runtime.io.network.buffer.BufferBuilder in project flink by apache.
the class BufferWritingResultPartition method appendUnicastDataForNewRecord.
private BufferBuilder appendUnicastDataForNewRecord(final ByteBuffer record, final int targetSubpartition) throws IOException {
if (targetSubpartition < 0 || targetSubpartition > unicastBufferBuilders.length) {
throw new ArrayIndexOutOfBoundsException(targetSubpartition);
}
BufferBuilder buffer = unicastBufferBuilders[targetSubpartition];
if (buffer == null) {
buffer = requestNewUnicastBufferBuilder(targetSubpartition);
addToSubpartition(buffer, targetSubpartition, 0, record.remaining());
}
buffer.appendAndCommit(record);
return buffer;
}
use of org.apache.flink.runtime.io.network.buffer.BufferBuilder in project flink by apache.
the class BufferWritingResultPartition method appendBroadcastDataForRecordContinuation.
private BufferBuilder appendBroadcastDataForRecordContinuation(final ByteBuffer remainingRecordBytes) throws IOException {
final BufferBuilder buffer = requestNewBroadcastBufferBuilder();
// !! Be aware, in case of partialRecordBytes != 0, partial length and data has to
// `appendAndCommit` first
// before consumer is created. Otherwise it would be confused with the case the buffer
// starting
// with a complete record.
// !! The next two lines can not change order.
final int partialRecordBytes = buffer.appendAndCommit(remainingRecordBytes);
createBroadcastBufferConsumers(buffer, partialRecordBytes, partialRecordBytes);
return buffer;
}
use of org.apache.flink.runtime.io.network.buffer.BufferBuilder in project flink by apache.
the class BufferWritingResultPartition method appendUnicastDataForRecordContinuation.
private BufferBuilder appendUnicastDataForRecordContinuation(final ByteBuffer remainingRecordBytes, final int targetSubpartition) throws IOException {
final BufferBuilder buffer = requestNewUnicastBufferBuilder(targetSubpartition);
// !! Be aware, in case of partialRecordBytes != 0, partial length and data has to
// `appendAndCommit` first
// before consumer is created. Otherwise it would be confused with the case the buffer
// starting
// with a complete record.
// !! The next two lines can not change order.
final int partialRecordBytes = buffer.appendAndCommit(remainingRecordBytes);
addToSubpartition(buffer, targetSubpartition, partialRecordBytes, partialRecordBytes);
return buffer;
}
use of org.apache.flink.runtime.io.network.buffer.BufferBuilder in project flink by apache.
the class BufferWritingResultPartition method finishUnicastBufferBuilder.
private void finishUnicastBufferBuilder(int targetSubpartition) {
final BufferBuilder bufferBuilder = unicastBufferBuilders[targetSubpartition];
if (bufferBuilder != null) {
int bytes = bufferBuilder.finish();
numBytesProduced.inc(bytes);
numBytesOut.inc(bytes);
numBuffersOut.inc();
unicastBufferBuilders[targetSubpartition] = null;
bufferBuilder.close();
}
}
Aggregations