File indexing completed on 2023-03-17 11:10:27
0001 #ifndef IOPool_Streamer_StreamerInputFile_h
0002 #define IOPool_Streamer_StreamerInputFile_h
0003
0004 #include "IOPool/Streamer/interface/InitMessage.h"
0005 #include "IOPool/Streamer/interface/EventMessage.h"
0006 #include "IOPool/Streamer/interface/MsgTools.h"
0007 #include "Utilities/StorageFactory/interface/IOTypes.h"
0008 #include "Utilities/StorageFactory/interface/Storage.h"
0009 #include "FWCore/Utilities/interface/propagate_const.h"
0010
0011 #include <memory>
0012
0013 #include <string>
0014 #include <vector>
0015
0016 namespace edm {
0017 class EventSkipperByID;
0018 class FileCatalogItem;
0019 class StreamerInputFile {
0020 public:
0021
0022 explicit StreamerInputFile(std::string const& name,
0023 std::string const& LFN,
0024 std::shared_ptr<EventSkipperByID> eventSkipperByID = std::shared_ptr<EventSkipperByID>(),
0025 unsigned int prefetchMBytes = 0);
0026 explicit StreamerInputFile(std::string const& name,
0027 std::shared_ptr<EventSkipperByID> eventSkipperByID = std::shared_ptr<EventSkipperByID>(),
0028 unsigned int prefetchMBytes = 0);
0029
0030
0031 explicit StreamerInputFile(std::vector<FileCatalogItem> const& names,
0032 std::shared_ptr<EventSkipperByID> eventSkipperByID = std::shared_ptr<EventSkipperByID>(),
0033 unsigned int prefetchMBytes = 0);
0034
0035 ~StreamerInputFile();
0036
0037 enum class Next { kEvent, kFile, kStop };
0038 Next next();
0039
0040 InitMsgView const* startMessage() const { return startMsg_.get(); }
0041
0042
0043 EventMsgView const* currentRecord() const { return currentEvMsg_.get(); }
0044
0045
0046 bool newHeader() {
0047 bool tmp = newHeader_;
0048 newHeader_ = false;
0049 return tmp;
0050 }
0051
0052 void closeStreamerFile();
0053 bool openNextFile();
0054
0055 private:
0056 void openStreamerFile(std::string const& name, std::string const& LFN);
0057 std::pair<storage::IOSize, char*> readBytes(char* buf,
0058 storage::IOSize nBytes,
0059 bool zeroCopy,
0060 unsigned int skippedHdr = 0);
0061 storage::IOOffset skipBytes(storage::IOSize nBytes);
0062
0063 void readStartMessage();
0064 int readEventMessage();
0065
0066
0067
0068 bool compareHeader();
0069
0070 void logFileAction(char const* msg);
0071
0072 edm::propagate_const<std::shared_ptr<InitMsgView>> startMsg_;
0073 edm::propagate_const<std::shared_ptr<EventMsgView>> currentEvMsg_;
0074
0075 std::vector<char> headerBuf_;
0076 std::vector<char> eventBuf_;
0077
0078 std::vector<char> tempBuf_;
0079 unsigned int tempLen_ = 0;
0080 unsigned int tempPos_ = 0;
0081
0082 unsigned int currentFile_;
0083 std::vector<FileCatalogItem> streamerNames_;
0084 bool multiStreams_;
0085 std::string currentFileName_;
0086 bool currentFileOpen_;
0087
0088 edm::propagate_const<std::shared_ptr<EventSkipperByID>> eventSkipperByID_;
0089
0090 uint32 currRun_;
0091 uint32 currProto_;
0092
0093 bool newHeader_;
0094
0095 edm::propagate_const<std::unique_ptr<edm::storage::Storage>> storage_;
0096
0097 bool endOfFile_;
0098 };
0099 }
0100
0101 #endif