Class HugeAtomicDoubleArray


  • public class HugeAtomicDoubleArray
    extends java.lang.Object
    • Method Detail

      • get

        public double get​(long index)
      • set

        public void set​(long index,
                        double value)
        Sets the long value at the given index to the given value.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - if the index is not within size()
      • update

        public void update​(long index,
                           java.util.function.DoubleUnaryOperator updateFunction)
        Atomically updates the element at index index with the results of applying the given function, returning the updated value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads.
        Parameters:
        index - the index
        updateFunction - a side-effect-free function
      • size

        public long size()
        Returns the length of this array.

        If the size is greater than zero, the highest supported index is size() - 1

        The behavior is identical to calling array.length on primitive arrays.

      • sizeOf

        public long sizeOf()
        Returns:
        the amount of memory used by the instance of this array, in bytes. This should be the same as returned from release() without actually releasing the array.
      • compareAndSet

        public boolean compareAndSet​(long index,
                                     double expect,
                                     double update)
      • release

        public long release()
        Destroys the data, allowing the underlying storage arrays to be collected as garbage. The array is unusable after calling this method and will throw NullPointerExceptions on virtually every method invocation.

        Note that the data might not immediately collectible if there are still cursors alive that reference this array. You have to HugeCursor.close() every cursor instance as well.

        The amount is not removed from the AllocationTracker that had been provided in the constructor.

        Returns:
        the amount of memory freed, in bytes.
      • newArray

        public static HugeAtomicDoubleArray newArray​(long size,
                                                     AllocationTracker tracker)
        Creates a new array of the given size, tracking the memory requirements into the given AllocationTracker. The tracker is no longer referenced, as the arrays do not dynamically change their size.
      • memoryEstimation

        public static long memoryEstimation​(long size)