File indexing completed on 2024-05-31 04:19:41
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 }
0020 namespace edm::streamer {
0021 class StreamerInputFile {
0022 public:
0023
0024 explicit StreamerInputFile(std::string const& name,
0025 std::string const& LFN,
0026 std::shared_ptr<EventSkipperByID> eventSkipperByID = std::shared_ptr<EventSkipperByID>(),
0027 unsigned int prefetchMBytes = 0);
0028 explicit StreamerInputFile(std::string const& name,
0029 std::shared_ptr<EventSkipperByID> eventSkipperByID = std::shared_ptr<EventSkipperByID>(),
0030 unsigned int prefetchMBytes = 0);
0031
0032
0033 explicit StreamerInputFile(std::vector<FileCatalogItem> const& names,
0034 std::shared_ptr<EventSkipperByID> eventSkipperByID = std::shared_ptr<EventSkipperByID>(),
0035 unsigned int prefetchMBytes = 0);
0036
0037 ~StreamerInputFile();
0038
0039 enum class Next { kEvent, kFile, kStop };
0040 Next next();
0041
0042 InitMsgView const* startMessage() const { return startMsg_.get(); }
0043
0044
0045 EventMsgView const* currentRecord() const { return currentEvMsg_.get(); }
0046
0047
0048 bool newHeader() {
0049 bool tmp = newHeader_;
0050 newHeader_ = false;
0051 return tmp;
0052 }
0053
0054 void closeStreamerFile();
0055 bool openNextFile();
0056
0057 private:
0058 void openStreamerFile(std::string const& name, std::string const& LFN);
0059 std::pair<storage::IOSize, char*> readBytes(char* buf,
0060 storage::IOSize nBytes,
0061 bool zeroCopy,
0062 unsigned int skippedHdr = 0);
0063 storage::IOOffset skipBytes(storage::IOSize nBytes);
0064
0065 void readStartMessage();
0066 int readEventMessage();
0067
0068
0069
0070 bool compareHeader();
0071
0072 void logFileAction(char const* msg);
0073
0074 edm::propagate_const<std::shared_ptr<InitMsgView>> startMsg_;
0075 edm::propagate_const<std::shared_ptr<EventMsgView>> currentEvMsg_;
0076
0077 std::vector<char> headerBuf_;
0078 std::vector<char> eventBuf_;
0079
0080 std::vector<char> tempBuf_;
0081 unsigned int tempLen_ = 0;
0082 unsigned int tempPos_ = 0;
0083
0084 unsigned int currentFile_;
0085 std::vector<FileCatalogItem> streamerNames_;
0086 bool multiStreams_;
0087 std::string currentFileName_;
0088 bool currentFileOpen_;
0089
0090 edm::propagate_const<std::shared_ptr<EventSkipperByID>> eventSkipperByID_;
0091
0092 uint32 currRun_;
0093 uint32 currProto_;
0094
0095 bool newHeader_;
0096
0097 edm::propagate_const<std::unique_ptr<edm::storage::Storage>> storage_;
0098
0099 bool endOfFile_;
0100 };
0101 }
0102
0103 #endif