Class IntMappedBigList
- All Implemented Interfaces:
it.unimi.dsi.fastutil.BigList<Integer>,it.unimi.dsi.fastutil.ints.IntBigList,it.unimi.dsi.fastutil.ints.IntCollection,it.unimi.dsi.fastutil.ints.IntIterable,it.unimi.dsi.fastutil.ints.IntStack,it.unimi.dsi.fastutil.Size64,it.unimi.dsi.fastutil.Stack<Integer>,Comparable<it.unimi.dsi.fastutil.BigList<? extends Integer>>,Iterable<Integer>,Collection<Integer>
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.ints.AbstractIntBigList
it.unimi.dsi.fastutil.ints.AbstractIntBigList.IntRandomAccessSubList, it.unimi.dsi.fastutil.ints.AbstractIntBigList.IntSubList -
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
ConstructorsModifierConstructorDescriptionprotectedIntMappedBigList(IntBuffer[] 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, int[] a, int offset, int length) intgetInt(long index) static IntMappedBigListmap(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 IntMappedBigListmap(FileChannel fileChannel, ByteOrder byteOrder) Creates a new mapped big list by read-only mapping a given file channel.static IntMappedBigListmap(FileChannel fileChannel, ByteOrder byteOrder, FileChannel.MapMode mapMode) Creates a new mapped big list by mapping a given file channel.intset(long index, int value) longsize64()Methods inherited from class it.unimi.dsi.fastutil.ints.AbstractIntBigList
add, add, add, addAll, addAll, addAll, addAll, addElements, addElements, clear, compareTo, contains, ensureIndex, ensureRestrictedIndex, equals, forEach, get, getElements, hashCode, indexOf, indexOf, iterator, lastIndexOf, lastIndexOf, listIterator, listIterator, peek, peekInt, pop, popInt, push, push, rem, remove, removeElements, removeInt, set, setElements, size, size, subList, top, topInt, toStringMethods inherited from class it.unimi.dsi.fastutil.ints.AbstractIntCollection
add, contains, containsAll, containsAll, forEach, remove, removeAll, removeAll, removeIf, retainAll, retainAll, toArray, toIntArray, toIntArrayMethods 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.ints.IntBigList
addAll, addAll, addAll, addAll, setElements, setElements, spliteratorMethods inherited from interface it.unimi.dsi.fastutil.ints.IntCollection
add, contains, containsAll, intIterator, intParallelStream, intSpliterator, intStream, parallelStream, remove, removeAll, removeIf, removeIf, removeIf, retainAll, stream, toArray, toIntArray, toIntArrayMethods inherited from interface it.unimi.dsi.fastutil.ints.IntIterable
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
-
IntMappedBigList
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
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 IntMappedBigList 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.
-
getInt
public int getInt(long index) -
getElements
public void getElements(long from, int[] a, int offset, int length) -
set
public int set(long index, int value) - Specified by:
setin interfaceit.unimi.dsi.fastutil.ints.IntBigList- Overrides:
setin classit.unimi.dsi.fastutil.ints.AbstractIntBigList
-
size64
public long size64()
-
LOG2_BYTES.