Interface OffHeapEntryFactory

  • All Superinterfaces:
    KeyValueMetadataSizeCalculator<org.infinispan.commons.marshall.WrappedBytes,​org.infinispan.commons.marshall.WrappedBytes>
    All Known Implementing Classes:
    OffHeapEntryFactoryImpl

    public interface OffHeapEntryFactory
    extends KeyValueMetadataSizeCalculator<org.infinispan.commons.marshall.WrappedBytes,​org.infinispan.commons.marshall.WrappedBytes>
    Factory that can create InternalCacheEntry objects that use off-heap heap memory. These are stored by a long to symbolize the memory address.
    Since:
    9.0
    Author:
    wburns
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default long calculateSize​(org.infinispan.commons.marshall.WrappedBytes key, org.infinispan.commons.marshall.WrappedBytes value, Metadata metadata)
      Method used to calculate how much memory in size the key, value and metadata use.
      long calculateSize​(org.infinispan.commons.marshall.WrappedBytes key, org.infinispan.commons.marshall.WrappedBytes value, Metadata metadata, PrivateMetadata internalMetadata)
      Method used to calculate how much memory in size the key, value, metadata and internal metadata use.
      long create​(org.infinispan.commons.marshall.WrappedBytes key, int hashCode, InternalCacheEntry<org.infinispan.commons.marshall.WrappedBytes,​org.infinispan.commons.marshall.WrappedBytes> ice)
      Creates an off heap entry using the provided key value and metadata
      default boolean equalsKey​(long address, org.infinispan.commons.marshall.WrappedBytes wrappedBytes)
      Returns whether the given key as bytes is the same key as the key stored in the entry for the given address.
      boolean equalsKey​(long address, org.infinispan.commons.marshall.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<org.infinispan.commons.marshall.WrappedBytes,​org.infinispan.commons.marshall.WrappedBytes> fromMemory​(long address)
      Create an entry from the off heap pointer
      int getHashCode​(long address)
      Returns the hashCode of the address.
      byte[] getKey​(long address)
      Returns the key of the address.
      long getNext​(long address)
      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 address, 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 or not.
      void setNext​(long address, long value)
      Called to update the next pointer index when a collision occurs requiring a linked list within the entries themselves
      long updateMaxIdle​(long address, long accessTime)
      Update max idle time for an entry.
    • Method Detail

      • create

        long create​(org.infinispan.commons.marshall.WrappedBytes key,
                    int hashCode,
                    InternalCacheEntry<org.infinispan.commons.marshall.WrappedBytes,​org.infinispan.commons.marshall.WrappedBytes> ice)
        Creates an off heap entry using the provided key value and metadata
        Parameters:
        key - the key to use
        hashCode - the hashCode of the key
        ice - the internal entry to use
        Returns:
        the address of where the entry was created
      • getSize

        long getSize​(long address,
                     boolean includeAllocationOverhead)
        Returns how many bytes in memory this address location uses assuming it is an InternalCacheEntry.
        Parameters:
        address - 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

        long getNext​(long address)
        Returns the address to the next linked pointer if there is one for this bucket or 0 if there isn't one
        Parameters:
        address - the address of the entry
        Returns:
        the next address entry for this bucket or 0
      • setNext

        void setNext​(long address,
                     long value)
        Called to update the next pointer index when a collision occurs requiring a linked list within the entries themselves
        Parameters:
        address - the address of the entry to update
        value - the value of the linked node to set
      • getHashCode

        int getHashCode​(long address)
        Returns the hashCode of the address. This
        Parameters:
        address - the address of the entry
        Returns:
        the has code of the entry
      • getKey

        byte[] getKey​(long address)
        Returns the key of the address.
        Parameters:
        address - the address of the entry
        Returns:
        the bytes for the key
      • fromMemory

        InternalCacheEntry<org.infinispan.commons.marshall.WrappedBytes,​org.infinispan.commons.marshall.WrappedBytes> fromMemory​(long address)
        Create an entry from the off heap pointer
        Parameters:
        address - the address of the entry to read
        Returns:
        the entry created on heap from off heap
      • equalsKey

        default boolean equalsKey​(long address,
                                  org.infinispan.commons.marshall.WrappedBytes wrappedBytes)
        Returns whether the given key as bytes is the same key as the key stored in the entry for the given address.
        Parameters:
        address - the address of the entry's key to check
        wrappedBytes - the key to check equality with
        Returns:
        whether or not the keys are equal
      • equalsKey

        boolean equalsKey​(long address,
                          org.infinispan.commons.marshall.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.
        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

        boolean isExpired​(long address)
        Returns whether entry is expired or not.
        Parameters:
        address - the address of the entry's key to check
        Returns:
        true if the entry is expired, false otherwise
      • calculateSize

        default long calculateSize​(org.infinispan.commons.marshall.WrappedBytes key,
                                   org.infinispan.commons.marshall.WrappedBytes value,
                                   Metadata metadata)
        Method used to calculate how much memory in size the key, value and metadata use.
        Specified by:
        calculateSize in interface KeyValueMetadataSizeCalculator<org.infinispan.commons.marshall.WrappedBytes,​org.infinispan.commons.marshall.WrappedBytes>
        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.
      • calculateSize

        long calculateSize​(org.infinispan.commons.marshall.WrappedBytes key,
                           org.infinispan.commons.marshall.WrappedBytes value,
                           Metadata metadata,
                           PrivateMetadata internalMetadata)
        Method used to calculate how much memory in size the key, value, metadata and internal metadata use.
        Specified by:
        calculateSize in interface KeyValueMetadataSizeCalculator<org.infinispan.commons.marshall.WrappedBytes,​org.infinispan.commons.marshall.WrappedBytes>
        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
        internalMetadata - 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

        long updateMaxIdle​(long address,
                           long accessTime)
        Update 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.
        Parameters:
        address - the address of the entry's to update
        accessTime - 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