Search in sources :

Example 6 with BufferBuilder

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;
}
Also used : BufferBuilder(org.apache.flink.runtime.io.network.buffer.BufferBuilder)

Example 7 with BufferBuilder

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;
}
Also used : BufferBuilder(org.apache.flink.runtime.io.network.buffer.BufferBuilder)

Example 8 with BufferBuilder

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;
}
Also used : BufferBuilder(org.apache.flink.runtime.io.network.buffer.BufferBuilder)

Example 9 with BufferBuilder

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;
}
Also used : BufferBuilder(org.apache.flink.runtime.io.network.buffer.BufferBuilder)

Example 10 with BufferBuilder

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();
    }
}
Also used : BufferBuilder(org.apache.flink.runtime.io.network.buffer.BufferBuilder)

Aggregations

BufferBuilder (org.apache.flink.runtime.io.network.buffer.BufferBuilder)56 BufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferConsumer)18 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)14 Test (org.junit.Test)14 BufferBuilderTestUtils.createBufferBuilder (org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createBufferBuilder)12 MemorySegment (org.apache.flink.core.memory.MemorySegment)8 InputChannelInfo (org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)8 SubtaskConnectionDescriptor (org.apache.flink.runtime.io.network.api.SubtaskConnectionDescriptor)8 NetworkBuffer (org.apache.flink.runtime.io.network.buffer.NetworkBuffer)6 ByteBuffer (java.nio.ByteBuffer)4 DataOutputSerializer (org.apache.flink.core.memory.DataOutputSerializer)4 BufferBuilderTestUtils.createFilledBufferBuilder (org.apache.flink.runtime.io.network.buffer.BufferBuilderTestUtils.createFilledBufferBuilder)4 BufferPool (org.apache.flink.runtime.io.network.buffer.BufferPool)4 NetworkBufferPool (org.apache.flink.runtime.io.network.buffer.NetworkBufferPool)4 CheckpointedResultSubpartition (org.apache.flink.runtime.io.network.partition.CheckpointedResultSubpartition)4 BufferAndAvailability (org.apache.flink.runtime.io.network.partition.consumer.InputChannel.BufferAndAvailability)4 BufferAndAvailabilityProvider (org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel.BufferAndAvailabilityProvider)4 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2