Java Code Examples for org.apache.flink.runtime.io.network.buffer.BufferBuilder#append()

The following examples show how to use org.apache.flink.runtime.io.network.buffer.BufferBuilder#append() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpanningRecordSerializer.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Copies an intermediate data serialization buffer into the target BufferBuilder.
 *
 * @param targetBuffer the target BufferBuilder to copy to
 * @return how much information was written to the target buffer and
 *         whether this buffer is full
 */
@Override
public SerializationResult copyToBufferBuilder(BufferBuilder targetBuffer) {
	targetBuffer.append(lengthBuffer);
	targetBuffer.append(dataBuffer);
	targetBuffer.commit();

	return getSerializationResult(targetBuffer);
}
 
Example 2
Source File: SpanningRecordSerializer.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Copies an intermediate data serialization buffer into the target BufferBuilder.
 *
 * @param targetBuffer the target BufferBuilder to copy to
 * @return how much information was written to the target buffer and
 *         whether this buffer is full
 */
@Override
public SerializationResult copyToBufferBuilder(BufferBuilder targetBuffer) {
	targetBuffer.append(lengthBuffer);
	targetBuffer.append(dataBuffer);
	targetBuffer.commit();

	return getSerializationResult(targetBuffer);
}
 
Example 3
Source File: SpanningRecordSerializer.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Copies an intermediate data serialization buffer into the target BufferBuilder.
 *
 * @param targetBuffer the target BufferBuilder to copy to
 * @return how much information was written to the target buffer and
 *         whether this buffer is full
 */
@Override
public SerializationResult copyToBufferBuilder(BufferBuilder targetBuffer) {
	targetBuffer.append(dataBuffer);
	targetBuffer.commit();

	return getSerializationResult(targetBuffer);
}
 
Example 4
Source File: SpanningRecordSerializationTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static Buffer appendLeftOverBytes(Buffer buffer, byte[] leftOverBytes) {
	BufferBuilder bufferBuilder = new BufferBuilder(
		MemorySegmentFactory.allocateUnpooledSegment(buffer.readableBytes() + leftOverBytes.length),
		FreeingBufferRecycler.INSTANCE);
	try (BufferConsumer bufferConsumer = bufferBuilder.createBufferConsumer()) {
		bufferBuilder.append(buffer.getNioBufferReadable());
		bufferBuilder.appendAndCommit(ByteBuffer.wrap(leftOverBytes));
		return bufferConsumer.build();
	}
}