@Test public void testUnsafeWrapperMultiCacheValue() throws EvictionException { final Unsafe unsafe = UnsafeCacheValue._unsafe; final long[] addresses = new long[10]; int chunkSize = 1000; int chunks = 10; for (int i = 0; i < chunks; i++) { addresses[i] = unsafe.allocateMemory(chunkSize); } int length = addresses.length * chunkSize; UnsafeWrapperMultiCacheValue unsafeWrapperMultiCacheValue = new UnsafeWrapperMultiCacheValue(length, addresses, chunkSize) { @Override protected void releaseInternal() { for (int i = 0; i < 10; i++) { unsafe.freeMemory(addresses[i]); } } }; Random random = new Random(); byte[] buf1 = new byte[length]; random.nextBytes(buf1); unsafeWrapperMultiCacheValue.write(0, buf1, 0, length); byte[] buf2 = new byte[length]; unsafeWrapperMultiCacheValue.read(0, buf2, 0, length); assertTrue(equals(buf1, buf2)); assertTrue(Arrays.equals(buf1, buf2)); unsafeWrapperMultiCacheValue.release(); }
public UnsafeWrapperMultiCacheValue(int length, long[] chunkAddresses, int chunkSize) { super(length); _chunkAddresses = chunkAddresses; _chunkSize = chunkSize; }
UnsafeWrapperMultiCacheValue extends UnsafeCacheValue { public UnsafeWrapperMultiCacheValue(int length, long[] chunkAddresses, int chunkSize) { super(length); _chunkAddresses = chunkAddresses; _chunkSize = chunkSize; } }
UnsafeWrapperMultiCacheValue extends UnsafeCacheValue { public UnsafeWrapperMultiCacheValue(int length, long[] chunkAddresses, int chunkSize) { super(length); _chunkAddresses = chunkAddresses; _chunkSize = chunkSize; } UnsafeWrapperMultiCacheValue(int length, long[] chunkAddresses, int chunkSize); }
UnsafeWrapperMultiCacheValue extends UnsafeCacheValue { public UnsafeWrapperMultiCacheValue(int length, long[] chunkAddresses, int chunkSize) { super(length); _chunkAddresses = chunkAddresses; _chunkSize = chunkSize; } UnsafeWrapperMultiCacheValue(int length, long[] chunkAddresses, int chunkSize);  }
UnsafeWrapperMultiCacheValue extends UnsafeCacheValue { public UnsafeWrapperMultiCacheValue(int length, long[] chunkAddresses, int chunkSize) { super(length); _chunkAddresses = chunkAddresses; _chunkSize = chunkSize; } UnsafeWrapperMultiCacheValue(int length, long[] chunkAddresses, int chunkSize);   }