Package org.ojalgo.netio
Class SegmentedFile
java.lang.Object
org.ojalgo.netio.SegmentedFile
- All Implemented Interfaces:
AutoCloseable
Divides a large file in segments and then reads those (in parallel) using memory mapped files (memory
mapped file segments). Basic usage:
- Call
newBuilder(File)
to get aSegmentedFile.Builder
orof(File)
to get aSegmentedFile
directly with the default settings. - Then for each of the segments obtained from
segments()
: CallnewTextLineReader(Segment)
and using that read all the lines.
TextLineReader
for each segment.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FileChannel
private final RandomAccessFile
private final SegmentedFile.Segment[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static SegmentedFile.Builder
newBuilder
(File file) newTextLineReader
(SegmentedFile.Segment segment) Call this once for each file segment, and use the returnedTextLineReader
to read the file segment.static SegmentedFile
segments()
-
Field Details
-
myFileChannel
-
myRandomAccessFile
-
mySegments
-
-
Constructor Details
-
SegmentedFile
SegmentedFile(RandomAccessFile file, SegmentedFile.Segment[] segments)
-
-
Method Details
-
newBuilder
-
of
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
newTextLineReader
Call this once for each file segment, and use the returnedTextLineReader
to read the file segment. TheTextLineReader
is not thread safe, and should only be used by a single thread.The segment is a range of bytes in the file. The
TextLineReader
will read the bytes in the range [offset, offset + size). The segments are obtained fromsegments()
. The segments are sorted in ascending order by offset. -
segments
-