Class PortabilityBasedStorageEngine<K,​V>

    • Constructor Detail

      • PortabilityBasedStorageEngine

        public PortabilityBasedStorageEngine​(Portability<? super K> keyPortability,
                                             Portability<? super V> valuePortability)
        Creates a storage engine using the given portabilities.
        Parameters:
        keyPortability - key type portability
        valuePortability - value type portability
    • Method Detail

      • writeMapping

        public final java.lang.Long writeMapping​(K key,
                                                 V value,
                                                 int hash,
                                                 int metadata)
        Description copied from interface: StorageEngine
        Converts the supplied key and value objects into their encoded form.
        Specified by:
        writeMapping in interface StorageEngine<K,​V>
        Parameters:
        key - a key object
        value - a value object
        hash - the key hash
        metadata - the metadata bits
        Returns:
        the encoded mapping
      • attachedMapping

        public void attachedMapping​(long encoding,
                                    int hash,
                                    int metadata)
        Specified by:
        attachedMapping in interface StorageEngine<K,​V>
      • freeMapping

        public final void freeMapping​(long encoding,
                                      int hash,
                                      boolean removal)
        Description copied from interface: StorageEngine
        Called to indicate that the associated encoded value is no longer needed.

        This call can be used to free any associated resources tied to the lifecycle of the supplied encoded value.

        Specified by:
        freeMapping in interface StorageEngine<K,​V>
        Parameters:
        encoding - encoded value
        hash - hash of the freed mapping
        removal - marks removal from a map
      • clear

        public final void clear()
        Description copied from interface: StorageEngine
        Called to indicate that all keys and values are now free.
        Specified by:
        clear in interface StorageEngine<K,​V>
      • readValue

        public V readValue​(long encoding)
        Description copied from interface: StorageEngine
        Converts the supplied encoded value into its correct object form.
        Specified by:
        readValue in interface StorageEngine<K,​V>
        Parameters:
        encoding - encoded value
        Returns:
        a decoded value object
      • equalsValue

        public boolean equalsValue​(java.lang.Object value,
                                   long encoding)
        Description copied from interface: StorageEngine
        Called to determine the equality of the given Java object value against the given encoded form.

        Simple implementations will probably perform a decode on the given encoded form in order to do a regular Object.equals(Object) comparison. This method is provided to allow implementations to optimize this comparison if possible.

        Specified by:
        equalsValue in interface StorageEngine<K,​V>
        Parameters:
        value - a value object
        encoding - encoded value
        Returns:
        true if the value and the encoding are equal
      • readKey

        public K readKey​(long encoding,
                         int hashCode)
        Description copied from interface: StorageEngine
        Converts the supplied encoded key into its correct object form.
        Specified by:
        readKey in interface StorageEngine<K,​V>
        Parameters:
        encoding - encoded key
        hashCode - hash-code of the decoded key
        Returns:
        a decoded key object
      • equalsKey

        public boolean equalsKey​(java.lang.Object key,
                                 long encoding)
        Description copied from interface: StorageEngine
        Called to determine the equality of the given object against the given encoded form.

        Simple implementations will probably perform a decode on the given encoded form in order to do a regular Object.equals(Object) comparison. This method is provided to allow implementations to optimize this comparison if possible.

        Specified by:
        equalsKey in interface StorageEngine<K,​V>
        Parameters:
        key - a key object
        encoding - encoded value
        Returns:
        true if the key and the encoding are equal
      • writeBinaryMapping

        public java.lang.Long writeBinaryMapping​(java.nio.ByteBuffer[] binaryKey,
                                                 java.nio.ByteBuffer[] binaryValue,
                                                 int pojoHash,
                                                 int metadata)
        Specified by:
        writeBinaryMapping in interface BinaryStorageEngine
      • writeBinaryMapping

        public java.lang.Long writeBinaryMapping​(java.nio.ByteBuffer binaryKey,
                                                 java.nio.ByteBuffer binaryValue,
                                                 int pojoHash,
                                                 int metadata)
        Specified by:
        writeBinaryMapping in interface BinaryStorageEngine
      • writeMappingBuffersGathering

        protected java.lang.Long writeMappingBuffersGathering​(java.nio.ByteBuffer[] keyBuffers,
                                                              java.nio.ByteBuffer[] valueBuffers,
                                                              int hash)
      • free

        protected abstract void free​(long address)
      • clearInternal

        protected abstract void clearInternal()
      • readKeyBuffer

        protected abstract java.nio.ByteBuffer readKeyBuffer​(long address)
      • getKeyWriteContext

        protected abstract WriteContext getKeyWriteContext​(long address)
      • readValueBuffer

        protected abstract java.nio.ByteBuffer readValueBuffer​(long address)
      • getValueWriteContext

        protected abstract WriteContext getValueWriteContext​(long address)
      • writeMappingBuffers

        protected abstract java.lang.Long writeMappingBuffers​(java.nio.ByteBuffer keyBuffer,
                                                              java.nio.ByteBuffer valueBuffer,
                                                              int hash)
      • invalidateCache

        public void invalidateCache()
        Description copied from interface: StorageEngine
        Invalidate any local key/value caches.

        This is called to indicate the termination of a map write "phase". Caching is permitted within a write operation (i.e. to cache around allocation failures during eviction processes).

        Specified by:
        invalidateCache in interface StorageEngine<K,​V>