sun.misc.Unsafe.getShort()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(191)

本文整理了Java中sun.misc.Unsafe.getShort()方法的一些代码示例,展示了Unsafe.getShort()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Unsafe.getShort()方法的具体详情如下:
包路径:sun.misc.Unsafe
类名称:Unsafe
方法名:getShort

Unsafe.getShort介绍

暂无

代码示例

代码示例来源:origin: netty/netty

static short getShort(long address) {
  return UNSAFE.getShort(address);
}

代码示例来源:origin: netty/netty

static short getShort(byte[] data, int index) {
  return UNSAFE.getShort(data, BYTE_ARRAY_BASE_OFFSET + index);
}

代码示例来源:origin: prestodb/presto

short getShortUnchecked(int index)
{
  return unsafe.getShort(base, address + index);
}

代码示例来源:origin: redisson/redisson

@Override
public short getShort(long byteIndex) {
  return unsafe.getShort(baseAdress + byteIndex);
}

代码示例来源:origin: redisson/redisson

static short getShort(byte[] data, int index) {
  return UNSAFE.getShort(data, BYTE_ARRAY_BASE_OFFSET + index);
}

代码示例来源:origin: redisson/redisson

static short getShort(long address) {
  return UNSAFE.getShort(address);
}

代码示例来源:origin: neo4j/neo4j

public static short getShort( Object obj, long offset )
{
  return unsafe.getShort( obj, offset );
}

代码示例来源:origin: apache/ignite

/**
 * Gets short value from object field.
 *
 * @param obj Object.
 * @param fieldOff Field offset.
 * @return Short value from object field.
 */
public static short getShortField(Object obj, long fieldOff) {
  return UNSAFE.getShort(obj, fieldOff);
}

代码示例来源:origin: apache/hbase

/**
 * Reads a short value at the given Object's offset considering it was written in big-endian
 * format.
 * @param ref
 * @param offset
 * @return short value at offset
 */
public static short toShort(Object ref, long offset) {
 if (LITTLE_ENDIAN) {
  return Short.reverseBytes(theUnsafe.getShort(ref, offset));
 }
 return theUnsafe.getShort(ref, offset);
}

代码示例来源:origin: apache/hbase

/**
 * Converts a byte array to a short value considering it was written in big-endian format.
 * @param bytes byte array
 * @param offset offset into array
 * @return the short value
 */
public static short toShort(byte[] bytes, int offset) {
 if (LITTLE_ENDIAN) {
  return Short.reverseBytes(theUnsafe.getShort(bytes, offset + BYTE_ARRAY_BASE_OFFSET));
 } else {
  return theUnsafe.getShort(bytes, offset + BYTE_ARRAY_BASE_OFFSET);
 }
}

代码示例来源:origin: prestodb/presto

public static short getShort(byte[] bytes, int index)
{
  checkIndexLength(bytes.length, index, SIZE_OF_SHORT);
  return unsafe.getShort(bytes, ((long) ARRAY_BYTE_BASE_OFFSET) + index);
}

代码示例来源:origin: redisson/redisson

@Override
public short getShort(long byteIndex) {
  checkIndex(byteIndex,2);
  return unsafe.getShort(base, off + byteIndex);
}

代码示例来源:origin: redisson/redisson

public final int getShortValue(Object obj) throws IllegalAccessException {
  if (!isAndroid && memOffset >= 0) {
    return FSTUtil.unFlaggedUnsafe.getShort(obj, memOffset);
  }
  return field.getShort(obj);
}

代码示例来源:origin: apache/hbase

/**
 * Reads bytes at the given offset as a short value.
 * @param buf
 * @param offset
 * @return short value at offset
 */
static short getAsShort(ByteBuffer buf, int offset) {
 if (buf.isDirect()) {
  return theUnsafe.getShort(((DirectBuffer) buf).address() + offset);
 }
 return theUnsafe.getShort(buf.array(), BYTE_ARRAY_BASE_OFFSET + buf.arrayOffset() + offset);
}

代码示例来源:origin: neo4j/neo4j

public static short getShort( long address )
{
  checkAccess( address, Short.BYTES );
  return unsafe.getShort( address );
}

代码示例来源:origin: apache/ignite

/**
 * Gets short value from byte array. Alignment aware.
 *
 * @param arr Byte array.
 * @param off Offset.
 * @return Short value from byte array.
 */
public static short getShort(byte[] arr, long off) {
  return UNALIGNED ? UNSAFE.getShort(arr, off) : getShortByByte(arr, off, BIG_ENDIAN);
}

代码示例来源:origin: apache/ignite

/**
 * Gets short value from given address. Alignment aware.
 *
 * @param addr Address.
 * @return Short value from given address.
 */
public static short getShort(long addr) {
  return UNALIGNED ? UNSAFE.getShort(addr) : getShortByByte(addr, BIG_ENDIAN);
}

代码示例来源:origin: apache/ignite

/**
 * Gets short value from byte array assuming that value stored in little-endian byte order and native byte order
 * is big-endian. Alignment aware.
 *
 * @param arr Byte array.
 * @param off Offset.
 * @return Short value from byte array.
 */
public static short getShortLE(byte[] arr, long off) {
  return UNALIGNED ? Short.reverseBytes(UNSAFE.getShort(arr, off)) : getShortByByte(arr, off, false);
}

代码示例来源:origin: apache/ignite

/**
 * Gets short value from given address assuming that value stored in little-endian byte order and native byte order
 * is big-endian. Alignment aware.
 *
 * @param addr Address.
 * @return Short value from given address.
 */
public static short getShortLE(long addr) {
  return UNALIGNED ? Short.reverseBytes(UNSAFE.getShort(addr)) : getShortByByte(addr, false);
}

代码示例来源:origin: netty/netty

case 7:
  return ((hash * HASH_CODE_C1 + hashCodeAsciiSanitize(UNSAFE.getByte(bytes, baseOffset)))
         * HASH_CODE_C2 + hashCodeAsciiSanitize(UNSAFE.getShort(bytes, baseOffset + 1)))
         * HASH_CODE_C1 + hashCodeAsciiSanitize(UNSAFE.getInt(bytes, baseOffset + 3));
case 6:
  return (hash * HASH_CODE_C1 + hashCodeAsciiSanitize(UNSAFE.getShort(bytes, baseOffset)))
         * HASH_CODE_C2 + hashCodeAsciiSanitize(UNSAFE.getInt(bytes, baseOffset + 2));
case 5:
case 3:
  return (hash * HASH_CODE_C1 + hashCodeAsciiSanitize(UNSAFE.getByte(bytes, baseOffset)))
         * HASH_CODE_C2 + hashCodeAsciiSanitize(UNSAFE.getShort(bytes, baseOffset + 1));
case 2:
  return hash * HASH_CODE_C1 + hashCodeAsciiSanitize(UNSAFE.getShort(bytes, baseOffset));
case 1:
  return hash * HASH_CODE_C1 + hashCodeAsciiSanitize(UNSAFE.getByte(bytes, baseOffset));

相关文章

Unsafe类方法