public class CharMappedBigList
extends it.unimi.dsi.fastutil.chars.AbstractCharBigList
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.
| Modifier and Type | Field and Description |
|---|---|
static long |
CHUNK_SIZE
The size in elements of a chunk created by
map(FileChannel, ByteOrder, FileChannel.MapMode). |
static int |
LOG2_BITS
Deprecated.
Use
LOG2_BYTES. |
static int |
LOG2_BYTES
The logarithm of the number of bytes of the primitive type of this list.
|
| Modifier | Constructor and Description |
|---|---|
protected |
CharMappedBigList(java.nio.CharBuffer[] buffer,
long size,
boolean[] readyToUse)
Creates a new mapped big list.
|
| Modifier and Type | Method and Description |
|---|---|
CharMappedBigList |
copy()
Returns a lightweight duplicate that can be read independently by another thread.
|
char |
getChar(long index) |
void |
getElements(long from,
char[] a,
int offset,
int length) |
static CharMappedBigList |
map(java.nio.channels.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 CharMappedBigList |
map(java.nio.channels.FileChannel fileChannel,
java.nio.ByteOrder byteOrder)
Creates a new mapped big list by read-only mapping a given file channel.
|
static CharMappedBigList |
map(java.nio.channels.FileChannel fileChannel,
java.nio.ByteOrder byteOrder,
java.nio.channels.FileChannel.MapMode mapMode)
Creates a new mapped big list by mapping a given file channel.
|
char |
set(long index,
char value) |
long |
size64() |
add, add, add, addAll, addAll, addAll, addAll, addElements, addElements, clear, compareTo, contains, ensureIndex, ensureRestrictedIndex, equals, forEach, get, getElements, hashCode, indexOf, indexOf, intSpliterator, iterator, lastIndexOf, lastIndexOf, listIterator, listIterator, peek, peekChar, pop, popChar, push, push, rem, remove, removeChar, removeElements, set, setElements, size, size, subList, top, topChar, toStringadd, contains, containsAll, containsAll, remove, removeAll, removeAll, retainAll, retainAll, toArray, toCharArray, toCharArrayclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddAll, addAll, addAll, addAll, setElements, setElements, spliteratoradd, contains, containsAll, intIterator, intParallelStream, intStream, parallelStream, remove, removeAll, removeIf, removeIf, removeIf, retainAll, stream, toArray, toCharArray, toCharArraypublic static int LOG2_BYTES
@Deprecated public static int LOG2_BITS
LOG2_BYTES.public static final long CHUNK_SIZE
map(FileChannel, ByteOrder, FileChannel.MapMode).protected CharMappedBigList(java.nio.CharBuffer[] buffer,
long size,
boolean[] readyToUse)
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 to buffer specifying 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.public static CharMappedBigList map(java.nio.channels.FileChannel fileChannel) throws java.io.IOException
DataOutput) byte order (ByteOrder.BIG_ENDIAN).fileChannel - the file channel that will be mapped.fileChannel.java.io.IOException#map(FileChannel, ByteOrder, MapMode)public static CharMappedBigList map(java.nio.channels.FileChannel fileChannel, java.nio.ByteOrder byteOrder) throws java.io.IOException
fileChannel - the file channel that will be mapped.byteOrder - a prescribed byte order.fileChannel.java.io.IOException#map(FileChannel, ByteOrder, MapMode)public static CharMappedBigList map(java.nio.channels.FileChannel fileChannel, java.nio.ByteOrder byteOrder, java.nio.channels.FileChannel.MapMode mapMode) throws java.io.IOException
fileChannel - the file channel that will be mapped.byteOrder - a prescribed byte order.mapMode - the mapping mode: usually FileChannel.MapMode.READ_ONLY, but if intend to make the list
mutable, you have to pass FileChannel.MapMode.READ_WRITE.fileChannel.java.io.IOExceptionpublic CharMappedBigList copy()
Only chunks that are actually used will be duplicated lazily.
public char getChar(long index)
public void getElements(long from,
char[] a,
int offset,
int length)
public char set(long index,
char value)
set in interface it.unimi.dsi.fastutil.chars.CharBigListset in class it.unimi.dsi.fastutil.chars.AbstractCharBigListpublic long size64()