Class HugeAtomicDoubleArray
- java.lang.Object
-
- org.neo4j.graphalgo.core.utils.paged.HugeAtomicDoubleArray
-
public class HugeAtomicDoubleArray extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description HugeAtomicDoubleArray(HugeAtomicLongArray data)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
compareAndSet(long index, double expect, double update)
double
get(long index)
static long
memoryEstimation(long size)
static HugeAtomicDoubleArray
newArray(long size, AllocationTracker tracker)
Creates a new array of the given size, tracking the memory requirements into the givenAllocationTracker
.static HugeAtomicDoubleArray
newArray(long size, PageFiller pageFiller, AllocationTracker tracker)
long
release()
Destroys the data, allowing the underlying storage arrays to be collected as garbage.void
set(long index, double value)
Sets the long value at the given index to the given value.long
size()
Returns the length of this array.long
sizeOf()
void
update(long index, java.util.function.DoubleUnaryOperator updateFunction)
Atomically updates the element at indexindex
with the results of applying the given function, returning the updated value.
-
-
-
Constructor Detail
-
HugeAtomicDoubleArray
public HugeAtomicDoubleArray(HugeAtomicLongArray data)
-
-
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 withinsize()
-
update
public void update(long index, java.util.function.DoubleUnaryOperator updateFunction)
Atomically updates the element at indexindex
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 indexupdateFunction
- 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 throwNullPointerException
s 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 givenAllocationTracker
. The tracker is no longer referenced, as the arrays do not dynamically change their size.
-
newArray
public static HugeAtomicDoubleArray newArray(long size, PageFiller pageFiller, AllocationTracker tracker)
-
memoryEstimation
public static long memoryEstimation(long size)
-
-