/** * Compares memory. * * @param ptr Pointer. * @param bytes Bytes to compare. * @return {@code True} if equals. */ public static boolean compare(long ptr, byte[] bytes) { return compare(ptr, bytes, 0, bytes.length); }
/** * Checks if keys are equal. * * @param ptr Pointer. * @param keyBytes Key bytes to compare. * @param mem Memory. * @return {@code True} if equal. */ static boolean keyEquals(long ptr, byte[] keyBytes, GridUnsafeMemory mem) { long len = readKeyLength(ptr, mem); return len == keyBytes.length && GridUnsafeMemory.compare(ptr + HEADER_SIZE, keyBytes); } }
/** * @param s String. * @throws Exception If failed. */ public void checkCompare(String s) throws Exception { byte[] bytes = s.getBytes(); int size = bytes.length + 8; GridUnsafeMemory mem = new GridUnsafeMemory(size); for (int i = 0; i < 8; i++) { long addr = mem.allocate(size); long ptr = addr + i; try { mem.writeBytes(ptr, bytes); assert mem.compare(ptr, bytes); byte[] read = mem.readBytes(ptr, bytes.length); assert Arrays.equals(bytes, read); } finally { mem.release(addr, size); } } }
if (c2.offheap()) return GridUnsafeMemory.compare(c1.curFieldPos + c1.ptr + off, c2.curFieldPos + c2.ptr + off, len);
/** * Compares memory. * * @param ptr Pointer. * @param bytes Bytes to compare. * @return {@code True} if equals. */ public static boolean compare(long ptr, byte[] bytes) { return compare(ptr, bytes, 0, bytes.length); }
/** * Checks if keys are equal. * * @param ptr Pointer. * @param keyBytes Key bytes to compare. * @param mem Memory. * @return {@code True} if equal. */ static boolean keyEquals(long ptr, byte[] keyBytes, GridUnsafeMemory mem) { long len = readKeyLength(ptr, mem); return len == keyBytes.length && GridUnsafeMemory.compare(ptr + HEADER_SIZE, keyBytes); } }
if (c2.offheap()) return GridUnsafeMemory.compare(c1.curFieldPos + c1.ptr + off, c2.curFieldPos + c2.ptr + off, len);