@Test public void testContinualAppendCausingEvictionIsStable() { UpfrontAllocatingPageSource pageSource = new UpfrontAllocatingPageSource( new OffHeapBufferSource(), KILOBYTES.toBytes(1024L), KILOBYTES.toBytes(1024)); if (steal) { OffHeapChainMap<String> mapA = new OffHeapChainMap<String>( pageSource, StringPortability.INSTANCE, minPageSize, maxPageSize, true); OffHeapChainMap<String> mapB = new OffHeapChainMap<String>( pageSource, StringPortability.INSTANCE, minPageSize, maxPageSize, true); for (int c = 0; ; c++) { long before = mapA.getOccupiedMemory(); for (int i = 0; i < 100; i++) { mapA.append(Integer.toString(i), buffer(2)); mapB.append(Integer.toString(i), buffer(2)); } if (mapA.getOccupiedMemory() <= before) { while (c-- > 0) { for (int i = 0; i < 100; i++) { mapA.append(Integer.toString(i), buffer(2)); mapB.append(Integer.toString(i), buffer(2)); } } break; } } } else { OffHeapChainMap<String> map = new OffHeapChainMap<String>( pageSource, StringPortability.INSTANCE, minPageSize, maxPageSize, false); for (int c = 0; ; c++) { long before = map.getOccupiedMemory(); for (int i = 0; i < 100; i++) { map.append(Integer.toString(i), buffer(2)); } if (map.getOccupiedMemory() <= before) { while (c-- > 0) { for (int i = 0; i < 100; i++) { map.append(Integer.toString(i), buffer(2)); } } break; } } } }
public long toKilobytes(double size) { return multiplyByByteOrderOfMagnitude(size, getOrdinal() - KILOBYTES.getOrdinal()); }
public long toKilobytes(long l) { return KILOBYTES.convert(l, this); }