public class FileLinesBigList extends AbstractObjectBigList<MutableString> implements RandomAccess, Serializable
An instance of this class allows to access the lines of a file as a
BigList. Contrarily to a big FileLinesCollection, direct access
is possible and reasonably efficient, in particular when accessing nearby lines, and
all returned mutable strings are separate, independent instances.
Similarly to FileLinesCollection, 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 AbstractObjectBigList.get(int) refer to the
same input stream.
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
FileLinesBigList.FileLinesIterator
An iterator over the lines of a
FileLinesBigList. |
AbstractObjectBigList.ObjectSubList<K>| Constructor and Description |
|---|
FileLinesBigList(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.
|
| Modifier and Type | Method and Description |
|---|---|
MutableString |
get(long index) |
MutableString |
get(long index,
FastBufferedInputStream fastBufferedInputStream,
ByteBuffer byteBuffer,
CharBuffer charBuffer,
CharsetDecoder decoder) |
FileLinesBigList.FileLinesIterator |
listIterator(long index) |
int |
size()
Deprecated.
|
long |
size64() |
String |
toString() |
add, add, addAll, addAll, addAll, addElements, addElements, compareTo, contains, ensureIndex, ensureRestrictedIndex, equals, get, getElements, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, peek, pop, push, remove, remove, removeElements, set, set, size, size, subList, topcontainsAll, isEmpty, objectIterator, removeAll, retainAll, toArray, toArrayclear, removeclone, finalize, getClass, notify, notifyAll, wait, wait, waitobjectIterator, toArrayclear, containsAll, isEmpty, remove, removeAll, retainAll, toArraypublic FileLinesBigList(CharSequence filename, String encoding, int bufferSize, EnumSet<FastBufferedInputStream.LineTerminator> terminators) throws IOException
filename - a filename.encoding - an encoding.bufferSize - the buffer size for FastBufferedInputStream.terminators - a set of line terminators.IOExceptionpublic FileLinesBigList(CharSequence filename, String encoding, int bufferSize) throws IOException
filename - a filename.encoding - an encoding.bufferSize - the buffer size for FastBufferedInputStream.IOExceptionpublic FileLinesBigList(CharSequence filename, String encoding) throws IOException
filename - a filename.encoding - an encoding.IOException@Deprecated public int size()
size in interface Size64size in interface Collection<MutableString>size in class AbstractObjectBigList<MutableString>public MutableString get(long index)
get in interface BigList<MutableString>public MutableString get(long index, FastBufferedInputStream fastBufferedInputStream, ByteBuffer byteBuffer, CharBuffer charBuffer, CharsetDecoder decoder)
public FileLinesBigList.FileLinesIterator listIterator(long index)
listIterator in interface BigList<MutableString>listIterator in interface ObjectBigList<MutableString>listIterator in class AbstractObjectBigList<MutableString>public String toString()
toString in class AbstractObjectBigList<MutableString>