Class HugeArray<Array,Box,Self extends HugeArray<Array,Box,Self>>
- java.lang.Object
-
- org.neo4j.graphalgo.core.utils.paged.HugeArray<Array,Box,Self>
-
- Direct Known Subclasses:
HugeDoubleArray
,HugeIntArray
,HugeLongArray
,HugeObjectArray
public abstract class HugeArray<Array,Box,Self extends HugeArray<Array,Box,Self>> extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description HugeArray()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract NodeProperties
asNodeProperties()
int
copyFromArrayIntoSlice(Array source, long sliceStart, long sliceEnd)
Copies data fromsource
into this array, starting fromsliceStart
up untilsliceEnd
.abstract Self
copyOf(long newLength, AllocationTracker tracker)
Creates a copy of the given array.abstract void
copyTo(Self dest, long length)
Copies the content of this array into the target array.HugeCursor<Array>
initCursor(HugeCursor<Array> cursor)
Resets theHugeCursor
to range from index 0 untilsize()
.HugeCursor<Array>
initCursor(HugeCursor<Array> cursor, long start, long end)
Resets theHugeCursor
to range from indexstart
(inclusive, the first index to be contained) untilend
(exclusive, the first index not to be contained).abstract HugeCursor<Array>
newCursor()
Returns a newHugeCursor
for this array.abstract long
release()
Destroys the data, allowing the underlying storage arrays to be collected as garbage.abstract long
size()
Returns the length of this array.abstract long
sizeOf()
abstract Array
toArray()
java.lang.String
toString()
-
-
-
Method Detail
-
copyTo
public abstract void copyTo(Self dest, long length)
Copies the content of this array into the target array.The behavior is identical to
System.arraycopy(Object, int, Object, int, int)
.
-
copyOf
public abstract Self copyOf(long newLength, AllocationTracker tracker)
Creates a copy of the given array. The behavior is identical toArrays.copyOf(int[], int)
.
-
size
public abstract 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 abstract 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.
-
release
public abstract 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.
-
newCursor
public abstract HugeCursor<Array> newCursor()
Returns a newHugeCursor
for this array. The cursor is not positioned and in an invalid state. To position the cursor you must callinitCursor(HugeCursor)
orinitCursor(HugeCursor, long, long)
. Then the cursor needs to be put in a valid state by callingHugeCursor.next()
. Obtaining aHugeCursor
for an empty array (wheresize()
returns0
) is undefined and might result in aNullPointerException
or anotherRuntimeException
.
-
initCursor
public final HugeCursor<Array> initCursor(HugeCursor<Array> cursor)
Resets theHugeCursor
to range from index 0 untilsize()
. The returned cursor is not positioned and in an invalid state. You must callHugeCursor.next()
first to position the cursor to a valid state. The returned cursor is the reference-same (==
) one as the provided one. Resetting theHugeCursor
of an empty array (wheresize()
returns0
) is undefined and might result in aNullPointerException
or anotherRuntimeException
.
-
initCursor
public final HugeCursor<Array> initCursor(HugeCursor<Array> cursor, long start, long end)
Resets theHugeCursor
to range from indexstart
(inclusive, the first index to be contained) untilend
(exclusive, the first index not to be contained). The returned cursor is not positioned and in an invalid state. You must callHugeCursor.next()
first to position the cursor to a valid state. The returned cursor is the reference-same (==
) one as the provided one. Resetting theHugeCursor
of an empty array (wheresize()
returns0
) is undefined and might result in aNullPointerException
or anotherRuntimeException
.- See Also:
initCursor(HugeCursor)
-
toArray
public abstract Array toArray()
- Returns:
- the contents of this array as a flat java primitive array. The returned array might be shared and changes would then be reflected and visible in this array.
- Throws:
java.lang.IllegalStateException
- if the array is too large
-
asNodeProperties
public abstract NodeProperties asNodeProperties()
-
copyFromArrayIntoSlice
public final int copyFromArrayIntoSlice(Array source, long sliceStart, long sliceEnd)
Copies data fromsource
into this array, starting fromsliceStart
up untilsliceEnd
.- Returns:
- the number of entries copied
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-