Class FileLinesBigList
- All Implemented Interfaces:
BigList<MutableString>
,ObjectBigList<MutableString>
,ObjectCollection<MutableString>
,ObjectIterable<MutableString>
,Size64
,Stack<MutableString>
,Serializable
,Comparable<BigList<? extends MutableString>>
,Iterable<MutableString>
,Collection<MutableString>
,RandomAccess
An instance of this class allows to access the lines of a file as a BigList
. Contrarily
to a big FileLinesMutableStringIterable
, direct access is possible and
reasonably efficient, in particular when accessing nearby lines, and all returned
mutable strings are separate, independent instances.
Similarly to FileLinesMutableStringIterable
, instead, AbstractObjectBigList.iterator()
can be called any number of
times, as it opens an independent input stream at each call. For the same reason, the returned
iterator type (FileLinesBigList.FileLinesIterator
) is Closeable
, and
should be closed after usage.
Note that toString()
will return a single string containing all file lines separated by
the string associated to the system property line.separator
.
Warning: this class is not synchronised. Separate iterators use separate input
streams, and can be accessed concurrently, but all calls to get(long)
refer to the same
input stream.
Implementation details
Instances of this class perform a full scan of the specified file at construction time, representing the list of pointers to the start of each line using the Elias–Fano representation. The memory occupation per line is thus bounded by 2 + log ℓ bits, where ℓ is the average line length.
- Since:
- 2.1
- Author:
- Sebastiano Vigna
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
An iterator over the lines of aFileLinesBigList
.Nested classes/interfaces inherited from class it.unimi.dsi.fastutil.objects.AbstractObjectBigList
AbstractObjectBigList.ObjectRandomAccessSubList<K extends Object>, AbstractObjectBigList.ObjectSubList<K extends Object>
-
Constructor Summary
ConstructorDescriptionFileLinesBigList
(CharSequence filename, String encoding) Creates a file-lines collection for the specified filename with the specified encoding, default buffer size and with all terminators.FileLinesBigList
(CharSequence filename, String encoding, int bufferSize) Creates a file-lines collection for the specified filename with the specified encoding, buffer size and with all terminators.FileLinesBigList
(CharSequence filename, String encoding, int bufferSize, EnumSet<FastBufferedInputStream.LineTerminator> terminators) Creates a file-lines collection for the specified filename with the specified encoding, buffer size and terminator set. -
Method Summary
Modifier and TypeMethodDescriptionget
(long index) get
(long index, FastBufferedInputStream fastBufferedInputStream, ByteBuffer byteBuffer, CharBuffer charBuffer, CharsetDecoder decoder) listIterator
(long index) int
size()
Deprecated.long
size64()
toString()
Methods inherited from class it.unimi.dsi.fastutil.objects.AbstractObjectBigList
add, add, addAll, addAll, addElements, addElements, clear, compareTo, contains, ensureIndex, ensureRestrictedIndex, equals, forEach, getElements, hashCode, indexOf, iterator, lastIndexOf, listIterator, peek, pop, push, remove, removeElements, set, setElements, size, subList, top
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
containsAll, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, stream, toArray, toArray, toArray
Methods inherited from interface it.unimi.dsi.fastutil.objects.ObjectBigList
addAll, addAll, addAll, addAll, getElements, setElements, setElements, spliterator
-
Constructor Details
-
FileLinesBigList
public FileLinesBigList(CharSequence filename, String encoding, int bufferSize, EnumSet<FastBufferedInputStream.LineTerminator> terminators) throws IOException Creates a file-lines collection for the specified filename with the specified encoding, buffer size and terminator set.- Parameters:
filename
- a filename.encoding
- an encoding.bufferSize
- the buffer size forFastBufferedInputStream
.terminators
- a set of line terminators.- Throws:
IOException
-
FileLinesBigList
Creates a file-lines collection for the specified filename with the specified encoding, buffer size and with all terminators.- Parameters:
filename
- a filename.encoding
- an encoding.bufferSize
- the buffer size forFastBufferedInputStream
.- Throws:
IOException
-
FileLinesBigList
Creates a file-lines collection for the specified filename with the specified encoding, default buffer size and with all terminators.- Parameters:
filename
- a filename.encoding
- an encoding.- Throws:
IOException
-
-
Method Details
-
size64
public long size64() -
size
Deprecated.- Specified by:
size
in interfaceBigList<MutableString>
- Specified by:
size
in interfaceCollection<MutableString>
- Specified by:
size
in interfaceSize64
- Overrides:
size
in classAbstractObjectBigList<MutableString>
-
get
- Specified by:
get
in interfaceBigList<MutableString>
-
get
public MutableString get(long index, FastBufferedInputStream fastBufferedInputStream, ByteBuffer byteBuffer, CharBuffer charBuffer, CharsetDecoder decoder) -
listIterator
- Specified by:
listIterator
in interfaceBigList<MutableString>
- Specified by:
listIterator
in interfaceObjectBigList<MutableString>
- Overrides:
listIterator
in classAbstractObjectBigList<MutableString>
-
toString
- Overrides:
toString
in classAbstractObjectBigList<MutableString>
-