@Test public void testLargeBlocks() throws Exception { final String segmentName = "someSegment"; PinotDataBufferMemoryManager memoryManager = new MmapMemoryManager(_tmpDir, segmentName); final long s1 = 2 * MmapMemoryManager.getDefaultFileLength(); final long s2 = 1000; final String col1 = "col1"; final String col2 = "col2"; final byte value = 34; PinotDataBuffer buf1 = memoryManager.allocate(s1, col1); ByteBuffer b1 = buf1.toDirectByteBuffer(0, (int) s1); b1.putLong(0, s1); Assert.assertEquals(b1.getLong(0), s1); b1.put((int) s1 - 1, value); Assert.assertEquals(b1.get((int) s1 - 1), value); PinotDataBuffer buf2 = memoryManager.allocate(s2, col2); ByteBuffer b2 = buf2.toDirectByteBuffer(0, (int) s2); b2.putLong(0, s2); Assert.assertEquals(b2.getLong(0), s2); File dir = new File(_tmpDir); File[] files = dir.listFiles(); Assert.assertEquals(files.length, 2); Arrays.sort(files, new Comparator<File>() { @Override public int compare(File o1, File o2) { return o1.getName().compareTo(o2.getName()); } }); String fileName = files[0].getName(); Assert.assertTrue(fileName.contains(segmentName)); fileName = files[1].getName(); Assert.assertTrue(fileName.contains(segmentName)); buf1.close(); buf2.close(); memoryManager.close(); List<String> allocationContexts = PinotDataBuffer.getBufferInfo(); Assert.assertEquals(allocationContexts.size(), 0); Assert.assertEquals(new File(_tmpDir).listFiles().length, 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();  }