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

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

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

Unsafe.getByte介绍

暂无

代码示例

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

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

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

static byte getByte(long address) {
  return UNSAFE.getByte(address);
}

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

byte getByteUnchecked(int index)
{
  return unsafe.getByte(base, address + index);
}

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

@Override
public boolean getBool(long byteIndex) {
  return unsafe.getByte(baseAdress +byteIndex) != 0;
}

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

@Override
public byte get(long byteIndex) {
  return unsafe.getByte(baseAdress +byteIndex);
}

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

static byte getByte(long address) {
  return UNSAFE.getByte(address);
}

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

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

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

public static byte getByte( Object obj, long offset )
{
  return unsafe.getByte( obj, offset );
}

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

/**
  * Returns the byte at the given offset of the object
  * @param ref
  * @param offset
  * @return the byte at the given offset
  */
 public static byte toByte(Object ref, long offset) {
  return theUnsafe.getByte(ref, offset);
 }
}

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

/**
 * Gets byte value from given address.
 *
 * @param addr Address.
 * @return Byte value from given address.
 */
public static byte getByte(long addr) {
  return UNSAFE.getByte(addr);
}

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

/**
 * @param addr Address.
 * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
 */
private static char getCharByByte(long addr, boolean bigEndian) {
  if (bigEndian)
    return (char)(UNSAFE.getByte(addr) << 8 | (UNSAFE.getByte(addr + 1) & 0xff));
  else
    return (char)(UNSAFE.getByte(addr + 1) << 8 | (UNSAFE.getByte(addr) & 0xff));
}

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

/**
 * Gets byte value from object field.
 *
 * @param obj Object.
 * @param fieldOff Field offset.
 * @return Byte value from object field.
 */
public static byte getByteField(Object obj, long fieldOff) {
  return UNSAFE.getByte(obj, fieldOff);
}

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

/**
 * @param obj Object.
 * @param off Offset.
 * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
 */
private static short getShortByByte(Object obj, long off, boolean bigEndian) {
  if (bigEndian)
    return (short)(UNSAFE.getByte(obj, off) << 8 | (UNSAFE.getByte(obj, off + 1) & 0xff));
  else
    return (short)(UNSAFE.getByte(obj, off + 1) << 8 | (UNSAFE.getByte(obj, off) & 0xff));
}

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

@Override
public final byte get(int index) {
  final long pos = address + index;
  if (index >= 0 && pos < addressLimit) {
    return UNSAFE.getByte(heapMemory, pos);
  }
  else if (address > addressLimit) {
    throw new IllegalStateException("segment has been freed");
  }
  else {
    // index is in fact invalid
    throw new IndexOutOfBoundsException();
  }
}

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

@Override
public byte get(long byteIndex) {
  checkIndex(byteIndex,1);
  return unsafe.getByte(base,off+byteIndex);
}

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

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

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

@Override
public boolean getBool(long byteIndex) {
  checkIndex(byteIndex,1);
  return unsafe.getByte(base,off+byteIndex) != 0;
}

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

public static byte getByte( long address )
{
  checkAccess( address, Byte.BYTES );
  return unsafe.getByte( address );
}

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

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));
         * HASH_CODE_C2 + hashCodeAsciiSanitize(UNSAFE.getInt(bytes, baseOffset + 2));
case 5:
  return (hash * HASH_CODE_C1 + hashCodeAsciiSanitize(UNSAFE.getByte(bytes, baseOffset)))
         * HASH_CODE_C2 + hashCodeAsciiSanitize(UNSAFE.getInt(bytes, baseOffset + 1));
case 4:
  return hash * HASH_CODE_C1 + hashCodeAsciiSanitize(UNSAFE.getInt(bytes, baseOffset));
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));
default:
  return hash;

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

private static long updateTail(long hash, Object base, long address, int index, int length)
{
  while (index <= length - 8) {
    hash = updateTail(hash, unsafe.getLong(base, address + index));
    index += 8;
  }
  if (index <= length - 4) {
    hash = updateTail(hash, unsafe.getInt(base, address + index));
    index += 4;
  }
  while (index < length) {
    hash = updateTail(hash, unsafe.getByte(base, address + index));
    index++;
  }
  hash = finalShuffle(hash);
  return hash;
}

相关文章

Unsafe类方法