Class FloatMappedBigList
- All Implemented Interfaces:
it.unimi.dsi.fastutil.BigList<Float>,it.unimi.dsi.fastutil.floats.FloatBigList,it.unimi.dsi.fastutil.floats.FloatCollection,it.unimi.dsi.fastutil.floats.FloatIterable,it.unimi.dsi.fastutil.floats.FloatStack,it.unimi.dsi.fastutil.Size64,it.unimi.dsi.fastutil.Stack<Float>,Comparable<it.unimi.dsi.fastutil.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 MappedByteBuffers, 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.
-
Nested Class Summary
Nested classes/interfaces inherited from class it.unimi.dsi.fastutil.floats.AbstractFloatBigList
it.unimi.dsi.fastutil.floats.AbstractFloatBigList.FloatRandomAccessSubList, it.unimi.dsi.fastutil.floats.AbstractFloatBigList.FloatSubList -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe size in elements of a chunk created bymap(FileChannel, ByteOrder, FileChannel.MapMode).static intDeprecated.static intThe logarithm of the number of bytes of the primitive type of this list. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFloatMappedBigList(FloatBuffer[] buffer, long size, boolean[] readyToUse) Creates a new mapped big list. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Returns a lightweight duplicate that can be read independently by another thread.voidgetElements(long from, float[] a, int offset, int length) floatgetFloat(long index) static FloatMappedBigListmap(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 FloatMappedBigListmap(FileChannel fileChannel, ByteOrder byteOrder) Creates a new mapped big list by read-only mapping a given file channel.static FloatMappedBigListmap(FileChannel fileChannel, ByteOrder byteOrder, FileChannel.MapMode mapMode) Creates a new mapped big list by mapping a given file channel.floatset(long index, float value) longsize64()Methods inherited from class it.unimi.dsi.fastutil.floats.AbstractFloatBigList
add, add, add, addAll, addAll, addAll, addAll, addElements, addElements, clear, compareTo, contains, doubleSpliterator, ensureIndex, ensureRestrictedIndex, 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, toStringMethods inherited from class it.unimi.dsi.fastutil.floats.AbstractFloatCollection
add, contains, containsAll, containsAll, remove, removeAll, removeAll, retainAll, retainAll, toArray, toFloatArray, toFloatArrayMethods inherited from class java.util.AbstractCollection
isEmpty, toArray, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toArrayMethods inherited from interface it.unimi.dsi.fastutil.floats.FloatBigList
addAll, addAll, addAll, addAll, setElements, setElements, spliteratorMethods 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, toFloatArrayMethods inherited from interface it.unimi.dsi.fastutil.floats.FloatIterable
forEach, forEachMethods inherited from interface it.unimi.dsi.fastutil.Stack
isEmpty
-
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).
-
-
Constructor Details
-
FloatMappedBigList
Creates a new mapped big list.- Parameters:
buffer- the underlying buffers.size- the overall number of elements in the underlying buffers (i.e., the sum of the capacities of the byte buffers divided by the size of an element in bytes).readyToUse- an array parallel tobufferspecifying which buffers do not need to be duplicated before being used (the process will happen lazily); the array will be used internally by the newly created mapped big list.
-
-
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) -
getElements
public void getElements(long from, float[] a, int offset, int length) -
set
public float set(long index, float value) - Specified by:
setin interfaceit.unimi.dsi.fastutil.floats.FloatBigList- Overrides:
setin classit.unimi.dsi.fastutil.floats.AbstractFloatBigList
-
size64
public long size64()
-
LOG2_BYTES.