Class OffHeapEntryFactoryImpl

  • All Implemented Interfaces:
    org.infinispan.container.impl.KeyValueMetadataSizeCalculator<WrappedBytes,​WrappedBytes>, OffHeapEntryFactory

    public class OffHeapEntryFactoryImpl
    extends java.lang.Object
    implements OffHeapEntryFactory
    Factory that can create CacheEntry instances from off-heap memory.
    Since:
    9.0
    Author:
    wburns
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long calculateSize​(WrappedBytes key, WrappedBytes value, Metadata metadata)
      Method used to calculate how much memory in size the key, value and metadata use.
      long create​(WrappedBytes key, int hashCode, WrappedBytes value, Metadata metadata)
      Creates an off heap entry using the provided key value and metadata
      boolean equalsKey​(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.
      InternalCacheEntry<WrappedBytes,​WrappedBytes> fromMemory​(long address)
      Assumes the address doesn't contain the linked pointer at the beginning
      int getHashCode​(long entryAddress)
      Returns the hashCode of the address.
      byte[] getKey​(long address)
      Returns the key of the address.
      long getNext​(long entryAddress)
      Returns the address to the next linked pointer if there is one for this bucket or 0 if there isn't one
      long getSize​(long entryAddress, boolean includeAllocationOverhead)
      Returns how many bytes in memory this address location uses assuming it is an InternalCacheEntry.
      boolean isExpired​(long address)
      Returns whether entry is expired.
      void setNext​(long entryAddress, long value)
      Called to update the next pointer index when a collision occurs requiring a linked list within the entries themselves
      void start()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OffHeapEntryFactoryImpl

        public OffHeapEntryFactoryImpl()
    • Method Detail

      • start

        public void start()
      • create

        public long create​(WrappedBytes key,
                           int hashCode,
                           WrappedBytes value,
                           Metadata metadata)
        Description copied from interface: OffHeapEntryFactory
        Creates an off heap entry using the provided key value and metadata
        Specified by:
        create in interface OffHeapEntryFactory
        Parameters:
        key - the key to use
        hashCode - the hashCode of the key
        value - the value to use
        metadata - the metadata to use
        Returns:
        the address of where the entry was created
      • getSize

        public long getSize​(long entryAddress,
                            boolean includeAllocationOverhead)
        Description copied from interface: OffHeapEntryFactory
        Returns how many bytes in memory this address location uses assuming it is an InternalCacheEntry.
        Specified by:
        getSize in interface OffHeapEntryFactory
        Parameters:
        entryAddress - the address of the entry
        includeAllocationOverhead - 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: OffHeapEntryFactory
        Returns the address to the next linked pointer if there is one for this bucket or 0 if there isn't one
        Specified by:
        getNext in interface OffHeapEntryFactory
        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: OffHeapEntryFactory
        Called to update the next pointer index when a collision occurs requiring a linked list within the entries themselves
        Specified by:
        setNext in interface OffHeapEntryFactory
        Parameters:
        entryAddress - the address of the entry to update
        value - the value of the linked node to set
      • getHashCode

        public int getHashCode​(long entryAddress)
        Description copied from interface: OffHeapEntryFactory
        Returns the hashCode of the address. This
        Specified by:
        getHashCode in interface OffHeapEntryFactory
        Parameters:
        entryAddress - the address of the entry
        Returns:
        the has code of the entry
      • getKey

        public byte[] getKey​(long address)
        Description copied from interface: OffHeapEntryFactory
        Returns the key of the address.
        Specified by:
        getKey in interface OffHeapEntryFactory
        Parameters:
        address - the address of the entry
        Returns:
        the bytes for the key
      • equalsKey

        public boolean equalsKey​(long address,
                                 WrappedBytes wrappedBytes,
                                 int hashCode)
        Description copied from interface: OffHeapEntryFactory
        Returns whether the given key as bytes is the same key as the key stored in the entry for the given address.
        Specified by:
        equalsKey in interface OffHeapEntryFactory
        Parameters:
        address - the address of the entry's key to check
        wrappedBytes - the key to check equality with
        hashCode - 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:
        isExpired in interface OffHeapEntryFactory
        Parameters:
        address - the address of the entry to check
        Returns:
        true if the entry is expired, false otherwise
      • calculateSize

        public long calculateSize​(WrappedBytes key,
                                  WrappedBytes value,
                                  Metadata metadata)
        Description copied from interface: OffHeapEntryFactory
        Method used to calculate how much memory in size the key, value and metadata use.
        Specified by:
        calculateSize in interface org.infinispan.container.impl.KeyValueMetadataSizeCalculator<WrappedBytes,​WrappedBytes>
        Specified by:
        calculateSize in interface OffHeapEntryFactory
        Parameters:
        key - The key for this entry to be used in size calculation
        value - The value for this entry to be used in size calculation
        metadata - The metadata for this entry to be used in size calculation
        Returns:
        The size approximately in memory the key, value and metadata use.