public final class WitsmlReader extends Object
Typical usage:
If the curve data is not needed, it is possible to read only the metadata. The curve data may be filled in later:WitsmlReader reader = new WitamlReader(new File("path/to/file"); List<WitsmlLog> logs = reader.read(true, false, null);
Note that even if only metadata is read, all curve information are properly established as this information comes from metadata. Only the curve values will be missing.WitsmlReader reader = new WitsmlReader(new File("path/to/file")); List<WitsmlLog> logs = reader.read(false, false, null); : reader.readData(logs);
If the WITSML content is larger than physical memory, it is possible
to stream (process than throw away) the data during read.
See WitsmlDataListener
. The same mechanism may be used
to abort the reading process during the operation.
Constructor and Description |
---|
WitsmlReader(File file)
Create a WITSML reader for the specified disk file.
|
WitsmlReader(InputStream inputStream)
Create a WITSML reader for the specified input stream.
|
Modifier and Type | Method and Description |
---|---|
static double |
isWitsmlFile(File file,
byte[] content)
Get the probability that the specified file is a
WITSML log.
|
List<WitsmlLog> |
read(boolean shouldReadBulkData,
boolean shouldCaptureStatistics,
WitsmlDataListener dataListener)
Read log from the content of this reader.
|
void |
readData(List<WitsmlLog> logs,
boolean shouldCaptureStatistics,
WitsmlDataListener dataListener)
Read data for a set of WITSML logs where the metadata has
already been read.
|
public WitsmlReader(InputStream inputStream)
inputStream
- Stream to read. Non-null.IllegalArgumentException
- If inputStream is null.public WitsmlReader(File file)
file
- File to read. Non-null.IllegalArgumentException
- If file is null.public static double isWitsmlFile(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<WitsmlLog> logs, boolean shouldCaptureStatistics, WitsmlDataListener 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 meta data List<WitsmlLog> logs = reader.read(false, ...); // Read the curve data reader.readData(logs);
// Read metadata List<WitsmlLog> logs = reader.read(false, ...); // Read all the data logs = reader.read(true, ...);
logs
- The logs to populate. These must be the
exact same list as retrieved by calling the
#read(false,...) on the same WitsmlReader 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 logs is null.IOException
- If the read operation fails for some reason.InterruptedException
- If the client returns false from
the WitsmlDataListener.dataRead(no.petroware.logio.witsml.WitsmlLog)
method.public List<WitsmlLog> read(boolean shouldReadBulkData, boolean shouldCaptureStatistics, WitsmlDataListener dataListener) throws IOException, InterruptedException
shouldReadBulkData
- True if bulk data should be read, false
if only metadata should be read.shouldCaptureStatistics
- True if curve statistics should be
captures, false otherwise,dataListener
- Client data listener. Null if not used.IOException
- If the read operation fails for some reason.InterruptedException
- If the client returns false from
the WitsmlDataListener.dataRead(no.petroware.logio.witsml.WitsmlLog)
method.Copyright © 2024 Petroware AS - https://petroware.no