use of org.apache.flink.runtime.io.network.buffer.BufferBuilder in project flink-mirror by flink-ci.
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();
}
}
use of org.apache.flink.runtime.io.network.buffer.BufferBuilder in project flink-mirror by flink-ci.
the class BufferWritingResultPartition method requestNewUnicastBufferBuilder.
private BufferBuilder requestNewUnicastBufferBuilder(int targetSubpartition) throws IOException {
checkInProduceState();
ensureUnicastMode();
final BufferBuilder bufferBuilder = requestNewBufferBuilderFromPool(targetSubpartition);
unicastBufferBuilders[targetSubpartition] = bufferBuilder;
return bufferBuilder;
}
use of org.apache.flink.runtime.io.network.buffer.BufferBuilder in project flink-mirror by flink-ci.
the class HashBasedDataBuffer method writeRecord.
private void writeRecord(ByteBuffer source, int targetChannel) throws IOException {
do {
BufferBuilder builder = builders[targetChannel];
if (builder == null) {
builder = requestBufferFromPool();
if (builder == null) {
break;
}
++numBuffersOccupied;
builders[targetChannel] = builder;
}
builder.append(source);
if (builder.isFull()) {
builder.finish();
buffers[targetChannel].add(builder.createBufferConsumerFromBeginning());
builder.close();
builders[targetChannel] = null;
}
} while (source.hasRemaining());
}
use of org.apache.flink.runtime.io.network.buffer.BufferBuilder in project flink-mirror by flink-ci.
the class HashBasedDataBuffer method writeEvent.
private void writeEvent(ByteBuffer source, int targetChannel, Buffer.DataType dataType) {
BufferBuilder builder = builders[targetChannel];
if (builder != null) {
builder.finish();
buffers[targetChannel].add(builder.createBufferConsumerFromBeginning());
builder.close();
builders[targetChannel] = null;
}
MemorySegment segment = MemorySegmentFactory.allocateUnpooledOffHeapMemory(source.remaining());
segment.put(0, source, segment.size());
BufferConsumer consumer = new BufferConsumer(new NetworkBuffer(segment, FreeingBufferRecycler.INSTANCE, dataType), segment.size());
buffers[targetChannel].add(consumer);
}
use of org.apache.flink.runtime.io.network.buffer.BufferBuilder in project flink-mirror by flink-ci.
the class HashBasedDataBuffer method finish.
@Override
public void finish() {
checkState(!isFull, "DataBuffer must not be full.");
checkState(!isFinished, "DataBuffer is already finished.");
isFull = true;
isFinished = true;
for (int channel = 0; channel < builders.length; ++channel) {
BufferBuilder builder = builders[channel];
if (builder != null) {
builder.finish();
buffers[channel].add(builder.createBufferConsumerFromBeginning());
builder.close();
builders[channel] = null;
}
}
}
Aggregations