Class 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
    1. Search the file for a time t1
    2. Do a LineByteStream.seekToFirstNewLine
    3. LineByteStream.readLine's after this should give events that satisfy getData's requirements.
    4. Remember to terminate appropriately
    • Constructor Detail

      • FileEventStreamSearch

        public FileEventStreamSearch​(Path path,
                                     long startPosn)
        path - Path
        startPosn - 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 that LineByteStream lis = new LineByteStream(fchannel); lis.seekToFirstNewLine(); byte[] line = lis.readLine(); starts returning events that satisfy getData's requirements
        dbrtype - ArchDBRType the enumeration type
        secondsIntoYear - Search seconds into year
        true or false
        IOException -  
        See Also:
      • seekToTime

        public boolean seekToTime​(CompareEventLine comparefunction)
                           throws IOException
        This should only be used by the unit tests.
        comparefunction - CompareEventLine
        true or false
        IOException - when parsing the absolute path