Package org.infinispan.container.offheap
Class OffHeapEntryFactoryImpl
java.lang.Object
org.infinispan.container.offheap.OffHeapEntryFactoryImpl
- All Implemented Interfaces:
KeyValueMetadataSizeCalculator<WrappedBytes,,WrappedBytes> OffHeapEntryFactory
Factory that can create CacheEntry instances from off-heap memory.
- Since:
- 9.0
- Author:
- wburns
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongcalculateSize(WrappedBytes key, WrappedBytes value, Metadata metadata, PrivateMetadata internalMetadata) Method used to calculate how much memory in size the key, value, metadata and internal metadata use.longcreate(WrappedBytes key, int hashCode, InternalCacheEntry<WrappedBytes, WrappedBytes> ice) Creates an off-heap entry using the provided key value and metadatabooleanequalsKey(long address, WrappedBytes wrappedBytes, int hashCode) Returns whether the given key as bytes is the same key as the key stored in the entry for the given address.fromMemory(long address) Assumes the address doesn't contain the linked pointer at the beginningintgetHashCode(long entryAddress) Returns the hashCode of the address.byte[]getKey(long address) Returns the key of the address.longgetNext(long entryAddress) Returns the address to the next linked pointer if there is one for this bucket or 0 if there isn't onelonggetSize(long entryAddress, boolean includeAllocationOverhead) Returns how many bytes in memory this address location uses assuming it is anInternalCacheEntry.booleanisExpired(long address) Returns whether entry is expired.voidsetNext(long entryAddress, long value) Called to update the next pointer index when a collision occurs requiring a linked list within the entries themselvesvoidstart()longupdateMaxIdle(long address, long currentTimeMillis) Update max idle time for an entry.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.infinispan.container.offheap.OffHeapEntryFactory
calculateSize, equalsKey
-
Constructor Details
-
OffHeapEntryFactoryImpl
public OffHeapEntryFactoryImpl()
-
-
Method Details
-
start
public void start() -
create
public long create(WrappedBytes key, int hashCode, InternalCacheEntry<WrappedBytes, WrappedBytes> ice) Description copied from interface:OffHeapEntryFactoryCreates an off-heap entry using the provided key value and metadata- Specified by:
createin interfaceOffHeapEntryFactory- Parameters:
key- the key to usehashCode- the hashCode of the keyice- the internal entry to use- Returns:
- the address of where the entry was created
-
getSize
public long getSize(long entryAddress, boolean includeAllocationOverhead) Description copied from interface:OffHeapEntryFactoryReturns how many bytes in memory this address location uses assuming it is anInternalCacheEntry.- Specified by:
getSizein interfaceOffHeapEntryFactory- Parameters:
entryAddress- the address of the entryincludeAllocationOverhead- if true, align to 8 bytes and add 16 bytes allocation overhead- Returns:
- how many bytes this address was estimated to be
-
getNext
public long getNext(long entryAddress) Description copied from interface:OffHeapEntryFactoryReturns the address to the next linked pointer if there is one for this bucket or 0 if there isn't one- Specified by:
getNextin interfaceOffHeapEntryFactory- Parameters:
entryAddress- the address of the entry- Returns:
- the next address entry for this bucket or 0
-
setNext
public void setNext(long entryAddress, long value) Description copied from interface:OffHeapEntryFactoryCalled to update the next pointer index when a collision occurs requiring a linked list within the entries themselves- Specified by:
setNextin interfaceOffHeapEntryFactory- Parameters:
entryAddress- the address of the entry to updatevalue- the value of the linked node to set
-
getHashCode
public int getHashCode(long entryAddress) Description copied from interface:OffHeapEntryFactoryReturns the hashCode of the address. This- Specified by:
getHashCodein interfaceOffHeapEntryFactory- Parameters:
entryAddress- the address of the entry- Returns:
- the has code of the entry
-
getKey
public byte[] getKey(long address) Description copied from interface:OffHeapEntryFactoryReturns the key of the address.- Specified by:
getKeyin interfaceOffHeapEntryFactory- Parameters:
address- the address of the entry- Returns:
- the bytes for the key
-
fromMemory
Assumes the address doesn't contain the linked pointer at the beginning- Specified by:
fromMemoryin interfaceOffHeapEntryFactory- Parameters:
address- the address to read the entry from- Returns:
- the entry at the memory location
-
equalsKey
Description copied from interface:OffHeapEntryFactoryReturns whether the given key as bytes is the same key as the key stored in the entry for the given address.- Specified by:
equalsKeyin interfaceOffHeapEntryFactory- Parameters:
address- the address of the entry's key to checkwrappedBytes- the key to check equality withhashCode- the hashCode of the key- Returns:
- whether or not the keys are equal
-
isExpired
public boolean isExpired(long address) Returns whether entry is expired.- Specified by:
isExpiredin interfaceOffHeapEntryFactory- Parameters:
address- the address of the entry to check- Returns:
trueif the entry is expired,falseotherwise
-
calculateSize
public long calculateSize(WrappedBytes key, WrappedBytes value, Metadata metadata, PrivateMetadata internalMetadata) Description copied from interface:OffHeapEntryFactoryMethod used to calculate how much memory in size the key, value, metadata and internal metadata use.- Specified by:
calculateSizein interfaceKeyValueMetadataSizeCalculator<WrappedBytes,WrappedBytes> - Specified by:
calculateSizein interfaceOffHeapEntryFactory- Parameters:
key- The key for this entry to be used in size calculationvalue- The value for this entry to be used in size calculationmetadata- The metadata for this entry to be used in size calculationinternalMetadata- The internal metadata for this entry to be used in size calculation- Returns:
- The size approximately in memory the key, value and metadata use.
-
updateMaxIdle
public long updateMaxIdle(long address, long currentTimeMillis) Description copied from interface:OffHeapEntryFactoryUpdate max idle time for an entry. This method will try to do an in place update of the access time, however if the new resulting value cannot fit it will allocate a new block of memory. The caller should free the old address in this case.- Specified by:
updateMaxIdlein interfaceOffHeapEntryFactory- Parameters:
address- the address of the entry's to updatecurrentTimeMillis- the timestamp to set for max idle access time (must be in milliseconds)- Returns:
- address of the new entry to use or 0 if the same one can be reused
-