@Override public final void clear() { clearInternal(); fireCleared(); }
@Override public final void freeMapping(long encoding, int hash, boolean removal) { if (hasListeners()) { ByteBuffer binaryKey = readBinaryKey(encoding); free(encoding); fireFreed(encoding, hash, binaryKey, removal); } else { free(encoding); } }
@SuppressWarnings("unchecked") @Override public K readKey(long encoding, int hashCode) { if (keyPortability instanceof WriteBackPortability<?>) { return (K) ((WriteBackPortability<? super K>) keyPortability).decode(readKeyBuffer(encoding), getKeyWriteContext(encoding)); } else { return (K) keyPortability.decode(readKeyBuffer(encoding)); } }
@SuppressWarnings("unchecked") @Override public V readValue(long encoding) { if (valuePortability instanceof WriteBackPortability<?>) { return (V) ((WriteBackPortability<? super V>) valuePortability).decode(readValueBuffer(encoding), getValueWriteContext(encoding)); } else { return (V) valuePortability.decode(readValueBuffer(encoding)); } }
@Override public boolean equalsBinaryKey(ByteBuffer binaryKey, long encoding) { return binaryKey.equals(readBinaryKey(encoding)) || equalsKey(keyPortability.decode(binaryKey.duplicate()), encoding); }
@Override public final Long writeMapping(K key, V value, int hash, int metadata) { Long result; if (lastMapping != null && lastMapping.getKey() == key && lastMapping.getValue() == value) { result = writeMappingBuffers(lastMapping.getEncodedKey(), lastMapping.getEncodedValue(), hash); } else { ByteBuffer keyBuffer = keyPortability.encode(key); ByteBuffer valueBuffer = valuePortability.encode(value); result = writeMappingBuffers(keyBuffer.duplicate(), valueBuffer.duplicate(), hash); lastMapping = new CachedEncode<>(key, value, keyBuffer, valueBuffer, result); } if (result != null) { fireWritten(key, value, lastMapping.getEncodedKey(), lastMapping.getEncodedValue(), hash, metadata, result); } return result; }
@SuppressWarnings("unchecked") @Override public K readKey(long encoding, int hashCode) { if (keyPortability instanceof WriteBackPortability<?>) { return (K) ((WriteBackPortability<? super K>) keyPortability).decode(readKeyBuffer(encoding), getKeyWriteContext(encoding)); } else { return (K) keyPortability.decode(readKeyBuffer(encoding)); } }
@SuppressWarnings("unchecked") @Override public V readValue(long encoding) { if (valuePortability instanceof WriteBackPortability<?>) { return (V) ((WriteBackPortability<? super V>) valuePortability).decode(readValueBuffer(encoding), getValueWriteContext(encoding)); } else { return (V) valuePortability.decode(readValueBuffer(encoding)); } }
@Override public boolean equalsBinaryKey(ByteBuffer binaryKey, long encoding) { return binaryKey.equals(readBinaryKey(encoding)) || equalsKey(keyPortability.decode(binaryKey.duplicate()), encoding); }
@Override public final Long writeMapping(K key, V value, int hash, int metadata) { Long result; if (lastMapping != null && lastMapping.getKey() == key && lastMapping.getValue() == value) { result = writeMappingBuffers(lastMapping.getEncodedKey(), lastMapping.getEncodedValue(), hash); } else { ByteBuffer keyBuffer = keyPortability.encode(key); ByteBuffer valueBuffer = valuePortability.encode(value); result = writeMappingBuffers(keyBuffer.duplicate(), valueBuffer.duplicate(), hash); lastMapping = new CachedEncode<>(key, value, keyBuffer, valueBuffer, result); } if (result != null) { fireWritten(key, value, lastMapping.getEncodedKey(), lastMapping.getEncodedValue(), hash, metadata, result); } return result; }
@Override public final void freeMapping(long encoding, int hash, boolean removal) { if (hasListeners()) { ByteBuffer binaryKey = readBinaryKey(encoding); free(encoding); fireFreed(encoding, hash, binaryKey, removal); } else { free(encoding); } }
@Override public final void clear() { clearInternal(); fireCleared(); }