@Test public void testCompareKey() throws Exception { long adr = Uns.allocate(MIN_ALLOC_LEN); KeyBuffer key = new KeyBuffer(11); try { HashEntries.init(0L, 11, 0, adr, Util.SENTINEL_NOT_PRESENT, 0L); ByteBuffer keyBuffer = key.byteBuffer(); keyBuffer.putInt(0x98765432); keyBuffer.putInt(0xabcdabba); keyBuffer.put((byte)(0x44 & 0xff)); keyBuffer.put((byte)(0x55 & 0xff)); keyBuffer.put((byte)(0x88 & 0xff)); key.finish(Hasher.create(HashAlgorithm.MURMUR3)); Uns.setMemory(adr, Util.ENTRY_OFF_DATA, 11, (byte) 0); assertFalse(key.sameKey(adr)); Uns.copyMemory(key.buffer, 0, adr, Util.ENTRY_OFF_DATA, 11); HashEntries.init(key.hash(), 11, 0, adr, Util.SENTINEL_NOT_PRESENT, 0L); assertTrue(key.sameKey(adr)); } finally { Uns.free(adr); } }
static void init(long hash, int keyLen, int valueLen, long hashEntryAdr, int sentinel, long expireAt) { Uns.putLong(hashEntryAdr, Util.ENTRY_OFF_EXPIRE_AT, expireAt); Uns.putLong(hashEntryAdr, Util.ENTRY_OFF_HASH, hash); setNext(hashEntryAdr, 0L); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_KEY_LENGTH, keyLen); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_VALUE_LENGTH, valueLen); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_REFCOUNT, 1); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_GENERATION, Util.GEN_EDEN); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_SENTINEL, sentinel); }
HashEntries { static void init(long hash, int keyLen, int valueLen, long hashEntryAdr, int sentinel, long expireAt) { Uns.putLong(hashEntryAdr, Util.ENTRY_OFF_EXPIRE_AT, expireAt); Uns.putLong(hashEntryAdr, Util.ENTRY_OFF_HASH, hash); setNext(hashEntryAdr, 0L); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_KEY_LENGTH, keyLen); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_VALUE_LENGTH, valueLen); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_REFCOUNT, 1); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_GENERATION, Util.GEN_EDEN); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_SENTINEL, sentinel); } }
HashEntries { static void init(long hash, int keyLen, int valueLen, long hashEntryAdr, int sentinel, long expireAt) { Uns.putLong(hashEntryAdr, Util.ENTRY_OFF_EXPIRE_AT, expireAt); Uns.putLong(hashEntryAdr, Util.ENTRY_OFF_HASH, hash); setNext(hashEntryAdr, 0L); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_KEY_LENGTH, keyLen); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_VALUE_LENGTH, valueLen); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_REFCOUNT, 1); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_GENERATION, Util.GEN_EDEN); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_SENTINEL, sentinel); }  }
HashEntries { static void init(long hash, int keyLen, int valueLen, long hashEntryAdr, int sentinel, long expireAt) { Uns.putLong(hashEntryAdr, Util.ENTRY_OFF_EXPIRE_AT, expireAt); Uns.putLong(hashEntryAdr, Util.ENTRY_OFF_HASH, hash); setNext(hashEntryAdr, 0L); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_KEY_LENGTH, keyLen); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_VALUE_LENGTH, valueLen); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_REFCOUNT, 1); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_GENERATION, Util.GEN_EDEN); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_SENTINEL, sentinel); }   }
HashEntries { static void init(long hash, int keyLen, int valueLen, long hashEntryAdr, int sentinel, long expireAt) { Uns.putLong(hashEntryAdr, Util.ENTRY_OFF_EXPIRE_AT, expireAt); Uns.putLong(hashEntryAdr, Util.ENTRY_OFF_HASH, hash); setNext(hashEntryAdr, 0L); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_KEY_LENGTH, keyLen); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_VALUE_LENGTH, valueLen); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_REFCOUNT, 1); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_GENERATION, Util.GEN_EDEN); Uns.putInt(hashEntryAdr, Util.ENTRY_OFF_SENTINEL, sentinel); }    }