public final class DlisFileReader extends Object
Typical usage:
If the curve data is not needed, it is possible to read only the metadata from the disk file. The curve data may be filled in later:DlisFileReader reader = new DlisFileReader(new File("path/to/file.DLIS")); List<DlisFile> dlisFiles = reader.read(true, false, null);
Note that even if only metadata is read, all frames and curve information are properly established as this information comes from metadata. Only the curve values will be missing.DlisFileReader reader = new DlisFileReader(new File("path/to/file.DLIS")); List<DlisFile> dlisFiles = reader.read(false, false, null); reader.readData(dlisFiles);
If disk files are larger than physical memory, it is possible to
stream (process than throw away) the data during read.
See DlisDataListener
. The same mechanism may be use to be
able to abort the reading process during the operation.
Constructor and Description |
---|
DlisFileReader(File file)
Create a DLIS file reader for the specified disk file.
|
DlisFileReader(InputStream inputStream)
Create a DLIS file reader for the specified stream.
|
Modifier and Type | Method and Description |
---|---|
static double |
isDlisFile(File file,
byte[] content)
Get the probability that the specified file is a DLIS file.
|
List<DlisFile> |
read(boolean shouldReadCurveData,
boolean shouldCaptureStatistics,
DlisDataListener dataListener)
Read all DLIS files from the disk file of this reader.
|
void |
readData(List<DlisFile> dlisFiles,
boolean shouldCaptureStatistics,
DlisDataListener dataListener)
Read data from a set of DLIS files where the metadata has
already been read.
|
public DlisFileReader(InputStream inputStream)
inputStream
- Stream to read. Non-null.IllegalArgumentException
- If inputStream is null.public DlisFileReader(File file)
file
- Disk file to read. Non-null.IllegalArgumentException
- If file is null.public static double isDlisFile(File file, byte[] content)
The check can be done with or without considering the content of the file. In the latter case, only the file name (typically its extension) is considered. In the former case a portion from the start of the file is used to match for known patterns. By passing the portion as an argument, the client code can read this once and then pass it to different classifiers in order to determine its most likely type.
Getting a portion of a file can be done by:
File file = ...; BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file)); byte[] content = new byte[2000]; stream.read(content, 0, content.length); stream.close();
file
- File to check. Null to classify on content only.content
- A number of bytes from the start of the file.
Null to classify on file name only.public void readData(List<DlisFile> dlisFiles, boolean shouldCaptureStatistics, DlisDataListener dataListener) throws IOException, InterruptedException
There is nothing to gain in performance with this approach so in case the result is not cached, the following will be equivalent:// Read metadata List<DlisFile> dlisFiles = reader.read(false, ...); // Read the curve data reader.readData(dlisFiles);
// Read metadata List<DlisFile> dlisFiles = reader.read(false, ...); // Read all the data dlisFiles = reader.read(true, ...);
dlisFiles
- The DLIS files to populate. These must be the
exact same list as retrieved by calling the
#read(false,...) on the same DlisFileReader instance.
Otherwise the behavior is unpredictable.shouldCaptureStatistics
- True to capture statistics per curve during read.
Statistics capture will reduce read performance slightly,
so set this to false if the statistics are not needed.dataListener
- Listener that will be notified when new data has been read.
Null if not used.IllegalArgumentException
- If dlisFiles is null.IOException
- If the read operation fails for some reason.InterruptedException
- If the client returns false from
the DlisDataListener.dataRead(no.petroware.logio.dlis.DlisFrame, no.petroware.logio.dlis.DlisFile)
method.public List<DlisFile> read(boolean shouldReadCurveData, boolean shouldCaptureStatistics, DlisDataListener dataListener) throws IOException, InterruptedException
shouldReadCurveData
- Indicate if curve data should be read.
False to read header data only.shouldCaptureStatistics
- True to capture statistics per curve.
Statistics capture will reduce read performance slightly,
so set this to false if the statistics are not needed.dataListener
- Listener that will be notified when new data has been read.
Null if not used.IOException
- If the read operation fails for some reason.InterruptedException
- If the client returns false from
the DlisDataListener.dataRead(no.petroware.logio.dlis.DlisFrame, no.petroware.logio.dlis.DlisFile)
method.Copyright © 2024 Petroware AS - https://petroware.no