CMS 3D CMS Logo

StreamerInputSource.h
Go to the documentation of this file.
1 #ifndef IOPool_Streamer_StreamerInputSource_h
2 #define IOPool_Streamer_StreamerInputSource_h
3 
11 #include "TBufferFile.h"
12 
16 
19 
20 #include <memory>
21 #include <vector>
22 
23 namespace edm {
24  class BranchIDListHelper;
26  class ThinnedAssociationsHelper;
27 } // namespace edm
28 
29 namespace edm::streamer {
30  class InitMsgView;
31  class EventMsgView;
32 
34  public:
36  ~StreamerInputSource() override;
38 
39  std::unique_ptr<SendJobHeader> deserializeRegistry(InitMsgView const& initView);
40 
41  void deserializeAndMergeWithRegistry(InitMsgView const& initView, bool subsequent = false);
42 
43  //If eventView is a meta data event then this returns its checksum
44  uint32_t eventMetaDataChecksum(EventMsgView const& eventView) const;
45  //Should be called right after this message has been read
46  void deserializeEventMetaData(EventMsgView const& eventView);
47  void deserializeEvent(EventMsgView const& eventView);
48 
50  //This can only be called during a new file transition as it updates state that requires
51  // framework synchronization.
52  void updateEventMetaData();
53 
54  static void mergeIntoRegistry(SendJobHeader const& header, ProductRegistry&, bool subsequent);
55 
59  bool isBufferLZMA(unsigned char const* inputBuffer, unsigned int inputSize);
60 
64  bool isBufferZSTD(unsigned char const* inputBuffer, unsigned int inputSize);
65 
74  static unsigned int uncompressBuffer(unsigned char* inputBuffer,
75  unsigned int inputSize,
76  std::vector<unsigned char>& outputBuffer,
77  unsigned int expectedFullSize);
78 
79  static unsigned int uncompressBufferLZMA(unsigned char* inputBuffer,
80  unsigned int inputSize,
81  std::vector<unsigned char>& outputBuffer,
82  unsigned int expectedFullSize,
83  bool hasHeader = true);
84 
85  static unsigned int uncompressBufferZSTD(unsigned char* inputBuffer,
86  unsigned int inputSize,
87  std::vector<unsigned char>& outputBuffer,
88  unsigned int expectedFullSize,
89  bool hasHeader = true);
90 
91  protected:
92  static void declareStreamers(SendDescs const& descs);
93  static void buildClassCache(SendDescs const& descs);
94  void resetAfterEndRun();
95 
96  private:
97  void deserializeEventCommon(EventMsgView const& eventView, bool isMetaData);
98 
100  public:
102  ~EventPrincipalHolder() override;
103 
104  WrapperBase const* getIt(ProductID const& id) const override;
105  std::optional<std::tuple<edm::WrapperBase const*, unsigned int>> getThinnedProduct(ProductID const&,
106  unsigned int) const override;
107  void getThinnedProducts(ProductID const& pid,
108  std::vector<WrapperBase const*>& wrappers,
109  std::vector<unsigned int>& keys) const override;
110  OptionalThinnedKey getThinnedKeyFrom(ProductID const&, unsigned int, ProductID const&) const override;
111 
112  unsigned int transitionIndex_() const override;
113 
115 
116  private:
117  // We don't own the principal. The lifetime must be managed externally.
119  };
120 
121  void read(EventPrincipal& eventPrincipal) override;
122 
123  void setRun(RunNumber_t r) override;
124 
126  std::vector<unsigned char> dest_;
127  TBufferFile xbuf_;
130  std::vector<edm::propagate_const<std::unique_ptr<EventPrincipalHolder>>> streamToEventPrincipalHolders_;
132 
134  unsigned int protocolVersion_;
136  }; //end-of-class-def
137 } // namespace edm::streamer
138 
139 #endif
static unsigned int uncompressBufferLZMA(unsigned char *inputBuffer, unsigned int inputSize, std::vector< unsigned char > &outputBuffer, unsigned int expectedFullSize, bool hasHeader=true)
std::optional< std::tuple< edm::WrapperBase const *, unsigned int > > getThinnedProduct(ProductID const &, unsigned int) const override
std::variant< unsigned int, detail::GetThinnedKeyFromExceptionFactory, std::monostate > OptionalThinnedKey
void deserializeEventMetaData(EventMsgView const &eventView)
std::vector< BranchDescription > SendDescs
OptionalThinnedKey getThinnedKeyFrom(ProductID const &, unsigned int, ProductID const &) const override
bool isBufferZSTD(unsigned char const *inputBuffer, unsigned int inputSize)
void deserializeEventCommon(EventMsgView const &eventView, bool isMetaData)
static void fillDescription(ParameterSetDescription &description)
StreamerInputSource(ParameterSet const &pset, InputSourceDescription const &desc)
bool isBufferLZMA(unsigned char const *inputBuffer, unsigned int inputSize)
void read(EventPrincipal &eventPrincipal) override
edm::propagate_const< TClass * > tc_
void setRun(RunNumber_t r) override
std::unique_ptr< SendJobHeader > deserializeRegistry(InitMsgView const &initView)
static unsigned int uncompressBufferZSTD(unsigned char *inputBuffer, unsigned int inputSize, std::vector< unsigned char > &outputBuffer, unsigned int expectedFullSize, bool hasHeader=true)
edm::propagate_const< std::unique_ptr< SendEvent > > sendEvent_
void deserializeEvent(EventMsgView const &eventView)
static void mergeIntoRegistry(SendJobHeader const &header, ProductRegistry &, bool subsequent)
uint32_t eventMetaDataChecksum(EventMsgView const &eventView) const
void deserializeAndMergeWithRegistry(InitMsgView const &initView, bool subsequent=false)
HLT enums.
static void buildClassCache(SendDescs const &descs)
unsigned int RunNumber_t
void getThinnedProducts(ProductID const &pid, std::vector< WrapperBase const *> &wrappers, std::vector< unsigned int > &keys) const override
WrapperBase const * getIt(ProductID const &id) const override
edm::propagate_const< std::unique_ptr< EventPrincipalHolder > > eventPrincipalHolder_
static unsigned int uncompressBuffer(unsigned char *inputBuffer, unsigned int inputSize, std::vector< unsigned char > &outputBuffer, unsigned int expectedFullSize)
std::vector< unsigned char > dest_
std::vector< edm::propagate_const< std::unique_ptr< EventPrincipalHolder > > > streamToEventPrincipalHolders_
static void declareStreamers(SendDescs const &descs)