Class FileEventStreamSearch
- java.lang.Object
-
- edu.stanford.slac.archiverappliance.PB.search.FileEventStreamSearch
-
public class FileEventStreamSearch extends Object
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 Constructor Description FileEventStreamSearch(Path path, long startPosn)
-
Method Summary
Modifier and Type Method Description long
getFoundPosition()
boolean
seekToTime(CompareEventLine comparefunction)
This should only be used by the unit tests.boolean
seekToTime(ArchDBRTypes dbrtype, int secondsIntoYear)
Set the fileChannels position to a point that best satisfies the requirements for getData(t1,...).
-
-
-
Constructor Detail
-
FileEventStreamSearch
public FileEventStreamSearch(Path path, long startPosn)
- Parameters:
path
- PathstartPosn
- a starting position of search PB files
-
-
Method Detail
-
getFoundPosition
public long getFoundPosition()
-
seekToTime
public boolean seekToTime(ArchDBRTypes dbrtype, int secondsIntoYear) 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 typesecondsIntoYear
- Search seconds into year- Returns:
true
orfalse
- Throws:
IOException
-- See Also:
ComparePBEvent
-
seekToTime
public boolean seekToTime(CompareEventLine comparefunction) throws IOException
This should only be used by the unit tests.- Parameters:
comparefunction
- CompareEventLine- Returns:
true
orfalse
- Throws:
IOException
- when parsing the absolute path
-
-