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.Builderorof(File)to get aSegmentedFiledirectly 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 classstatic final class -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static SegmentedFile.BuildernewBuilder(File file) <T> FromFileReader<T> newDataReader(DataReader.Deserializer<T> deserializer) <T> DataReader<T> newDataReader(SegmentedFile.Segment segment, DataReader.Deserializer<T> deserializer) <T> Supplier<FromFileReader<T>> newSequencedFactory(Function<SegmentedFile.Segment, FromFileReader<T>> factory) Each reader instantiated by this factory will read from the segments in sequence, until all of them are done.newTextLineReader(SegmentedFile.Segment segment) Call this once for each file segment, and use the returnedTextLineReaderto read the file segment.<T> FromFileReader<T> newTextLineReader(TextLineReader.Parser<T> parser) static SegmentedFilesegments()
-
Method Details
-
newBuilder
-
of
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
newDataReader
-
newDataReader
public <T> DataReader<T> newDataReader(SegmentedFile.Segment segment, DataReader.Deserializer<T> deserializer) -
newSequencedFactory
public <T> Supplier<FromFileReader<T>> newSequencedFactory(Function<SegmentedFile.Segment, FromFileReader<T>> factory) Each reader instantiated by this factory will read from the segments in sequence, until all of them are done. The idea is that you can create multiple readers and have them work in parallel (each segment will only be read once by one of the readers). If you only instantiate 1 reader, then maybe you shouldn't have created file segments in the first place. -
newTextLineReader
-
newTextLineReader
Call this once for each file segment, and use the returnedTextLineReaderto read the file segment. TheTextLineReaderis not thread safe, and should only be used by a single thread.The segment is a range of bytes in the file. The
TextLineReaderwill read the bytes in the range [offset, offset + size). The segments are obtained fromsegments(). The segments are sorted in ascending order by offset. -
newTextLineReader
-
segments
-