Class FloatMappedBigList
- All Implemented Interfaces:
BigList<Float>
,FloatBigList
,FloatCollection
,FloatIterable
,FloatStack
,Size64
,Stack<Float>
,Comparable<BigList<? extends Float>>
,Iterable<Float>
,Collection<Float>
Java's memory-mapping facilities have the
severe limitation of mapping at most Integer.MAX_VALUE
bytes, as they expose the content
of a file using a MappedByteBuffer
. This class can
expose a file of primitive types of
arbitrary length as a BigList
that is actually based on an array
of MappedByteBuffer
s, each mapping a chunk of CHUNK_SIZE
longs.
Mapping can happen with a specified byte order: saving and mapping data in
native order using methods from
BinIO
will enhance performance significantly.
Instances of this class are not thread safe, but the copy()
method provides a
lightweight duplicate that can be read independently by another thread. Only chunks that are
actually used will be duplicated lazily. If you are
modifiying the content of list, however, you will need to provide external synchronization.
- Author:
- Sebastiano Vigna
-
Nested Class Summary
Nested classes/interfaces inherited from class it.unimi.dsi.fastutil.floats.AbstractFloatBigList
AbstractFloatBigList.FloatRandomAccessSubList, AbstractFloatBigList.FloatSubList
-
Field Summary
Modifier and TypeFieldDescriptionstatic final long
The size in elements of a chunk created bymap(FileChannel, ByteOrder, FileChannel.MapMode)
.static int
Deprecated.static int
The logarithm of the number of bytes of the primitive type of this list. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Returns a lightweight duplicate that can be read independently by another thread.void
getElements
(long from, float[] a, int offset, int length) Copies (hopefully quickly) elements of this type-specific big list into the given array.float
getFloat
(long index) Returns the element at the specified position.static FloatMappedBigList
map
(FileChannel fileChannel) Creates a new mapped big list by read-only mapping a given file channel using the standard Java (i.e.,DataOutput
) byte order (ByteOrder.BIG_ENDIAN
).static FloatMappedBigList
map
(FileChannel fileChannel, ByteOrder byteOrder) Creates a new mapped big list by read-only mapping a given file channel.static FloatMappedBigList
map
(FileChannel fileChannel, ByteOrder byteOrder, FileChannel.MapMode mapMode) Creates a new mapped big list by mapping a given file channel.float
set
(long index, float value) Replaces the element at the specified position in this big list with the specified element (optional operation).long
size64()
Returns the size of this data structure as a long.Methods inherited from class it.unimi.dsi.fastutil.floats.AbstractFloatBigList
add, add, add, addAll, addAll, addAll, addAll, addElements, addElements, clear, compareTo, contains, doubleSpliterator, equals, forEach, get, getElements, hashCode, indexOf, indexOf, iterator, lastIndexOf, lastIndexOf, listIterator, listIterator, peek, peekFloat, pop, popFloat, push, push, rem, remove, removeElements, removeFloat, set, setElements, size, size, subList, top, topFloat, toString
Methods inherited from class it.unimi.dsi.fastutil.floats.AbstractFloatCollection
add, contains, containsAll, containsAll, remove, removeAll, removeAll, retainAll, retainAll, toArray, toFloatArray, toFloatArray
Methods inherited from class java.util.AbstractCollection
isEmpty, toArray, toArray
Methods inherited from interface java.util.Collection
containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toArray
Methods inherited from interface it.unimi.dsi.fastutil.floats.FloatBigList
addAll, addAll, addAll, addAll, setElements, setElements, spliterator
Methods inherited from interface it.unimi.dsi.fastutil.floats.FloatCollection
add, contains, containsAll, doubleIterator, doubleParallelStream, doubleStream, parallelStream, remove, removeAll, removeIf, removeIf, removeIf, retainAll, stream, toArray, toFloatArray, toFloatArray
Methods inherited from interface it.unimi.dsi.fastutil.floats.FloatIterable
forEach, forEach
-
Field Details
-
LOG2_BYTES
public static int LOG2_BYTESThe logarithm of the number of bytes of the primitive type of this list. -
LOG2_BITS
Deprecated.UseLOG2_BYTES
. -
CHUNK_SIZE
public static final long CHUNK_SIZEThe size in elements of a chunk created bymap(FileChannel, ByteOrder, FileChannel.MapMode)
.
-
-
Method Details
-
map
Creates a new mapped big list by read-only mapping a given file channel using the standard Java (i.e.,DataOutput
) byte order (ByteOrder.BIG_ENDIAN
).- Parameters:
fileChannel
- the file channel that will be mapped.- Returns:
- a new read-only mapped big list over the contents of
fileChannel
. - Throws:
IOException
- See Also:
-
map
public static FloatMappedBigList map(FileChannel fileChannel, ByteOrder byteOrder) throws IOException Creates a new mapped big list by read-only mapping a given file channel.- Parameters:
fileChannel
- the file channel that will be mapped.byteOrder
- a prescribed byte order.- Returns:
- a new read-only mapped big list over the contents of
fileChannel
. - Throws:
IOException
- See Also:
-
map
public static FloatMappedBigList map(FileChannel fileChannel, ByteOrder byteOrder, FileChannel.MapMode mapMode) throws IOException Creates a new mapped big list by mapping a given file channel.- Parameters:
fileChannel
- the file channel that will be mapped.byteOrder
- a prescribed byte order.mapMode
- the mapping mode: usuallyFileChannel.MapMode.READ_ONLY
, but if intend to make the list mutable, you have to passFileChannel.MapMode.READ_WRITE
.- Returns:
- a new mapped big list over the contents of
fileChannel
. - Throws:
IOException
-
copy
Returns a lightweight duplicate that can be read independently by another thread.Only chunks that are actually used will be duplicated lazily.
- Returns:
- a lightweight duplicate that can be read independently by another thread.
-
getFloat
public float getFloat(long index) Description copied from interface:FloatBigList
Returns the element at the specified position.- See Also:
-
getElements
public void getElements(long from, float[] a, int offset, int length) Description copied from interface:FloatBigList
Copies (hopefully quickly) elements of this type-specific big list into the given array.- Parameters:
from
- the start index (inclusive).a
- the destination array.offset
- the offset into the destination array where to store the first element copied.length
- the number of elements to be copied.
-
set
public float set(long index, float value) Description copied from class:AbstractFloatBigList
Replaces the element at the specified position in this big list with the specified element (optional operation).- Specified by:
set
in interfaceFloatBigList
- Overrides:
set
in classAbstractFloatBigList
- See Also:
-
size64
public long size64()Description copied from interface:Size64
Returns the size of this data structure as a long.- Returns:
- the size of this data structure.
-
LOG2_BYTES
.