Github user hvanhovell commented on a diff in the pull request:
https://github.com/apache/spark/pull/19222#discussion_r138739155
--- Diff:
common/unsafe/src/main/java/org/apache/spark/unsafe/memory/UnsafeMemoryAllocator.java
---
@@ -19,28 +19,61 @@
import org.apache.spark.unsafe.Platform;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
+
/**
* A simple {@link MemoryAllocator} that uses {@code Unsafe} to allocate
off-heap memory.
*/
public class UnsafeMemoryAllocator implements MemoryAllocator {
+ private static Method bufAddrMethod;
+ static {
+ try {
+ Class cb =
UnsafeMemoryAllocator.class.getClassLoader().loadClass("java.nio.DirectByteBuffer");
+ bufAddrMethod = cb.getMethod("address");
--- End diff --
You could use `sun.nio.ch.DirectBuffer` here. Both are evil.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]