Class FileEventStreamSearch
java.lang.Object
edu.stanford.slac.archiverappliance.PB.search.FileEventStreamSearch
This is a variant of binary search that searches for an event in a event stream file.
We assume a time-sorted PB file separated by unix newlines as outlined in the archiver appliance design doc.
We pass in file channel and a function that compares an event line (most likely a PB) to the desired time t1.
The fileChannels position is moved to a spot where this constraint is satisfied s1 ≤ t1 < s2
That is
- Search the file for a time t1
- Do a LineByteStream.seekToFirstNewLine
- LineByteStream.readLine's after this should give events that satisfy getData's requirements.
- Remember to terminate appropriately
- Author:
- mshankar
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongbooleanseekToTime(CompareEventLine comparefunction) This should only be used by the unit tests.booleanseekToTime(ArchDBRTypes dbrtype, YearSecondTimestamp yearSecondTimestamp) Set the fileChannels position to a point that best satisfies the requirements for getData(t1,...).
-
Constructor Details
-
FileEventStreamSearch
- Parameters:
path- PathstartPosn- a starting position of search PB files
-
-
Method Details
-
getFoundPosition
public long getFoundPosition() -
seekToTime
public boolean seekToTime(ArchDBRTypes dbrtype, YearSecondTimestamp yearSecondTimestamp) throws IOException Set the fileChannels position to a point that best satisfies the requirements for getData(t1,...). If found (return value is true), the file's position is set such thatLineByteStream lis = new LineByteStream(fchannel); lis.seekToFirstNewLine(); byte[] line = lis.readLine();starts returning events that satisfy getData's requirements- Parameters:
dbrtype- ArchDBRType the enumeration typeyearSecondTimestamp- Search seconds into year- Returns:
trueorfalse- Throws:
IOException-- See Also:
-
seekToTime
This should only be used by the unit tests.- Parameters:
comparefunction- CompareEventLine- Returns:
trueorfalse- Throws:
IOException- when parsing the absolute path
-