15 package com.cloudera.impala.util;
17 import java.lang.reflect.Field;
18 import java.security.AccessController;
19 import java.security.PrivilegedAction;
21 import sun.misc.Unsafe;
23 @SuppressWarnings(
"restriction")
37 UNSAFE = (Unsafe) AccessController.doPrivileged(
38 new PrivilegedAction<Object>() {
42 Field f = Unsafe.class.getDeclaredField(
"theUnsafe");
43 f.setAccessible(
true);
45 }
catch (NoSuchFieldException e) {
47 }
catch (IllegalAccessException e) {
53 BYTE_ARRAY_DATA_OFFSET = UNSAFE.arrayBaseOffset(byte[].class);
57 public static void Copy(
long dst, byte[] src,
int srcOffset,
int len) {
58 UNSAFE.copyMemory(src, BYTE_ARRAY_DATA_OFFSET + srcOffset, null, dst, len);
62 public static void Copy(byte[] dst,
int dstOffset,
long src,
int len) {
63 UNSAFE.copyMemory(null, src, dst, dstOffset + BYTE_ARRAY_DATA_OFFSET, len);
static final Unsafe UNSAFE
static void Copy(byte[] dst, int dstOffset, long src, int len)
static final int BYTE_ARRAY_DATA_OFFSET
static void Copy(long dst, byte[] src, int srcOffset, int len)