Java Code Examples for org.apache.flink.runtime.io.disk.iomanager.IOManager#createBufferFileWriter()

The following examples show how to use org.apache.flink.runtime.io.disk.iomanager.IOManager#createBufferFileWriter() . 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: FileChannelUtil.java    From flink with Apache License 2.0 6 votes vote down vote up
public static AbstractChannelWriterOutputView createOutputView(
		IOManager ioManager,
		FileIOChannel.ID channel,
		boolean compressionEnable,
		BlockCompressionFactory compressionCodecFactory,
		int compressionBlockSize,
		int segmentSize) throws IOException {
	if (compressionEnable) {
		BufferFileWriter bufferWriter = ioManager.createBufferFileWriter(channel);
		return new CompressedHeaderlessChannelWriterOutputView(
				bufferWriter,
				compressionCodecFactory,
				compressionBlockSize);
	} else {
		BlockChannelWriter<MemorySegment> blockWriter =
				ioManager.createBlockChannelWriter(channel);
		return new HeaderlessChannelWriterOutputView(
				blockWriter,
				Arrays.asList(
						allocateUnpooledSegment(segmentSize),
						allocateUnpooledSegment(segmentSize)
				),
				segmentSize
		);
	}
}
 
Example 2
Source File: CompressedBlockChannelWriter.java    From flink with Apache License 2.0 6 votes vote down vote up
public CompressedBlockChannelWriter(
		IOManager ioManager, ID channel,
		LinkedBlockingQueue<MemorySegment> blockQueue,
		BlockCompressionFactory codecFactory, int preferBlockSize, int segmentSize) throws IOException {
	this.writer = ioManager.createBufferFileWriter(channel);
	this.blockQueue = blockQueue;
	copyCompress = preferBlockSize > segmentSize * 2;
	int blockSize = copyCompress ? preferBlockSize : segmentSize;
	this.compressor = codecFactory.getCompressor();

	if (copyCompress) {
		this.buf = new byte[blockSize];
		this.bufWrapper = ByteBuffer.wrap(buf);
	}

	for (int i = 0; i < 2; i++) {
		compressedBuffers.add(MemorySegmentFactory.wrap(
				new byte[compressor.getMaxCompressedSize(blockSize)]));
	}
}
 
Example 3
Source File: FileChannelUtil.java    From flink with Apache License 2.0 6 votes vote down vote up
public static AbstractChannelWriterOutputView createOutputView(
		IOManager ioManager,
		FileIOChannel.ID channel,
		boolean compressionEnable,
		BlockCompressionFactory compressionCodecFactory,
		int compressionBlockSize,
		int segmentSize) throws IOException {
	if (compressionEnable) {
		BufferFileWriter bufferWriter = ioManager.createBufferFileWriter(channel);
		return new CompressedHeaderlessChannelWriterOutputView(
				bufferWriter,
				compressionCodecFactory,
				compressionBlockSize);
	} else {
		BlockChannelWriter<MemorySegment> blockWriter =
				ioManager.createBlockChannelWriter(channel);
		return new HeaderlessChannelWriterOutputView(
				blockWriter,
				Arrays.asList(
						allocateUnpooledSegment(segmentSize),
						allocateUnpooledSegment(segmentSize)
				),
				segmentSize
		);
	}
}
 
Example 4
Source File: CompressedBlockChannelWriter.java    From flink with Apache License 2.0 6 votes vote down vote up
public CompressedBlockChannelWriter(
		IOManager ioManager, ID channel,
		LinkedBlockingQueue<MemorySegment> blockQueue,
		BlockCompressionFactory codecFactory, int preferBlockSize, int segmentSize) throws IOException {
	this.writer = ioManager.createBufferFileWriter(channel);
	this.blockQueue = blockQueue;
	copyCompress = preferBlockSize > segmentSize * 2;
	int blockSize = copyCompress ? preferBlockSize : segmentSize;
	this.compressor = codecFactory.getCompressor();

	if (copyCompress) {
		this.buf = new byte[blockSize];
		this.bufWrapper = ByteBuffer.wrap(buf);
	}

	for (int i = 0; i < 2; i++) {
		compressedBuffers.add(MemorySegmentFactory.wrap(
				new byte[compressor.getMaxCompressedSize(blockSize)]));
	}
}