Class FileBackedPBEventStream
java.lang.Object
edu.stanford.slac.archiverappliance.plain.pb.FileBackedPBEventStream
- All Implemented Interfaces:
ETLPBByteStream,Closeable,AutoCloseable,Iterable<Event>,RemotableOverRaw,ETLBulkStream,EventStream
public class FileBackedPBEventStream
extends Object
implements EventStream, RemotableOverRaw, ETLPBByteStream
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
ConstructorsConstructorDescriptionFileBackedPBEventStream(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, Instant startTime, Instant endTime, boolean skipSearch) Used when we know the start and end times.FileBackedPBEventStream(String pvname, Path path, ArchDBRTypes dbrtype, Instant startAtTime, BiDirectionalIterable.IterationDirection direction) Used for unlimited iteration. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()getByteChannel(BasicContext context) Get a byte channel positioned at the first event (after the header).getFirstEvent(BasicContext context) Get the first event in this event stream.iterator()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
FileBackedPBEventStream
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, Instant startTime, Instant 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-trueorfalse- Throws:
IOException-
-
FileBackedPBEventStream
public FileBackedPBEventStream(String pvname, Path path, ArchDBRTypes dbrtype, Instant startAtTime, BiDirectionalIterable.IterationDirection direction) throws IOException Used for unlimited iteration. We specify a time to start the iteration at and a direction.- Parameters:
pvname- The PV namepath- Pathdbrtype- Enum ArchDBRTypesstartAtTime- Start iteration at time- Throws:
IOException-
-
-
Method Details
-
iterator
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getDescription
- Specified by:
getDescriptionin interfaceEventStream- Specified by:
getDescriptionin interfaceRemotableOverRaw
-
getPvName
-
getFirstEvent
Description copied from interface:ETLBulkStreamGet the first event in this event stream. If there are no events in this stream, return null.- Specified by:
getFirstEventin interfaceETLBulkStream- Parameters:
context- BasicContext- Returns:
- Event return the first event, or null
- Throws:
IOException-
-
getByteChannel
Description copied from interface:ETLPBByteStreamGet a byte channel positioned at the first event (after the header).- Specified by:
getByteChannelin interfaceETLPBByteStream- Parameters:
context- BasicContext- Returns:
- ReadableByteChannel A channel that can read bytes.
- Throws:
IOException-- See Also:
-