Java Code Examples for org.apache.flink.runtime.io.network.buffer.NetworkBuffer#setSize()

The following examples show how to use org.apache.flink.runtime.io.network.buffer.NetworkBuffer#setSize() . 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: CompressedBlockChannelWriter.java    From flink with Apache License 2.0 5 votes vote down vote up
private void compressBuffer(ByteBuffer buffer, int len) throws IOException {
	MemorySegment compressedBuffer;
	try {
		compressedBuffer = compressedBuffers.take();
	} catch (InterruptedException e) {
		throw new IOException(e);
	}
	int compressedLen = compressor.compress(
			buffer, 0, len,
			compressedBuffer.wrap(0, compressedBuffer.size()), 0);
	NetworkBuffer networkBuffer = new NetworkBuffer(compressedBuffer, this);
	networkBuffer.setSize(compressedLen);
	writer.writeBlock(networkBuffer);
}
 
Example 2
Source File: CompressedHeaderlessChannelWriterOutputView.java    From flink with Apache License 2.0 5 votes vote down vote up
private void writeCompressed(MemorySegment current, int size) throws IOException {
	MemorySegment compressedBuffer;
	try {
		compressedBuffer = compressedBuffers.take();
	} catch (InterruptedException e) {
		throw new IOException(e);
	}
	int compressedLen = compressor.compress(current.getArray(), 0, size, compressedBuffer.getArray(), 0);
	NetworkBuffer networkBuffer = new NetworkBuffer(compressedBuffer, this);
	networkBuffer.setSize(compressedLen);
	writer.writeBlock(networkBuffer);
	blockCount++;
	numBytes += size;
	numCompressedBytes += compressedLen;
}
 
Example 3
Source File: CompressedBlockChannelWriter.java    From flink with Apache License 2.0 5 votes vote down vote up
private void compressBuffer(ByteBuffer buffer, int len) throws IOException {
	MemorySegment compressedBuffer;
	try {
		compressedBuffer = compressedBuffers.take();
	} catch (InterruptedException e) {
		throw new IOException(e);
	}
	int compressedLen = compressor.compress(
			buffer, 0, len,
			compressedBuffer.wrap(0, compressedBuffer.size()), 0);
	NetworkBuffer networkBuffer = new NetworkBuffer(compressedBuffer, this);
	networkBuffer.setSize(compressedLen);
	writer.writeBlock(networkBuffer);
}
 
Example 4
Source File: CompressedHeaderlessChannelWriterOutputView.java    From flink with Apache License 2.0 5 votes vote down vote up
private void writeCompressed(MemorySegment current, int size) throws IOException {
	MemorySegment compressedBuffer;
	try {
		compressedBuffer = compressedBuffers.take();
	} catch (InterruptedException e) {
		throw new IOException(e);
	}
	int compressedLen = compressor.compress(current.getArray(), 0, size, compressedBuffer.getArray(), 0);
	NetworkBuffer networkBuffer = new NetworkBuffer(compressedBuffer, this);
	networkBuffer.setSize(compressedLen);
	writer.writeBlock(networkBuffer);
	blockCount++;
	numBytes += size;
	numCompressedBytes += compressedLen;
}