Class MappedEliasFanoMonotoneLongBigList
- java.lang.Object
-
- java.util.AbstractCollection<java.lang.Long>
-
- it.unimi.dsi.fastutil.longs.AbstractLongCollection
-
- it.unimi.dsi.fastutil.longs.AbstractLongBigList
-
- it.unimi.dsi.sux4j.util.MappedEliasFanoMonotoneLongBigList
-
- All Implemented Interfaces:
it.unimi.dsi.fastutil.BigList<java.lang.Long>,it.unimi.dsi.fastutil.longs.LongBigList,it.unimi.dsi.fastutil.longs.LongCollection,it.unimi.dsi.fastutil.longs.LongIterable,it.unimi.dsi.fastutil.longs.LongStack,it.unimi.dsi.fastutil.Size64,it.unimi.dsi.fastutil.Stack<java.lang.Long>,it.unimi.dsi.lang.FlyweightPrototype<MappedEliasFanoMonotoneLongBigList>,java.io.Closeable,java.io.Serializable,java.lang.AutoCloseable,java.lang.Comparable<it.unimi.dsi.fastutil.BigList<? extends java.lang.Long>>,java.lang.Iterable<java.lang.Long>,java.util.Collection<java.lang.Long>
public class MappedEliasFanoMonotoneLongBigList extends it.unimi.dsi.fastutil.longs.AbstractLongBigList implements java.io.Serializable, java.io.Closeable, it.unimi.dsi.lang.FlyweightPrototype<MappedEliasFanoMonotoneLongBigList>
A memory-mapped implementation ofEliasFanoMonotoneLongBigList/EliasFanoMonotoneBigLongBigList.This class makes it possible to use an
EliasFanoMonotoneLongBigList(orEliasFanoMonotoneBigLongBigList) without actually loading the lower bits, but rather mapping them into memory. You build anEliasFanoMonotoneLongBigList(orEliasFanoMonotoneBigLongBigList) instance first, and then you use the dump it to disk providing a basename. The same basename must be used when loading an instance of this class.After usage, you should
close()instances of this class to release the associatedFileChannel.Instances of this class are not thread safe, but the
copy()method provides a lightweight duplicate that can be read independently by another thread. The method usesLongMappedBigList.copy()to provide an independent mapping of the lower bits. Note that theclose()method, when invoked on any copy, will stop mapping of all copies. *
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classMappedEliasFanoMonotoneLongBigList.MappedEliasFanoMonotoneLongBigListIteratorA list iterator over the values of thisMappedEliasFanoMonotoneLongBigList.
-
Field Summary
Fields Modifier and Type Field Description protected intlThe number of lower bits.protected longlengthThe length of the sequence.static java.lang.StringLOWER_BITS_EXTENSIONprotected it.unimi.dsi.fastutil.longs.LongMappedBigListlowerBitsThe list of lower bits of each element, stored explicitly.protected longlowerBitsMaskThe mask for the lower bits.static java.lang.StringOBJECT_EXTENSIONprotected SimpleBigSelectselectUpperThe select structure used to extract the upper bits.protected long[][]upperBitsThe upper bits, stored as unary gaps.
-
Constructor Summary
Constructors Modifier Constructor Description protectedMappedEliasFanoMonotoneLongBigList(long length, int l, long[][] upperBits, SimpleBigSelect selectUpper, boolean littleEndian)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()MappedEliasFanoMonotoneLongBigListcopy()long[]get(long index, long[] dest)Extracts a number of consecutive entries into a given array.long[]get(long index, long[] dest, int offset, int length)Extracts a number of consecutive entries into a given array fragment.longgetDelta(long index)Returns the difference between two consecutive elements of the sequence.longgetLong(long index)Returns the element at the specified position.MappedEliasFanoMonotoneLongBigList.MappedEliasFanoMonotoneLongBigListIteratoriterator()Returns a list iterator over the values of thisMappedEliasFanoMonotoneLongBigList.MappedEliasFanoMonotoneLongBigList.MappedEliasFanoMonotoneLongBigListIteratorlistIterator()Returns a list iterator over the values of thisMappedEliasFanoMonotoneLongBigList.MappedEliasFanoMonotoneLongBigList.MappedEliasFanoMonotoneLongBigListIteratorlistIterator(long from)Returns a list iterator over the values of thisMappedEliasFanoMonotoneLongBigList.static MappedEliasFanoMonotoneLongBigListload(java.lang.String basename)Maps an Elias–Fano monotone list into memory.MappedEliasFanoMonotoneLongBigListlowerBits(java.lang.String lowerBits)Maps the lower bits of this list from a file.longnumBits()longsize64()-
Methods inherited from class it.unimi.dsi.fastutil.longs.AbstractLongBigList
add, add, add, addAll, addAll, addAll, addAll, addElements, addElements, clear, compareTo, contains, ensureIndex, ensureRestrictedIndex, equals, forEach, get, getElements, hashCode, indexOf, indexOf, lastIndexOf, lastIndexOf, peek, peekLong, pop, popLong, push, push, rem, remove, removeElements, removeLong, set, set, setElements, size, size, subList, top, topLong, toString
-
Methods inherited from class it.unimi.dsi.fastutil.longs.AbstractLongCollection
add, contains, containsAll, containsAll, forEach, remove, removeAll, removeAll, removeIf, retainAll, retainAll, toArray, toLongArray, toLongArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toArray
-
Methods inherited from interface it.unimi.dsi.fastutil.longs.LongBigList
addAll, addAll, addAll, addAll, getElements, setElements, setElements, spliterator
-
-
-
-
Field Detail
-
OBJECT_EXTENSION
public static final java.lang.String OBJECT_EXTENSION
- See Also:
- Constant Field Values
-
LOWER_BITS_EXTENSION
public static final java.lang.String LOWER_BITS_EXTENSION
- See Also:
- Constant Field Values
-
length
protected final long length
The length of the sequence.
-
l
protected final int l
The number of lower bits.
-
upperBits
protected long[][] upperBits
The upper bits, stored as unary gaps.
-
lowerBits
protected it.unimi.dsi.fastutil.longs.LongMappedBigList lowerBits
The list of lower bits of each element, stored explicitly.
-
selectUpper
protected final SimpleBigSelect selectUpper
The select structure used to extract the upper bits.
-
lowerBitsMask
protected final long lowerBitsMask
The mask for the lower bits.
-
-
Constructor Detail
-
MappedEliasFanoMonotoneLongBigList
protected MappedEliasFanoMonotoneLongBigList(long length, int l, long[][] upperBits, SimpleBigSelect selectUpper, boolean littleEndian)
-
-
Method Detail
-
load
public static MappedEliasFanoMonotoneLongBigList load(java.lang.String basename) throws java.io.IOException, java.lang.ClassNotFoundException
Maps an Elias–Fano monotone list into memory.- Parameters:
basename- the basename of the dumped list. From the basename, two files will be derived: a serialized object with extensionOBJECT_EXTENSIONand a list of longs with extensionLOWER_BITS_EXTENSION.- Returns:
- an instance of this class.
- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
lowerBits
public MappedEliasFanoMonotoneLongBigList lowerBits(java.lang.String lowerBits) throws java.io.IOException
Maps the lower bits of this list from a file.This method is low level and should not be used in geneneral. There is no check that the file you are using is actually the right file for this instance.
- Parameters:
lowerBits- the name of the file containing the lower bits.- Returns:
- this instance.
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
numBits
public long numBits()
-
getLong
public long getLong(long index)
Returns the element at the specified position.- Specified by:
getLongin interfaceit.unimi.dsi.fastutil.longs.LongBigList- Parameters:
index- a position in the list.- Returns:
- the element at the specified position; if
indexis out of bounds, behavior is undefined.
-
getDelta
public long getDelta(long index)
Returns the difference between two consecutive elements of the sequence.- Parameters:
index- the index of an element (smaller thensize64()- 1).- Returns:
- the difference between the element of position
index + 1and that of positionindex; ifindexis out of bounds, behavior is undefined. - See Also:
get(long, long[])
-
get
public long[] get(long index, long[] dest, int offset, int length)Extracts a number of consecutive entries into a given array fragment.- Parameters:
index- the index of the first entry returned.dest- the destination array; it will be filled withlengthconsecutive entries starting at positionoffset; must be of length greater thanoffset.offset- the first position written indest.length- the number of elements written indeststarting atoffset.- Returns:
dest; if the arguments are out of bounds, behavior is undefined.- See Also:
get(long, long[])
-
get
public long[] get(long index, long[] dest)Extracts a number of consecutive entries into a given array.- Parameters:
index- the index of the first entry returned.dest- the destination array, of nonzero length; it will be filled with consecutive entries.- Returns:
dest; ifindexis out of bounds ordesthas length zero, behavior is undefined.- See Also:
get(long, long[], int, int)
-
listIterator
public MappedEliasFanoMonotoneLongBigList.MappedEliasFanoMonotoneLongBigListIterator listIterator(long from)
Returns a list iterator over the values of thisMappedEliasFanoMonotoneLongBigList.Forward iteration will be faster than iterated calls to
getLong(). Backward iteration is available, but it will perform similarly togetLong().- Specified by:
listIteratorin interfaceit.unimi.dsi.fastutil.BigList<java.lang.Long>- Specified by:
listIteratorin interfaceit.unimi.dsi.fastutil.longs.LongBigList- Overrides:
listIteratorin classit.unimi.dsi.fastutil.longs.AbstractLongBigList- Parameters:
from- the starting position in the sequence.- Returns:
- a list iterator over the values of this
MappedEliasFanoMonotoneLongBigList. - See Also:
MappedEliasFanoMonotoneLongBigList.MappedEliasFanoMonotoneLongBigListIterator
-
listIterator
public MappedEliasFanoMonotoneLongBigList.MappedEliasFanoMonotoneLongBigListIterator listIterator()
Returns a list iterator over the values of thisMappedEliasFanoMonotoneLongBigList.Forward iteration will be faster than iterated calls to
getLong(). Backward iteration is available, but it will perform similarly togetLong().- Specified by:
listIteratorin interfaceit.unimi.dsi.fastutil.BigList<java.lang.Long>- Specified by:
listIteratorin interfaceit.unimi.dsi.fastutil.longs.LongBigList- Overrides:
listIteratorin classit.unimi.dsi.fastutil.longs.AbstractLongBigList- Returns:
- a list iterator over the values of this
MappedEliasFanoMonotoneLongBigList. - See Also:
MappedEliasFanoMonotoneLongBigList.MappedEliasFanoMonotoneLongBigListIterator
-
iterator
public MappedEliasFanoMonotoneLongBigList.MappedEliasFanoMonotoneLongBigListIterator iterator()
Returns a list iterator over the values of thisMappedEliasFanoMonotoneLongBigList.Forward iteration will be faster than iterated calls to
getLong(). Backward iteration is available, but it will perform similarly togetLong().- Specified by:
iteratorin interfacejava.util.Collection<java.lang.Long>- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.Long>- Specified by:
iteratorin interfaceit.unimi.dsi.fastutil.longs.LongBigList- Specified by:
iteratorin interfaceit.unimi.dsi.fastutil.longs.LongCollection- Specified by:
iteratorin interfaceit.unimi.dsi.fastutil.longs.LongIterable- Overrides:
iteratorin classit.unimi.dsi.fastutil.longs.AbstractLongBigList- Returns:
- a list iterator over the values of this
MappedEliasFanoMonotoneLongBigList. - See Also:
MappedEliasFanoMonotoneLongBigList.MappedEliasFanoMonotoneLongBigListIterator
-
size64
public long size64()
- Specified by:
size64in interfaceit.unimi.dsi.fastutil.Size64
-
copy
public MappedEliasFanoMonotoneLongBigList copy()
- Specified by:
copyin interfaceit.unimi.dsi.lang.FlyweightPrototype<MappedEliasFanoMonotoneLongBigList>
-
-