it.unimi.dsi.util
Class ByteBufferLongBigList

java.lang.Object
  extended by java.util.AbstractCollection<Long>
      extended by it.unimi.dsi.fastutil.longs.AbstractLongCollection
          extended by it.unimi.dsi.fastutil.longs.AbstractLongBigList
              extended by it.unimi.dsi.util.ByteBufferLongBigList
All Implemented Interfaces:
BigList<Long>, LongBigList, LongCollection, LongIterable, LongStack, Size64, Stack<Long>, Comparable<BigList<? extends Long>>, Iterable<Long>, Collection<Long>

public class ByteBufferLongBigList
extends AbstractLongBigList

A bridge between byte buffers and long big lists.

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 longs of arbitrary length as a LongBigList that is actually based on an array of MappedByteBuffers, each mapping a chunk of CHUNK_SIZE longs.

Author:
Sebastiano Vigna

Nested Class Summary
 
Nested classes/interfaces inherited from class it.unimi.dsi.fastutil.longs.AbstractLongBigList
AbstractLongBigList.LongSubList
 
Field Summary
static long CHUNK_SIZE
          The size in longs of a chunk created by #map(FileChannel, ByteOrder, MapMode).
 
Constructor Summary
  ByteBufferLongBigList(ByteBuffer byteBuffer)
          Creates a new byte-buffer long big list from a single ByteBuffer.
protected ByteBufferLongBigList(ByteBuffer[] byteBuffer, long size, boolean[] readyToUse)
          Creates a new byte-buffer long big list.
 
Method Summary
 ByteBufferLongBigList copy()
           
 long getLong(long index)
           
static ByteBufferLongBigList map(FileChannel fileChannel, ByteOrder byteOrder, FileChannel.MapMode mapMode)
          Creates a new byte-buffer long big list by mapping a given file channel.
 long size64()
           
 
Methods inherited from class it.unimi.dsi.fastutil.longs.AbstractLongBigList
add, add, add, addAll, addAll, addAll, addAll, addAll, addAll, addAll, addElements, addElements, compareTo, contains, ensureIndex, ensureRestrictedIndex, equals, get, getElements, getLong, hashCode, indexOf, indexOf, iterator, lastIndexOf, lastIndexOf, listIterator, listIterator, listIterator, peek, peekLong, pop, popLong, push, push, rem, remove, remove, removeElements, removeLong, removeLong, set, set, set, size, size, size, subList, top, topLong, toString
 
Methods inherited from class it.unimi.dsi.fastutil.longs.AbstractLongCollection
add, contains, containsAll, containsAll, isEmpty, longIterator, rem, remove, removeAll, removeAll, retainAll, retainAll, toArray, toArray, toArray, toLongArray, toLongArray
 
Methods inherited from class java.util.AbstractCollection
clear
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface it.unimi.dsi.fastutil.longs.LongCollection
containsAll, longIterator, removeAll, retainAll, toArray, toArray, toLongArray, toLongArray
 
Methods inherited from interface java.util.Collection
add, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray
 
Methods inherited from interface it.unimi.dsi.fastutil.Stack
isEmpty
 

Field Detail

CHUNK_SIZE

public static final long CHUNK_SIZE
The size in longs of a chunk created by #map(FileChannel, ByteOrder, MapMode).

Constructor Detail

ByteBufferLongBigList

public ByteBufferLongBigList(ByteBuffer byteBuffer)
Creates a new byte-buffer long big list from a single ByteBuffer.

Parameters:
byteBuffer - the underlying byte buffer.

ByteBufferLongBigList

protected ByteBufferLongBigList(ByteBuffer[] byteBuffer,
                                long size,
                                boolean[] readyToUse)
Creates a new byte-buffer long big list.

Parameters:
byteBuffer - the underlying byte buffers.
size - the sum of the capacities of the byte buffers.
readyToUse - an array parallel to byteBuffer 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 byte-buffer long big list.
Method Detail

map

public static ByteBufferLongBigList map(FileChannel fileChannel,
                                        ByteOrder byteOrder,
                                        FileChannel.MapMode mapMode)
                                 throws IOException
Creates a new byte-buffer long big list by mapping a given file channel.

Parameters:
fileChannel - the file channel that will be mapped.
byteOrder - a prescribed byte order.
mapMode - this must be FileChannel.MapMode.READ_ONLY.
Returns:
a new byte-buffer long big list over the contents of fileChannel.
Throws:
IOException

copy

public ByteBufferLongBigList copy()

getLong

public long getLong(long index)

size64

public long size64()