@Test public void testCornerConditions() throws Exception { final String segmentName = "someSegment"; PinotDataBufferMemoryManager memoryManager = new MmapMemoryManager(_tmpDir, segmentName); final long s1 = MmapMemoryManager.getDefaultFileLength() - 1; final long s2 = 1; final long s3 = 100 * 1024 * 1024; final String colName = "col"; final byte v1 = 56; final byte v2 = 11; final byte v3 = 32; PinotDataBuffer b1 = memoryManager.allocate(s1, colName); ByteBuffer bb1 = b1.toDirectByteBuffer(0, (int) s1); bb1.put((int) s1 - 1, v1); PinotDataBuffer b2 = memoryManager.allocate(s2, colName); ByteBuffer bb2 = b2.toDirectByteBuffer(0, (int) s2); bb2.put((int) s2 - 1, v2); File dir = new File(_tmpDir); Assert.assertEquals(dir.listFiles().length, 1); PinotDataBuffer b3 = memoryManager.allocate(s3, colName); ByteBuffer bb3 = b3.toDirectByteBuffer(0, (int) s3); bb3.put(0, v3); Assert.assertEquals(dir.listFiles().length, 2); Assert.assertEquals(bb1.get((int) s1 - 1), v1); Assert.assertEquals(bb2.get((int) s2 - 1), v2); Assert.assertEquals(bb3.get(0), v3); memoryManager.close(); List<String> allocationContexts = PinotDataBuffer.getBufferInfo(); Assert.assertEquals(allocationContexts.size(), 0); }
@VisibleForTesting public static long getDefaultFileLength() { return DEFAULT_FILE_LENGTH; }
MmapMemoryManager extends RealtimeIndexOffHeapMemoryManager { @VisibleForTesting public static long getDefaultFileLength() { return DEFAULT_FILE_LENGTH; } }
MmapMemoryManager extends RealtimeIndexOffHeapMemoryManager { @VisibleForTesting public static long getDefaultFileLength() { return DEFAULT_FILE_LENGTH; } MmapMemoryManager(String dirPathName, String segmentName, ServerMetrics serverMetrics); @VisibleForTesting  MmapMemoryManager(String dirPathName, String segmentName); }
MmapMemoryManager extends RealtimeIndexOffHeapMemoryManager { @VisibleForTesting public static long getDefaultFileLength() { return DEFAULT_FILE_LENGTH; } MmapMemoryManager(String dirPathName, String segmentName, ServerMetrics serverMetrics); @VisibleForTesting  MmapMemoryManager(String dirPathName, String segmentName); @VisibleForTesting static long getDefaultFileLength(); }
MmapMemoryManager extends RealtimeIndexOffHeapMemoryManager { @VisibleForTesting public static long getDefaultFileLength() { return DEFAULT_FILE_LENGTH; } MmapMemoryManager(String dirPathName, String segmentName, ServerMetrics serverMetrics); @VisibleForTesting  MmapMemoryManager(String dirPathName, String segmentName); @VisibleForTesting static long getDefaultFileLength();  }