List of usage examples for io.netty.util.internal PlatformDependent getLong
public static long getLong(long address)
From source file:org.apache.arrow.vector.util.ByteFunctionHelpers.java
License:Apache License
private static final int memEqual(final long laddr, int lStart, int lEnd, final long raddr, int rStart, final int rEnd) { int n = lEnd - lStart; if (n == rEnd - rStart) { long lPos = laddr + lStart; long rPos = raddr + rStart; while (n > 7) { long leftLong = PlatformDependent.getLong(lPos); long rightLong = PlatformDependent.getLong(rPos); if (leftLong != rightLong) { return 0; }/*from w w w . j a v a 2 s . co m*/ lPos += 8; rPos += 8; n -= 8; } while (n-- != 0) { byte leftByte = PlatformDependent.getByte(lPos); byte rightByte = PlatformDependent.getByte(rPos); if (leftByte != rightByte) { return 0; } lPos++; rPos++; } return 1; } else { return 0; } }
From source file:org.apache.arrow.vector.util.ByteFunctionHelpers.java
License:Apache License
private static final int memcmp(final long laddr, int lStart, int lEnd, final long raddr, int rStart, final int rEnd) { int lLen = lEnd - lStart; int rLen = rEnd - rStart; int n = Math.min(rLen, lLen); long lPos = laddr + lStart; long rPos = raddr + rStart; while (n > 7) { long leftLong = PlatformDependent.getLong(lPos); long rightLong = PlatformDependent.getLong(rPos); if (leftLong != rightLong) { return UnsignedLongs.compare(Long.reverseBytes(leftLong), Long.reverseBytes(rightLong)); }/*from w ww. j av a 2 s .c o m*/ lPos += 8; rPos += 8; n -= 8; } while (n-- != 0) { byte leftByte = PlatformDependent.getByte(lPos); byte rightByte = PlatformDependent.getByte(rPos); if (leftByte != rightByte) { return ((leftByte & 0xFF) - (rightByte & 0xFF)) > 0 ? 1 : -1; } lPos++; rPos++; } if (lLen == rLen) { return 0; } return lLen > rLen ? 1 : -1; }
From source file:org.apache.drill.exec.expr.fn.impl.XXHash.java
License:Apache License
private static long hash64bytes(long start, long bEnd, long seed) { long len = bEnd - start; long h64;//from w w w .j a v a2 s.c o m long p = start; // for long strings (greater than 32 bytes) if (len >= 32) { final long limit = bEnd - 32; long v1 = seed + PRIME64_1 + PRIME64_2; long v2 = seed + PRIME64_2; long v3 = seed + 0; long v4 = seed - PRIME64_1; do { v1 += PlatformDependent.getLong(p) * PRIME64_2; p = p + 8; v1 = Long.rotateLeft(v1, 31); v1 *= PRIME64_1; v2 += PlatformDependent.getLong(p) * PRIME64_2; p = p + 8; v2 = Long.rotateLeft(v2, 31); v2 *= PRIME64_1; v3 += PlatformDependent.getLong(p) * PRIME64_2; p = p + 8; v3 = Long.rotateLeft(v3, 31); v3 *= PRIME64_1; v4 += PlatformDependent.getLong(p) * PRIME64_2; p = p + 8; v4 = Long.rotateLeft(v4, 31); v4 *= PRIME64_1; } while (p <= limit); h64 = Long.rotateLeft(v1, 1) + Long.rotateLeft(v2, 7) + Long.rotateLeft(v3, 12) + Long.rotateLeft(v4, 18); v1 *= PRIME64_2; v1 = Long.rotateLeft(v1, 31); v1 *= PRIME64_1; h64 ^= v1; h64 = h64 * PRIME64_1 + PRIME64_4; v2 *= PRIME64_2; v2 = Long.rotateLeft(v2, 31); v2 *= PRIME64_1; h64 ^= v2; h64 = h64 * PRIME64_1 + PRIME64_4; v3 *= PRIME64_2; v3 = Long.rotateLeft(v3, 31); v3 *= PRIME64_1; h64 ^= v3; h64 = h64 * PRIME64_1 + PRIME64_4; v4 *= PRIME64_2; v4 = Long.rotateLeft(v4, 31); v4 *= PRIME64_1; h64 ^= v4; h64 = h64 * PRIME64_1 + PRIME64_4; } else { h64 = seed + PRIME64_5; } h64 += len; while (p + 8 <= bEnd) { long k1 = PlatformDependent.getLong(p); k1 *= PRIME64_2; k1 = Long.rotateLeft(k1, 31); k1 *= PRIME64_1; h64 ^= k1; h64 = Long.rotateLeft(h64, 27) * PRIME64_1 + PRIME64_4; p += 8; } if (p + 4 <= bEnd) { //IMPORTANT: we are expecting a long from these 4 bytes. Which means it is always positive long finalInt = getIntLittleEndian(p); h64 ^= finalInt * PRIME64_1; h64 = Long.rotateLeft(h64, 23) * PRIME64_2 + PRIME64_3; p += 4; } while (p < bEnd) { h64 ^= ((long) (PlatformDependent.getByte(p) & 0x00ff)) * PRIME64_5; h64 = Long.rotateLeft(h64, 11) * PRIME64_1; p++; } return applyFinalHashComputation(h64); }
From source file:org.apache.tajo.tuple.memory.UnSafeTuple.java
License:Apache License
@Override public long getInt8(int fieldId) { return PlatformDependent.getLong(getFieldAddr(fieldId)); }
From source file:org.apache.tajo.tuple.memory.UnSafeTuple.java
License:Apache License
@Override public double getFloat8(int fieldId) { return Double.longBitsToDouble(PlatformDependent.getLong(getFieldAddr(fieldId))); }
From source file:org.apache.tajo.tuple.memory.UnSafeTuple.java
License:Apache License
@Override public IntervalDatum getInterval(int fieldId) { long pos = getFieldAddr(fieldId); int months = PlatformDependent.getInt(pos); pos += SizeOf.SIZE_OF_INT;/* ww w . j av a2 s . c om*/ long millisecs = PlatformDependent.getLong(pos); return new IntervalDatum(months, millisecs); }