Java Code Examples for org.apache.flink.core.memory.MemorySegmentFactory#allocateUnpooledOffHeapMemory()
The following examples show how to use
org.apache.flink.core.memory.MemorySegmentFactory#allocateUnpooledOffHeapMemory() .
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: BufferReaderWriterUtilTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void readPrematureEndOfFile1() throws Exception { final FileChannel fc = tmpFileChannel(); final Buffer buffer = createTestBuffer(); final MemorySegment readBuffer = MemorySegmentFactory.allocateUnpooledOffHeapMemory(buffer.getSize(), null); BufferReaderWriterUtil.writeToByteChannel(fc, buffer, BufferReaderWriterUtil.allocatedWriteBufferArray()); fc.truncate(fc.position() - 1); fc.position(0); try { BufferReaderWriterUtil.readFromByteChannel( fc, BufferReaderWriterUtil.allocatedHeaderBuffer(), readBuffer, FreeingBufferRecycler.INSTANCE); fail(); } catch (IOException e) { // expected } }
Example 2
Source File: BufferReaderWriterUtilTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void readPrematureEndOfFile2() throws Exception { final FileChannel fc = tmpFileChannel(); final Buffer buffer = createTestBuffer(); final MemorySegment readBuffer = MemorySegmentFactory.allocateUnpooledOffHeapMemory(buffer.getSize(), null); BufferReaderWriterUtil.writeToByteChannel(fc, buffer, BufferReaderWriterUtil.allocatedWriteBufferArray()); fc.truncate(2); // less than a header size fc.position(0); try { BufferReaderWriterUtil.readFromByteChannel( fc, BufferReaderWriterUtil.allocatedHeaderBuffer(), readBuffer, FreeingBufferRecycler.INSTANCE); fail(); } catch (IOException e) { // expected } }
Example 3
Source File: BufferReaderWriterUtilTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void readPrematureEndOfFile1() throws Exception { final FileChannel fc = tmpFileChannel(); final Buffer buffer = createTestBuffer(); final MemorySegment readBuffer = MemorySegmentFactory.allocateUnpooledOffHeapMemory(buffer.getSize(), null); BufferReaderWriterUtil.writeToByteChannel(fc, buffer, BufferReaderWriterUtil.allocatedWriteBufferArray()); fc.truncate(fc.position() - 1); fc.position(0); try { BufferReaderWriterUtil.readFromByteChannel( fc, BufferReaderWriterUtil.allocatedHeaderBuffer(), readBuffer, FreeingBufferRecycler.INSTANCE); fail(); } catch (IOException e) { // expected } }
Example 4
Source File: BufferReaderWriterUtilTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void readPrematureEndOfFile2() throws Exception { final FileChannel fc = tmpFileChannel(); final Buffer buffer = createTestBuffer(); final MemorySegment readBuffer = MemorySegmentFactory.allocateUnpooledOffHeapMemory(buffer.getSize(), null); BufferReaderWriterUtil.writeToByteChannel(fc, buffer, BufferReaderWriterUtil.allocatedWriteBufferArray()); fc.truncate(2); // less than a header size fc.position(0); try { BufferReaderWriterUtil.readFromByteChannel( fc, BufferReaderWriterUtil.allocatedHeaderBuffer(), readBuffer, FreeingBufferRecycler.INSTANCE); fail(); } catch (IOException e) { // expected } }
Example 5
Source File: BufferReaderWriterUtilTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void writeReadFileChannel() throws Exception { final FileChannel fc = tmpFileChannel(); final Buffer buffer = createTestBuffer(); final MemorySegment readBuffer = MemorySegmentFactory.allocateUnpooledOffHeapMemory(buffer.getSize(), null); BufferReaderWriterUtil.writeToByteChannel(fc, buffer, BufferReaderWriterUtil.allocatedWriteBufferArray()); fc.position(0); Buffer result = BufferReaderWriterUtil.readFromByteChannel( fc, BufferReaderWriterUtil.allocatedHeaderBuffer(), readBuffer, FreeingBufferRecycler.INSTANCE); validateTestBuffer(result); }
Example 6
Source File: BufferReaderWriterUtilTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void writeReadFileChannel() throws Exception { final FileChannel fc = tmpFileChannel(); final Buffer buffer = createTestBuffer(); final MemorySegment readBuffer = MemorySegmentFactory.allocateUnpooledOffHeapMemory(buffer.getSize(), null); BufferReaderWriterUtil.writeToByteChannel(fc, buffer, BufferReaderWriterUtil.allocatedWriteBufferArray()); fc.position(0); Buffer result = BufferReaderWriterUtil.readFromByteChannel( fc, BufferReaderWriterUtil.allocatedHeaderBuffer(), readBuffer, FreeingBufferRecycler.INSTANCE); validateTestBuffer(result); }
Example 7
Source File: BufferCompressionTest.java From flink with Apache License 2.0 | 5 votes |
private static Buffer createBufferAndFillWithLongValues(boolean isDirect) { MemorySegment segment; if (isDirect) { segment = MemorySegmentFactory.allocateUnpooledSegment(BUFFER_SIZE); } else { segment = MemorySegmentFactory.allocateUnpooledOffHeapMemory(BUFFER_SIZE); } for (int i = 0; i < NUM_LONGS; ++i) { segment.putLongLittleEndian(8 * i, i); } NetworkBuffer buffer = new NetworkBuffer(segment, FreeingBufferRecycler.INSTANCE); buffer.setSize(8 * NUM_LONGS); return buffer; }
Example 8
Source File: MemoryManager.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override MemorySegment allocateNewSegment(Object owner) { return MemorySegmentFactory.allocateUnpooledOffHeapMemory(segmentSize, owner); }
Example 9
Source File: MemoryManager.java From flink with Apache License 2.0 | 4 votes |
@Override MemorySegment allocateNewSegment(Object owner) { return MemorySegmentFactory.allocateUnpooledOffHeapMemory(segmentSize, owner); }