Class FileBackedPBEventStream
- java.lang.Object
-
- edu.stanford.slac.archiverappliance.PlainPB.FileBackedPBEventStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<Event>
,ETLBulkStream
,EventStream
,RemotableOverRaw
public class FileBackedPBEventStream extends Object implements EventStream, RemotableOverRaw, ETLBulkStream
An EventStream that is backed by a single PB file. You can only get one iterator out of this event stream. This condition is also checked for. This is typically used with/after PlainPBFileNameUtility.getFilesWithData- Author:
- mshankar
-
-
Constructor Summary
Constructors Constructor Description FileBackedPBEventStream(String pvname, Path path, ArchDBRTypes type)
Used when we want to include data from the entire file.FileBackedPBEventStream(String pvname, Path path, ArchDBRTypes type, long startPosition, long endPosition)
Used when we know the file locations of the start and end.FileBackedPBEventStream(String pvname, Path path, ArchDBRTypes dbrtype, Timestamp startTime, Timestamp endTime, boolean skipSearch)
Used when we know the start and end times.
-
Method Summary
Modifier and Type Method Description void
close()
ReadableByteChannel
getByteChannel(BasicContext context)
Get a byte channel positioned at the first event (after the header).RemotableEventStreamDesc
getDescription()
Event
getFirstEvent(BasicContext context)
Get the first event in this event stream.String
getPvName()
Iterator<Event>
iterator()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
FileBackedPBEventStream
public FileBackedPBEventStream(String pvname, Path path, ArchDBRTypes type) throws IOException
Used when we want to include data from the entire file.- Parameters:
pvname
- The PV namepath
- pathtype
- Enum ArchDBRTypes- Throws:
IOException
-
-
FileBackedPBEventStream
public FileBackedPBEventStream(String pvname, Path path, ArchDBRTypes type, long startPosition, long endPosition) throws IOException
Used when we know the file locations of the start and end. Really only used in one utility...- Parameters:
pvname
- The PV namepath
- Pathtype
- Enum ArchDBRTypesstartPosition
- The file location of the startendPosition
- The file location of the end- Throws:
IOException
-
-
FileBackedPBEventStream
public FileBackedPBEventStream(String pvname, Path path, ArchDBRTypes dbrtype, Timestamp startTime, Timestamp endTime, boolean skipSearch) throws IOException
Used when we know the start and end times. There are six cases here; see the FileBackedIteratorTest for more details. For performance reasons, we want to use the location based iterator as much as possible. But in case of issues, we do not want to not return data. So, fall back to a time based iterator- Parameters:
pvname
- The PV namepath
- Pathdbrtype
- Enum ArchDBRTypesstartTime
- The start timeendTime
- The end timeskipSearch
-true
orfalse
- Throws:
IOException
-
-
-
Method Detail
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
getDescription
public RemotableEventStreamDesc getDescription()
- Specified by:
getDescription
in interfaceEventStream
- Specified by:
getDescription
in interfaceRemotableOverRaw
-
getPvName
public String getPvName()
-
getFirstEvent
public Event getFirstEvent(BasicContext context) throws IOException
Description copied from interface:ETLBulkStream
Get the first event in this event stream. If there are no events in this stream, return null.- Specified by:
getFirstEvent
in interfaceETLBulkStream
- Parameters:
context
- BasicContext- Returns:
- Event return the first event, or null
- Throws:
IOException
-
-
getByteChannel
public ReadableByteChannel getByteChannel(BasicContext context) throws IOException
Description copied from interface:ETLBulkStream
Get a byte channel positioned at the first event (after the header).- Specified by:
getByteChannel
in interfaceETLBulkStream
- Parameters:
context
- BasicContext- Returns:
- ReadableByteChannel A channel that can read bytes.
- Throws:
IOException
-- See Also:
- java.nio.channels.ReadableByteChannel
-
-