Interface BaseState

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void checkValidAndBounds​(long offsetBytes, long lengthBytes)
      Checks that the specified range of bytes is within bounds of this object, throws IllegalArgumentException if it's not: i.
      boolean equals​(Object that)
      Returns true if the given object is an instance of this class and has equal data contents.
      boolean equalTo​(long thisOffsetBytes, Object that, long thatOffsetBytes, long lengthBytes)
      Returns true if the given object is an instance of this class and has equal contents to this object in the given range of bytes.
      ByteBuffer getByteBuffer()
      Gets the backing ByteBuffer if it exists, otherwise returns null.
      long getCapacity()
      Gets the capacity of this object in bytes
      long getCumulativeOffset()
      Gets the cumulative offset in bytes of this object from the backing resource.
      long getCumulativeOffset​(long offsetBytes)
      Gets the cumulative offset in bytes of this object from the backing resource including the given offsetBytes.
      static long getCurrentDirectMemoryAllocated()
      Gets the current size of active direct memory allocated.
      static long getCurrentDirectMemoryAllocations()
      Gets the current number of active direct memory allocations.
      static long getCurrentDirectMemoryMapAllocated()
      Gets the current size of active direct memory map allocated.
      static long getCurrentDirectMemoryMapAllocations()
      Gets the current number of active direct memory map allocations.
      long getRegionOffset()
      Returns the offset of address zero of this object relative to the address zero of the backing resource but not including the size of any Java object header.
      long getRegionOffset​(long offsetBytes)
      Returns the offset of address zero of this object relative to the address zero of the backing resource plus the given offsetBytes but not including the size of any Java object header.
      ByteOrder getTypeByteOrder()
      Gets the current Type ByteOrder.
      boolean hasArray()
      Returns true if this object is backed by an on-heap primitive array
      boolean hasByteBuffer()
      Returns true if this Memory is backed by a ByteBuffer.
      int hashCode()
      Returns the hashCode of this object.
      boolean isByteOrderCompatible​(ByteOrder byteOrder)
      Returns true if the Native ByteOrder is the same as the ByteOrder of the current Buffer or Memory and the same ByteOrder as the given byteOrder.
      boolean isDirect()
      Returns true if the backing resource is direct (off-heap) memory.
      boolean isReadOnly()
      Returns true if this object or the backing resource is read-only.
      boolean isSameResource​(Object that)
      Returns true if the backing resource of this is identical with the backing resource of that.
      boolean isValid()
      Returns true if this object is valid and has not been closed.
      String toHexString​(String header, long offsetBytes, int lengthBytes)
      Returns a formatted hex string of a range of this object.
      long xxHash64​(long in, long seed)
      Returns a 64-bit hash from a single long.
      long xxHash64​(long offsetBytes, long lengthBytes, long seed)
      Returns the 64-bit hash of the sequence of bytes in this object specified by offsetBytes, lengthBytes and a seed.
    • Field Detail

      • defaultMemReqSvr

        static final MemoryRequestServer defaultMemReqSvr
        The placeholder for the default MemoryRequestServer, if set at all.
    • Method Detail

      • getTypeByteOrder

        ByteOrder getTypeByteOrder()
        Gets the current Type ByteOrder. This may be different from the ByteOrder of the backing resource and of the Native Byte Order.
        Returns:
        the current Type ByteOrder.
      • isByteOrderCompatible

        boolean isByteOrderCompatible​(ByteOrder byteOrder)
        Returns true if the Native ByteOrder is the same as the ByteOrder of the current Buffer or Memory and the same ByteOrder as the given byteOrder.
        Parameters:
        byteOrder - the given ByteOrder
        Returns:
        true if the Native ByteOrder is the same as the ByteOrder of the current Buffer or Memory and the same ByteOrder as the given byteOrder.
      • equals

        boolean equals​(Object that)
        Returns true if the given object is an instance of this class and has equal data contents.
        Overrides:
        equals in class Object
        Parameters:
        that - the given object
        Returns:
        true if the given Object is an instance of this class and has equal data contents.
      • equalTo

        boolean equalTo​(long thisOffsetBytes,
                        Object that,
                        long thatOffsetBytes,
                        long lengthBytes)
        Returns true if the given object is an instance of this class and has equal contents to this object in the given range of bytes. This will also check two distinct ranges within the same object for equals.
        Parameters:
        thisOffsetBytes - the starting offset in bytes for this object.
        that - the given object
        thatOffsetBytes - the starting offset in bytes for the given object
        lengthBytes - the size of the range in bytes
        Returns:
        true if the given object has equal contents to this object in the given range of bytes.
      • getByteBuffer

        ByteBuffer getByteBuffer()
        Gets the backing ByteBuffer if it exists, otherwise returns null.
        Returns:
        the backing ByteBuffer if it exists, otherwise returns null.
      • getCapacity

        long getCapacity()
        Gets the capacity of this object in bytes
        Returns:
        the capacity of this object in bytes
      • getCumulativeOffset

        long getCumulativeOffset()
        Gets the cumulative offset in bytes of this object from the backing resource. This offset may also include other offset components such as the native off-heap memory address, DirectByteBuffer split offsets, region offsets, and unsafe arrayBaseOffsets.
        Returns:
        the cumulative offset in bytes of this object from the backing resource.
      • getCumulativeOffset

        long getCumulativeOffset​(long offsetBytes)
        Gets the cumulative offset in bytes of this object from the backing resource including the given offsetBytes. This offset may also include other offset components such as the native off-heap memory address, DirectByteBuffer split offsets, region offsets, and unsafe arrayBaseOffsets.
        Parameters:
        offsetBytes - offset to be added to the cumulative offset.
        Returns:
        the cumulative offset in bytes of this object from the backing resource including the given offsetBytes.
      • getRegionOffset

        long getRegionOffset()
        Returns the offset of address zero of this object relative to the address zero of the backing resource but not including the size of any Java object header.
        Returns:
        the offset of address zero of this object relative to the address zero of the backing resource but not including the size of any Java object header.
      • getRegionOffset

        long getRegionOffset​(long offsetBytes)
        Returns the offset of address zero of this object relative to the address zero of the backing resource plus the given offsetBytes but not including the size of any Java object header.
        Parameters:
        offsetBytes - the given offsetBytes
        Returns:
        the offset of address zero of this object relative to the address zero of the backing resource plus the given offsetBytes but not including the size of any Java object header.
      • hasArray

        boolean hasArray()
        Returns true if this object is backed by an on-heap primitive array
        Returns:
        true if this object is backed by an on-heap primitive array
      • hashCode

        int hashCode()
        Returns the hashCode of this object.

        The hash code of this object depends upon all of its contents. Because of this, it is inadvisable to use these objects as keys in hash maps or similar data structures unless it is known that their contents will not change.

        If it is desirable to use these objects in a hash map depending only on object identity, than the IdentityHashMap can be used.

        Overrides:
        hashCode in class Object
        Returns:
        the hashCode of this object.
      • xxHash64

        long xxHash64​(long offsetBytes,
                      long lengthBytes,
                      long seed)
        Returns the 64-bit hash of the sequence of bytes in this object specified by offsetBytes, lengthBytes and a seed. Note that the sequence of bytes is always processed in the same order independent of endianness.
        Parameters:
        offsetBytes - the given offset in bytes to the first byte of the byte sequence.
        lengthBytes - the given length in bytes of the byte sequence.
        seed - the given long seed.
        Returns:
        the 64-bit hash of the sequence of bytes in this object specified by offsetBytes and lengthBytes.
      • xxHash64

        long xxHash64​(long in,
                      long seed)
        Returns a 64-bit hash from a single long. This method has been optimized for speed when only a single hash of a long is required.
        Parameters:
        in - A long.
        seed - A long valued seed.
        Returns:
        the hash.
      • hasByteBuffer

        boolean hasByteBuffer()
        Returns true if this Memory is backed by a ByteBuffer.
        Returns:
        true if this Memory is backed by a ByteBuffer.
      • isDirect

        boolean isDirect()
        Returns true if the backing resource is direct (off-heap) memory. This is the case for allocated direct memory, memory mapped files,
        Returns:
        true if the backing resource is direct (off-heap) memory.
      • isReadOnly

        boolean isReadOnly()
        Returns true if this object or the backing resource is read-only.
        Returns:
        true if this object or the backing resource is read-only.
      • isSameResource

        boolean isSameResource​(Object that)
        Returns true if the backing resource of this is identical with the backing resource of that. The capacities must be the same. If this is a region, the region offset must also be the same.
        Parameters:
        that - A different non-null object
        Returns:
        true if the backing resource of this is the same as the backing resource of that.
      • isValid

        boolean isValid()
        Returns true if this object is valid and has not been closed. This is relevant only for direct (off-heap) memory and Mapped Files.
        Returns:
        true if this object is valid and has not been closed.
      • checkValidAndBounds

        void checkValidAndBounds​(long offsetBytes,
                                 long lengthBytes)
        Checks that the specified range of bytes is within bounds of this object, throws IllegalArgumentException if it's not: i. e. if offsetBytes < 0, or length < 0, or offsetBytes + length > getCapacity().
        Parameters:
        offsetBytes - the given offset in bytes of this object
        lengthBytes - the given length in bytes of this object
      • getCurrentDirectMemoryAllocations

        static long getCurrentDirectMemoryAllocations()
        Gets the current number of active direct memory allocations.
        Returns:
        the current number of active direct memory allocations.
      • getCurrentDirectMemoryAllocated

        static long getCurrentDirectMemoryAllocated()
        Gets the current size of active direct memory allocated.
        Returns:
        the current size of active direct memory allocated.
      • getCurrentDirectMemoryMapAllocations

        static long getCurrentDirectMemoryMapAllocations()
        Gets the current number of active direct memory map allocations.
        Returns:
        the current number of active direct memory map allocations.
      • getCurrentDirectMemoryMapAllocated

        static long getCurrentDirectMemoryMapAllocated()
        Gets the current size of active direct memory map allocated.
        Returns:
        the current size of active direct memory map allocated.
      • toHexString

        String toHexString​(String header,
                           long offsetBytes,
                           int lengthBytes)
        Returns a formatted hex string of a range of this object. Used primarily for testing.
        Parameters:
        header - a descriptive header
        offsetBytes - offset bytes relative to this object start
        lengthBytes - number of bytes to convert to a hex string
        Returns:
        a formatted hex string in a human readable array