Search in sources :

Example 36 with BufferBuilder

use of org.apache.flink.runtime.io.network.buffer.BufferBuilder in project flink by splunk.

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)

Example 37 with BufferBuilder

use of org.apache.flink.runtime.io.network.buffer.BufferBuilder in project flink by splunk.

the class BufferWritingResultPartition method broadcastRecord.

@Override
public void broadcastRecord(ByteBuffer record) throws IOException {
    totalWrittenBytes += ((long) record.remaining() * numSubpartitions);
    BufferBuilder buffer = appendBroadcastDataForNewRecord(record);
    while (record.hasRemaining()) {
        // full buffer, partial record
        finishBroadcastBufferBuilder();
        buffer = appendBroadcastDataForRecordContinuation(record);
    }
    if (buffer.isFull()) {
        // full buffer, full record
        finishBroadcastBufferBuilder();
    }
// partial buffer, full record
}
Also used : BufferBuilder(org.apache.flink.runtime.io.network.buffer.BufferBuilder)

Example 38 with BufferBuilder

use of org.apache.flink.runtime.io.network.buffer.BufferBuilder in project flink by splunk.

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 39 with BufferBuilder

use of org.apache.flink.runtime.io.network.buffer.BufferBuilder in project flink by splunk.

the class BufferWritingResultPartition method requestNewUnicastBufferBuilder.

private BufferBuilder requestNewUnicastBufferBuilder(int targetSubpartition) throws IOException {
    checkInProduceState();
    ensureUnicastMode();
    final BufferBuilder bufferBuilder = requestNewBufferBuilderFromPool(targetSubpartition);
    unicastBufferBuilders[targetSubpartition] = bufferBuilder;
    return bufferBuilder;
}
Also used : BufferBuilder(org.apache.flink.runtime.io.network.buffer.BufferBuilder)

Example 40 with BufferBuilder

use of org.apache.flink.runtime.io.network.buffer.BufferBuilder in project flink by splunk.

the class BufferWritingResultPartition method emitRecord.

@Override
public void emitRecord(ByteBuffer record, int targetSubpartition) throws IOException {
    totalWrittenBytes += record.remaining();
    BufferBuilder buffer = appendUnicastDataForNewRecord(record, targetSubpartition);
    while (record.hasRemaining()) {
        // full buffer, partial record
        finishUnicastBufferBuilder(targetSubpartition);
        buffer = appendUnicastDataForRecordContinuation(record, targetSubpartition);
    }
    if (buffer.isFull()) {
        // full buffer, full record
        finishUnicastBufferBuilder(targetSubpartition);
    }
// partial buffer, full record
}
Also used : BufferBuilder(org.apache.flink.runtime.io.network.buffer.BufferBuilder)

Aggregations

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