protected void removeAtTableOffset(int offset, boolean shrink) { IntBuffer entry = ((IntBuffer) hashtable.duplicate().position(offset).limit(offset + ENTRY_SIZE)).slice(); if (isPresent(entry)) { storageEngine.freeMapping(readLong(entry, ENCODING), entry.get(KEY_HASHCODE), true); entry.put(STATUS, STATUS_REMOVED); slotRemoved(entry); if (shrink) { shrink(); } } else { throw new AssertionError(); } }
protected void removeAtTableOffset(int offset, boolean shrink) { IntBuffer entry = ((IntBuffer) hashtable.duplicate().position(offset).limit(offset + ENTRY_SIZE)).slice(); if (isPresent(entry)) { storageEngine.freeMapping(readLong(entry, ENCODING), entry.get(KEY_HASHCODE), true); entry.put(STATUS, STATUS_REMOVED); slotRemoved(entry); if (shrink) { shrink(); } } else { throw new AssertionError(); } }
@Override public void remove() { throw new UnsupportedOperationException(); }
@Override public void remove() { throw new UnsupportedOperationException(); }
@SuppressWarnings("unchecked") protected boolean removeMapping(Object o) { freePendingTables(); if (!(o instanceof Entry<?, ?>)) { return false; } Entry<K, V> e = (Entry<K, V>) o; Object key = e.getKey(); int hash = key.hashCode(); hashtable.position(indexFor(spread(hash))); for (int i = 0; i < reprobeLimit(); i++) { if (!hashtable.hasRemaining()) { hashtable.rewind(); } IntBuffer entry = (IntBuffer) hashtable.slice().limit(ENTRY_SIZE); if (isTerminating(entry)) { return false; } else if (isPresent(entry) && keyEquals(key, hash, readLong(entry, ENCODING), entry.get(KEY_HASHCODE)) && storageEngine.equalsValue(e.getValue(), readLong(entry, ENCODING))) { storageEngine.freeMapping(readLong(entry, ENCODING), entry.get(KEY_HASHCODE), true); entry.put(STATUS, STATUS_REMOVED); slotRemoved(entry); shrink(); return true; } else { hashtable.position(hashtable.position() + ENTRY_SIZE); } } return false; }
@SuppressWarnings("unchecked") protected boolean removeMapping(Object o) { freePendingTables(); if (!(o instanceof Entry<?, ?>)) { return false; } Entry<K, V> e = (Entry<K, V>) o; Object key = e.getKey(); int hash = key.hashCode(); hashtable.position(indexFor(spread(hash))); for (int i = 0; i < reprobeLimit(); i++) { if (!hashtable.hasRemaining()) { hashtable.rewind(); } IntBuffer entry = (IntBuffer) hashtable.slice().limit(ENTRY_SIZE); if (isTerminating(entry)) { return false; } else if (isPresent(entry) && keyEquals(key, hash, readLong(entry, ENCODING), entry.get(KEY_HASHCODE)) && storageEngine.equalsValue(e.getValue(), readLong(entry, ENCODING))) { storageEngine.freeMapping(readLong(entry, ENCODING), entry.get(KEY_HASHCODE), true); entry.put(STATUS_REMOVED); slotRemoved(entry); shrink(); return true; } else { hashtable.position(hashtable.position() + ENTRY_SIZE); } } return false; }
return false; } else if (isPresent(entry) && keyEquals(key, hash, readLong(entry, ENCODING), entry.get(KEY_HASHCODE))) { storageEngine.freeMapping(readLong(entry, ENCODING), entry.get(KEY_HASHCODE), true);
@SuppressWarnings("unchecked") K removedKey = (K) storageEngine.readKey(readLong(entry, ENCODING), hash); storageEngine.freeMapping(readLong(entry, ENCODING), entry.get(KEY_HASHCODE), true);
@SuppressWarnings("unchecked") K removedKey = (K) storageEngine.readKey(readLong(entry, ENCODING), hash); storageEngine.freeMapping(readLong(entry, ENCODING), entry.get(KEY_HASHCODE), true);
return false; } else if (isPresent(entry) && keyEquals(key, hash, readLong(entry, ENCODING), entry.get(KEY_HASHCODE))) { storageEngine.freeMapping(readLong(entry, ENCODING), entry.get(KEY_HASHCODE), true);
MetadataTuple<V> result = remappingFunction.apply(key, existingValue); if (result == null) { storageEngine.freeMapping(existingEncoding, hash, true); entry.put(STATUS_REMOVED); slotRemoved(entry); int [] newEntry = writeEntry(key, hash, result.value(), result.metadata()); if (hashtable != originalTable || !isPresent(entry)) { storageEngine.freeMapping(readLong(newEntry, ENCODING), newEntry[KEY_HASHCODE], false); return computeIfPresentWithMetadata(key, remappingFunction); //not exactly ideal - but technically correct storageEngine.freeMapping(readLong(entry, ENCODING), entry.get(KEY_HASHCODE), false); entry.put(newEntry); slotUpdated((IntBuffer) entry.flip(), readLong(entry, ENCODING));
MetadataTuple<V> result = remappingFunction.apply(key, existingValue); if (result == null) { storageEngine.freeMapping(existingEncoding, hash, true); entry.put(STATUS, STATUS_REMOVED); slotRemoved(entry); int [] newEntry = writeEntry(key, hash, result.value(), result.metadata()); if (hashtable != originalTable || !isPresent(entry)) { storageEngine.freeMapping(readLong(newEntry, ENCODING), newEntry[KEY_HASHCODE], false); return computeIfPresentWithMetadata(key, remappingFunction); //not exactly ideal - but technically correct storageEngine.freeMapping(readLong(entry, ENCODING), entry.get(KEY_HASHCODE), false); entry.put(newEntry); slotUpdated((IntBuffer) entry.flip(), readLong(entry, ENCODING));
@Override @FindbugsSuppressWarnings("VO_VOLATILE_INCREMENT") public long installMappingForHashAndEncoding(int pojoHash, ByteBuffer offheapBinaryKey, ByteBuffer offheapBinaryValue, int metadata) { freePendingTables(); int[] newEntry = installEntry(offheapBinaryKey, pojoHash, offheapBinaryValue, metadata); int start = indexFor(spread(pojoHash)); hashtable.position(start); int limit = reprobeLimit(); for (int i = 0; i < limit; i++) { if (!hashtable.hasRemaining()) { hashtable.rewind(); } IntBuffer entry = (IntBuffer) hashtable.slice().limit(ENTRY_SIZE); if (isAvailable(entry)) { if (isRemoved(entry)) { removedSlots--; } entry.put(newEntry); slotAdded(entry); hit(entry); return readLong(newEntry, ENCODING); } else { hashtable.position(hashtable.position() + ENTRY_SIZE); } } storageEngine.freeMapping(readLong(newEntry, ENCODING), newEntry[KEY_HASHCODE], false); //XXX: further contemplate the boolean value here // hit reprobe limit - must rehash expand(start, limit); return installMappingForHashAndEncoding(pojoHash, offheapBinaryKey, offheapBinaryValue, metadata); }
@Override @FindbugsSuppressWarnings("VO_VOLATILE_INCREMENT") public long installMappingForHashAndEncoding(int pojoHash, ByteBuffer offheapBinaryKey, ByteBuffer offheapBinaryValue, int metadata) { freePendingTables(); int[] newEntry = installEntry(offheapBinaryKey, pojoHash, offheapBinaryValue, metadata); int start = indexFor(spread(pojoHash)); hashtable.position(start); int limit = reprobeLimit(); for (int i = 0; i < limit; i++) { if (!hashtable.hasRemaining()) { hashtable.rewind(); } IntBuffer entry = (IntBuffer) hashtable.slice().limit(ENTRY_SIZE); if (isAvailable(entry)) { if (isRemoved(entry)) { removedSlots--; } entry.put(newEntry); slotAdded(entry); hit(entry); return readLong(newEntry, ENCODING); } else { hashtable.position(hashtable.position() + ENTRY_SIZE); } } storageEngine.freeMapping(readLong(newEntry, ENCODING), newEntry[KEY_HASHCODE], false); //XXX: further contemplate the boolean value here // hit reprobe limit - must rehash expand(start, limit); return installMappingForHashAndEncoding(pojoHash, offheapBinaryKey, offheapBinaryValue, metadata); }
} else if (isPresent(laterEntry) && keyEquals(key, hash, readLong(laterEntry, ENCODING), laterEntry.get(KEY_HASHCODE))) { V old = (V) storageEngine.readValue(readLong(laterEntry, ENCODING)); storageEngine.freeMapping(readLong(laterEntry, ENCODING), laterEntry.get(KEY_HASHCODE), false); long oldEncoding = readLong(laterEntry, ENCODING); laterEntry.put(newEntry); storageEngine.invalidateCache(); V old = (V) storageEngine.readValue(readLong(entry, ENCODING)); storageEngine.freeMapping(readLong(entry, ENCODING), entry.get(KEY_HASHCODE), false); long oldEncoding = readLong(entry, ENCODING); entry.put(newEntry); storageEngine.freeMapping(readLong(newEntry, ENCODING), newEntry[KEY_HASHCODE], true);
} else if (isPresent(laterEntry) && keyEquals(key, hash, readLong(laterEntry, ENCODING), laterEntry.get(KEY_HASHCODE))) { V old = (V) storageEngine.readValue(readLong(laterEntry, ENCODING)); storageEngine.freeMapping(readLong(laterEntry, ENCODING), laterEntry.get(KEY_HASHCODE), false); long oldEncoding = readLong(laterEntry, ENCODING); laterEntry.put(newEntry); storageEngine.invalidateCache(); V old = (V) storageEngine.readValue(readLong(entry, ENCODING)); storageEngine.freeMapping(readLong(entry, ENCODING), entry.get(KEY_HASHCODE), false); long oldEncoding = readLong(entry, ENCODING); entry.put(newEntry); storageEngine.freeMapping(readLong(newEntry, ENCODING), newEntry[KEY_HASHCODE], false); //XXX: further contemplate the boolean value here
} else if (isPresent(laterEntry) && keyEquals(key, hash, readLong(laterEntry, ENCODING), laterEntry.get(KEY_HASHCODE))) { V old = (V) storageEngine.readValue(readLong(laterEntry, ENCODING)); storageEngine.freeMapping(readLong(laterEntry, ENCODING), laterEntry.get(KEY_HASHCODE), false); long oldEncoding = readLong(laterEntry, ENCODING); laterEntry.put(newEntry); storageEngine.invalidateCache(); V old = (V) storageEngine.readValue(readLong(entry, ENCODING)); storageEngine.freeMapping(readLong(entry, ENCODING), entry.get(KEY_HASHCODE), false); long oldEncoding = readLong(entry, ENCODING); entry.put(newEntry); storageEngine.freeMapping(readLong(newEntry, ENCODING), newEntry[KEY_HASHCODE], true);
} else if (isPresent(laterEntry) && keyEquals(key, hash, readLong(laterEntry, ENCODING), laterEntry.get(KEY_HASHCODE))) { V old = (V) storageEngine.readValue(readLong(laterEntry, ENCODING)); storageEngine.freeMapping(readLong(laterEntry, ENCODING), laterEntry.get(KEY_HASHCODE), false); long oldEncoding = readLong(laterEntry, ENCODING); laterEntry.put(newEntry); storageEngine.invalidateCache(); V old = (V) storageEngine.readValue(readLong(entry, ENCODING)); storageEngine.freeMapping(readLong(entry, ENCODING), entry.get(KEY_HASHCODE), false); long oldEncoding = readLong(entry, ENCODING); entry.put(newEntry); storageEngine.freeMapping(readLong(newEntry, ENCODING), newEntry[KEY_HASHCODE], false); //XXX: further contemplate the boolean value here
int [] newEntry = writeEntry(key, hash, result.value(), result.metadata()); if (hashtable != originalTable) { storageEngine.freeMapping(readLong(newEntry, ENCODING), newEntry[KEY_HASHCODE], false); return computeIfAbsentWithMetadata(key, mappingFunction); } else if (!isAvailable(entry)) {
int [] newEntry = writeEntry(key, hash, result.value(), result.metadata()); if (hashtable != originalTable) { storageEngine.freeMapping(readLong(newEntry, ENCODING), newEntry[KEY_HASHCODE], false); return computeIfAbsentWithMetadata(key, mappingFunction); } else if (!isAvailable(entry)) {