42 int const init_size = 1024 * 1024;
49 xbuf_(TBuffer::kRead, init_size),
51 eventPrincipalHolder_(),
52 adjustEventToNewProductRegistry_(
false),
54 protocolVersion_(0
U) {}
68 FDEBUG(6) <<
"mergeIntoRegistry: Product List: " << std::endl;
74 if (!mergeInfo.empty()) {
75 throw cms::Exception(
"MismatchedInput",
"RootInputFileSequence::previousEvent()") << mergeInfo;
92 std::vector<std::string> missingDictionaries;
93 std::vector<std::string> branchNamesForMissing;
94 std::vector<std::string> producedTypes;
95 for (
auto const&
item : descs) {
98 FDEBUG(6) <<
"declare: " << real_name << std::endl;
99 if (!
loadCap(real_name, missingDictionaries)) {
100 branchNamesForMissing.emplace_back(
item.branchName());
101 producedTypes.emplace_back(
item.className() +
std::string(
" (read from input)"));
104 if (!missingDictionaries.empty()) {
105 std::string context(
"Calling StreamerInputSource::declareStreamers, checking dictionaries for input types");
111 for (
auto const&
item : descs) {
114 FDEBUG(6) <<
"BuildReadData: " << real_name << std::endl;
125 throw cms::Exception(
"StreamTranslation",
"Registry deserialization error")
126 <<
"received wrong message type: expected INIT, got " << initView.
code() <<
"\n";
133 FDEBUG(10) <<
"StreamerInputSource::deserializeRegistry processName = " <<
processName_ << std::endl;
134 FDEBUG(10) <<
"StreamerInputSource::deserializeRegistry protocolVersion_= " <<
protocolVersion_ << std::endl;
145 <<
" chksum from registry data = " << adler32_chksum <<
" from header = " << initView.
adler32_chksum()
146 <<
" host name = " << initView.
hostName() << std::endl;
152 TBuffer::kRead, initView.
descLength(),
const_cast<char*
>((
char const*)initView.
descData()), kFALSE);
154 std::unique_ptr<SendJobHeader>
sd((
SendJobHeader*)xbuf.ReadObjectAny(desc));
156 if (
sd.get() ==
nullptr) {
157 throw cms::Exception(
"StreamTranslation",
"Registry deserialization error")
158 <<
"Could not read the initial product registry list\n";
161 sd->initializeTransients();
177 for (
auto const&
item : psetMap) {
189 throw cms::Exception(
"StreamTranslation",
"Event deserialization error")
190 <<
"received wrong message type: expected EVENT, got " << eventView.
code() <<
"\n";
191 FDEBUG(9) <<
"Decode event: " << eventView.
event() <<
" " << eventView.
run() <<
" " << eventView.
size() <<
" " 198 unsigned long dest_size;
207 <<
" chksum from event = " << adler32_chksum <<
" from header = " << eventView.
adler32_chksum()
208 <<
" host name = " << eventView.
hostName() << std::endl;
210 if (origsize != 78 && origsize != 0) {
230 dest_.resize(dest_size);
231 unsigned char*
pos = (
unsigned char*)&
dest_[0];
232 unsigned char const* from = (
unsigned char const*)eventView.
eventData();
240 xbuf_.SetBuffer(&
dest_[0], dest_size, kFALSE);
251 std::shared_ptr<void> refCoreStreamerGuard(
nullptr, [](
void*) {
259 throw cms::Exception(
"StreamTranslation",
"Event deserialization error")
260 <<
"got a null event from input stream\n";
304 for (
auto& spitem : sps) {
305 FDEBUG(10) <<
"check prodpair" << std::endl;
306 if (spitem.desc() ==
nullptr)
309 <<
" " << spitem.desc()->className() <<
" " << spitem.desc()->productInstanceName() <<
" " 310 << spitem.desc()->branchID() << std::endl;
314 if (spitem.parents()) {
316 if (spitem.prod() !=
nullptr) {
317 FDEBUG(10) <<
"addproduct next " << spitem.branchID() << std::endl;
319 branchDesc, std::unique_ptr<WrapperBase>(const_cast<WrapperBase*>(spitem.prod())), &productProvenance);
320 FDEBUG(10) <<
"addproduct done" << std::endl;
322 FDEBUG(10) <<
"addproduct empty next " << spitem.branchID() << std::endl;
323 eventPrincipal.
putOnRead(branchDesc, std::unique_ptr<WrapperBase>(), &productProvenance);
324 FDEBUG(10) <<
"addproduct empty done" << std::endl;
328 if (spitem.prod() !=
nullptr) {
329 FDEBUG(10) <<
"addproduct next " << spitem.branchID() << std::endl;
331 branchDesc, std::unique_ptr<WrapperBase>(const_cast<WrapperBase*>(spitem.prod())), productProvenance);
332 FDEBUG(10) <<
"addproduct done" << std::endl;
334 FDEBUG(10) <<
"addproduct empty next " << spitem.branchID() << std::endl;
335 eventPrincipal.
putOnRead(branchDesc, std::unique_ptr<WrapperBase>(), productProvenance);
336 FDEBUG(10) <<
"addproduct empty done" << std::endl;
342 FDEBUG(10) <<
"Size = " << eventPrincipal.
size() << std::endl;
354 unsigned int inputSize,
355 std::vector<unsigned char>& outputBuffer,
356 unsigned int expectedFullSize) {
357 unsigned long origSize = expectedFullSize;
358 unsigned long uncompressedSize = expectedFullSize * 1.1;
359 FDEBUG(1) <<
"Uncompress: original size = " << origSize <<
", compressed size = " << inputSize << std::endl;
360 outputBuffer.resize(uncompressedSize);
361 int ret = uncompress(&outputBuffer[0], &uncompressedSize, inputBuffer, inputSize);
365 FDEBUG(10) <<
" original size = " << origSize <<
" final size = " << uncompressedSize << std::endl;
366 if (origSize != uncompressedSize) {
368 throw cms::Exception(
"StreamDeserialization",
"Uncompression error")
369 <<
"mismatch event lengths should be" << origSize <<
" got " << uncompressedSize <<
"\n";
373 throw cms::Exception(
"StreamDeserialization",
"Uncompression error") <<
"Error code = " << ret <<
"\n ";
375 return (
unsigned int)uncompressedSize;
379 if (inputSize >= 4 && !strcmp((
const char*)inputBuffer,
"XZ"))
386 unsigned int inputSize,
387 std::vector<unsigned char>& outputBuffer,
388 unsigned int expectedFullSize,
390 unsigned long origSize = expectedFullSize;
391 unsigned long uncompressedSize = expectedFullSize * 1.1;
392 FDEBUG(1) <<
"Uncompress: original size = " << origSize <<
", compressed size = " << inputSize << std::endl;
393 outputBuffer.resize(uncompressedSize);
395 lzma_stream stream = LZMA_STREAM_INIT;
396 lzma_ret returnStatus;
398 returnStatus = lzma_stream_decoder(&stream, UINT64_MAX, 0
U);
399 if (returnStatus != LZMA_OK) {
400 throw cms::Exception(
"StreamDeserializationLZM",
"LZMA stream decoder error")
401 <<
"Error code = " << returnStatus <<
"\n ";
404 size_t hdrSize = hasHeader ? 4 : 0;
405 stream.next_in = (
const uint8_t*)(inputBuffer + hdrSize);
406 stream.avail_in = (size_t)(inputSize - hdrSize);
407 stream.next_out = (uint8_t*)&outputBuffer[0];
408 stream.avail_out = (size_t)uncompressedSize;
410 returnStatus = lzma_code(&stream, LZMA_FINISH);
411 if (returnStatus != LZMA_STREAM_END) {
413 throw cms::Exception(
"StreamDeserializationLZM",
"LZMA uncompression error")
414 <<
"Error code = " << returnStatus <<
"\n ";
418 uncompressedSize = (
unsigned int)stream.total_out;
420 FDEBUG(10) <<
" original size = " << origSize <<
" final size = " << uncompressedSize << std::endl;
421 if (origSize != uncompressedSize) {
423 throw cms::Exception(
"StreamDeserialization",
"LZMA uncompression error")
424 <<
"mismatch event lengths should be" << origSize <<
" got " << uncompressedSize <<
"\n";
427 return uncompressedSize;
431 if (inputSize >= 4 && !strcmp((
const char*)inputBuffer,
"ZS"))
438 unsigned int inputSize,
439 std::vector<unsigned char>& outputBuffer,
440 unsigned int expectedFullSize,
442 unsigned long uncompressedSize = expectedFullSize * 1.1;
443 FDEBUG(1) <<
"Uncompress: original size = " << expectedFullSize <<
", compressed size = " << inputSize << std::endl;
444 outputBuffer.resize(uncompressedSize);
446 size_t hdrSize = hasHeader ? 4 : 0;
447 size_t ret = ZSTD_decompress(
448 (
void*)&(outputBuffer[0]), uncompressedSize, (
const void*)(inputBuffer + hdrSize), inputSize - hdrSize);
450 if (ZSTD_isError(ret)) {
451 throw cms::Exception(
"StreamDeserializationZSTD",
"ZSTD uncompression error")
452 <<
"Error core " << ret <<
", message:" << ZSTD_getErrorName(ret);
454 return (
unsigned int)
ret;
470 <<
"Run number cannot be modified for this type of Input Source\n" 471 <<
"Contact a Storage Manager Developer\n";
483 unsigned int&
index)
const {
488 std::vector<WrapperBase const*>& wrappers,
489 std::vector<unsigned int>&
keys)
const {
void throwMissingDictionariesException(std::vector< std::string > &missingDictionaries, std::string const &context)
WrapperBase const * getThinnedProduct(ProductID const &pid, unsigned int &key) const override
static Timestamp invalidTimestamp()
const uint8 * eventData() const
const uint8 * descData() const
std::string hostName() const
ret
prodAgent to be discontinued
std::vector< BranchDescription > SendDescs
void doBuildRealData(const std::string &name)
bool registerProcessHistory(ProcessHistory const &processHistory)
void setRefCoreStreamer(bool resetAll=false)
void updateFromPrimaryInput(ThinnedAssociationsHelper const &)
std::vector< EventSelectionID > EventSelectionIDVector
void getThinnedProducts(ProductID const &pid, std::vector< WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys) const override
uint32 adler32_chksum() const
uint32 eventLength() const
uint32 adler32_chksum() const
std::vector< BranchListIndex > BranchListIndexes
StreamID streamID() const
std::string hostName() const
std::string merge(ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
bool insertMapped(value_type const &v, bool forceUpdate=false)
void setProcessHistoryID(ProcessHistoryID const &phid)
std::vector< StreamedProduct > SendProds
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
uint32 protocolVersion() const
unsigned int value() const
std::string wrappedClassName(std::string const &iFullName)
void putOnRead(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp, ProductProvenance const *productProvenance) const
bool loadCap(const std::string &name, std::vector< std::string > &missingDictionaries)
TClass * getTClass(const std::type_info &ti)
uint32 origDataSize() const
unsigned int transitionIndex() const
bool updateFromInput(BranchIDLists const &bidlists)
void fillEventPrincipal(EventAuxiliary const &aux, ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=0)
bool adjustToNewProductRegistry(ProductRegistry const ®)
std::string processName() const
void updateFromInput(ProductList const &other)
void setProcessHistoryID(ProcessHistoryID const &phid)
void adjustIndexesAfterProductRegistryAddition()
uint32 descLength() const
WrapperBase const * getIt(ProductID const &pid) const override
static Registry * instance()