Closeable
, AutoCloseable
public class HistogramLogReader extends Object implements Closeable
Histogram logs are used to capture full fidelity, per-time-interval histograms of a recorded value.
For example, a histogram log can be used to capture high fidelity reaction-time logs for some measured system or subsystem component. Such a log would capture a full reaction time histogram for each logged interval, and could be used to later reconstruct a full HdrHistogram of the measured reaction time behavior for any arbitrary time range within the log, by adding [only] the relevant interval histograms.
A valid interval description line contains an optional Tag=tagString text field, followed by an interval description.
A valid interval description must contain exactly four text fields:
Constructor | Description |
---|---|
HistogramLogReader(File inputFile) |
Constructs a new HistogramLogReader that produces intervals read from the specified file.
|
HistogramLogReader(InputStream inputStream) |
Constructs a new HistogramLogReader that produces intervals read from the specified InputStream.
|
HistogramLogReader(String inputFileName) |
Constructs a new HistogramLogReader that produces intervals read from the specified file name.
|
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
|
double |
getStartTimeSec() |
get the latest start time found in the file so far (or 0.0),
per the log file format explained above.
|
boolean |
hasNext() |
Indicates whether or not additional intervals may exist in the log
|
EncodableHistogram |
nextAbsoluteIntervalHistogram(double absoluteStartTimeSec,
double absoluteEndTimeSec) |
Read the next interval histogram from the log, if interval falls within an absolute time range
|
EncodableHistogram |
nextIntervalHistogram() |
Read the next interval histogram from the log.
|
EncodableHistogram |
nextIntervalHistogram(double startTimeSec,
double endTimeSec) |
Read the next interval histogram from the log, if interval falls within a time range.
|
public HistogramLogReader(String inputFileName) throws FileNotFoundException
inputFileName
- The name of the file to read fromFileNotFoundException
- when unable to find inputFileNamepublic HistogramLogReader(InputStream inputStream)
inputStream
- The InputStream to read frompublic HistogramLogReader(File inputFile) throws FileNotFoundException
inputFile
- The File to read fromFileNotFoundException
- when unable to find inputFilepublic double getStartTimeSec()
public EncodableHistogram nextIntervalHistogram(double startTimeSec, double endTimeSec)
Returns a histogram object if an interval line was found with an associated start timestamp value that falls between startTimeSec and endTimeSec, or null if no such interval line is found. Note that the range is assumed to be in seconds relative to the actual timestamp value found in each interval line in the log, and not in absolute time.
Timestamps are assumed to appear in order in the log file, and as such this method will return a null upon encountering a timestamp larger than rangeEndTimeSec.
The histogram returned will have it's timestamp set to the absolute timestamp calculated from adding the interval's indicated timestamp value to the latest [optional] start time found in the log.
Upon encountering any unexpected format errors in reading the next
interval from the file, this method will return a null. Use hasNext()
to determine
whether or not additional intervals may be available for reading in the log input.
startTimeSec
- The (non-absolute time) start of the expected
time range, in seconds.endTimeSec
- The (non-absolute time) end of the expected time
range, in seconds.public EncodableHistogram nextAbsoluteIntervalHistogram(double absoluteStartTimeSec, double absoluteEndTimeSec)
Returns a histogram object if an interval line was found with an associated absolute start timestamp value that falls between absoluteStartTimeSec and absoluteEndTimeSec, or null if no such interval line is found.
Timestamps are assumed to appear in order in the log file, and as such this method will return a null upon encountering a timestamp larger than rangeEndTimeSec.
The histogram returned will have it's timestamp set to the absolute timestamp calculated from adding the interval's indicated timestamp value to the latest [optional] start time found in the log.
Absolute timestamps are calculated by adding the timestamp found with the recorded interval to the [latest, optional] start time found in the log. The start time is indicated in the log with a "#[StartTime: " followed by the start time in seconds.
Upon encountering any unexpected format errors in reading the next
interval from the file, this method will return a null. Use hasNext()
to determine
whether or not additional intervals may be available for reading in the log input.
absoluteStartTimeSec
- The (absolute time) start of the expected
time range, in seconds.absoluteEndTimeSec
- The (absolute time) end of the expected
time range, in seconds.public EncodableHistogram nextIntervalHistogram()
Upon encountering any unexpected format errors in reading the next interval
from the input, this method will return a null. Use hasNext()
to determine
whether or not additional intervals may be available for reading in the log input.
public boolean hasNext()
public void close()
close
in interface AutoCloseable
close
in interface Closeable
Copyright © 2019. All rights reserved.