50 return serializeRegistry(data_buffer, branchIDLists, thinnedAssociationsHelper, psetMap);
57 FDEBUG(6) <<
"StreamSerializer::serializeRegistry" << std::endl;
60 FDEBUG(9) <<
"Product List: " << std::endl;
64 FDEBUG(9) <<
"StreamOutput got product = " <<
selection.first->className() << std::endl;
76 int bres = data_buffer.
rootbuf_.WriteObjectAny((
char *)&sd, tc);
81 throw cms::Exception(
"StreamTranslation",
"Registry serialization failed")
82 <<
"StreamSerializer failed to serialize registry\n";
89 throw cms::Exception(
"StreamTranslation",
"Registry serialization truncated")
90 <<
"StreamSerializer module attempted to serialize\n" 91 <<
"a registry that is to big for the allocated buffers\n";
96 throw cms::Exception(
"StreamTranslation",
"Registry serialization failed")
97 <<
"StreamSerializer module got an unknown error code\n" 98 <<
" while attempting to serialize registry\n";
105 data_buffer.
ptr_ = (
unsigned char *)data_buffer.
rootbuf_.Buffer();
137 unsigned int reserveSize)
const {
139 selectionIDs.push_back(selectorConfig);
140 SendEvent se(
event.eventAuxiliary(),
event.processHistory(), selectionIDs,
event.branchListIndexes());
164 if (
result.provenance()->productProvenance()) {
168 se.products().push_back(
180 int bres = data_buffer.
rootbuf_.WriteObjectAny(&se,
tc_);
184 throw cms::Exception(
"StreamTranslation",
"Event serialization failed")
185 <<
"StreamSerializer failed to serialize event: " <<
event.id();
192 throw cms::Exception(
"StreamTranslation",
"Event serialization truncated")
193 <<
"StreamSerializer module attempted to serialize an event\n" 194 <<
"that is to big for the allocated buffers: " <<
event.id();
199 throw cms::Exception(
"StreamTranslation",
"Event serialization failed")
200 <<
"StreamSerializer module got an unknown error code\n" 201 <<
" while attempting to serialize event: " <<
event.id();
207 data_buffer.
ptr_ = (
unsigned char *)data_buffer.
rootbuf_.Buffer();
210 if(data_buffer.
ptr_ != data_.ptr_) {
211 std::cerr <<
"ROOT reset the buffer!!!!\n";
212 data_.ptr_ = data_buffer.
ptr_;
222 unsigned int dest_size = 0;
223 switch (compressionAlgo) {
246 dest_size = data_buffer.
rootbuf_.Length();
247 if (data_buffer.
comp_buf_.size() < dest_size + reserveSize)
248 data_buffer.
comp_buf_.resize(dest_size + reserveSize);
250 (
char *)data_buffer.
rootbuf_.Buffer() + dest_size,
271 unsigned int inputSize,
272 std::vector<unsigned char> &outputBuffer,
274 unsigned int reserveSize) {
275 unsigned int resultSize = 0;
278 unsigned long dest_size = (
unsigned long)(
double(inputSize) * 1.002 + 1.0) + 12;
280 if (outputBuffer.size() < dest_size + reserveSize)
281 outputBuffer.resize(dest_size + reserveSize);
284 int ret = compress2(&outputBuffer[reserveSize], &dest_size, inputBuffer, inputSize,
compressionLevel);
289 resultSize = dest_size;
291 FDEBUG(1) <<
" original size = " << inputSize <<
" final size = " << dest_size
292 <<
" ratio = " << double(dest_size) / double(inputSize) << std::endl;
295 <<
"Compression Return value: " <<
ret <<
" Okay = " << Z_OK << std::endl;
303 unsigned int inputSize,
304 std::vector<unsigned char> &outputBuffer,
306 unsigned int reserveSize,
309 unsigned int hdr_size = addHeader ? 4 : 0;
310 unsigned long dest_size = (
unsigned long)(
double(inputSize) * 1.01 + 1.0) + 12;
311 if (outputBuffer.size() < dest_size + reserveSize)
312 outputBuffer.resize(dest_size + reserveSize);
315 uint32_t dict_size_est = inputSize / 4;
316 lzma_stream
stream = LZMA_STREAM_INIT;
317 lzma_options_lzma opt_lzma2;
319 {.id = LZMA_FILTER_LZMA2, .options = &opt_lzma2},
320 {.id = LZMA_VLI_UNKNOWN, .options =
nullptr},
322 lzma_ret returnStatus;
324 unsigned char *tgt = &outputBuffer[reserveSize];
335 throw cms::Exception(
"StreamSerializer",
"compressBufferLZMA") <<
"LZMA preset return status: " << presetStatus;
338 if (LZMA_DICT_SIZE_MIN > dict_size_est) {
339 dict_size_est = LZMA_DICT_SIZE_MIN;
341 if (opt_lzma2.dict_size > dict_size_est) {
345 opt_lzma2.dict_size = dict_size_est;
349 lzma_stream_encoder(&
stream,
352 if (returnStatus != LZMA_OK) {
354 <<
"LZMA compression encoder return value: " << returnStatus;
357 stream.next_in = (
const uint8_t *)inputBuffer;
358 stream.avail_in = (size_t)(inputSize);
360 stream.next_out = (uint8_t *)(&tgt[hdr_size]);
361 stream.avail_out = (size_t)(dest_size - hdr_size);
363 returnStatus = lzma_code(&
stream, LZMA_FINISH);
365 if (returnStatus != LZMA_STREAM_END) {
368 <<
"LZMA compression return value: " << returnStatus;
380 FDEBUG(1) <<
" LZMA original size = " << inputSize <<
" final size = " <<
stream.total_out
381 <<
" ratio = " << double(
stream.total_out) / double(inputSize) << std::endl;
383 return stream.total_out + hdr_size;
387 unsigned int inputSize,
388 std::vector<unsigned char> &outputBuffer,
390 unsigned int reserveSize,
392 unsigned int hdr_size = addHeader ? 4 : 0;
393 unsigned int resultSize = 0;
396 size_t worst_size = ZSTD_compressBound(inputSize);
398 if (outputBuffer.size() < worst_size + reserveSize + hdr_size)
399 outputBuffer.resize(worst_size + reserveSize + hdr_size);
402 unsigned char *tgt = &outputBuffer[reserveSize];
411 size_t dest_size = ZSTD_compress(
412 (
void *)&outputBuffer[reserveSize + hdr_size], worst_size, (
void *)inputBuffer, inputSize,
compressionLevel);
415 if (!ZSTD_isError(dest_size)) {
417 resultSize = (
unsigned int)dest_size + hdr_size;
419 FDEBUG(1) <<
" original size = " << inputSize <<
" final size = " << dest_size
420 <<
" ratio = " << double(dest_size) / double(inputSize) << std::endl;
423 <<
"Compression (ZSTD) Error: " << ZSTD_getErrorName(dest_size);
static unsigned int compressBufferZSTD(unsigned char *inputBuffer, unsigned int inputSize, std::vector< unsigned char > &outputBuffer, int compressionLevel, unsigned int reserveSize, bool addHeader=true)
std::vector< BranchIDList > BranchIDLists
ret
prodAgent to be discontinued
std::vector< BranchID > const & parents() const
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
TClass * getTClass(const std::type_info &ti)
std::vector< TPRegexp > filters
std::vector< EventSelectionID > EventSelectionIDVector
std::vector< std::pair< BranchDescription const *, EDGetToken > > SelectedProducts
bool getMapped(key_type const &k, value_type &result) const
std::vector< unsigned char > comp_buf_
unsigned int curr_event_size_
int serializeEvent(SerializeDataBuffer &data_buffer, EventForOutput const &event, ParameterSetID const &selectorConfig, StreamerCompressionAlgo compressionAlgo, int compression_level, unsigned int reserveSize) const
void fillMap(regmap_type &fillme) const
int serializeRegistry(SerializeDataBuffer &data_buffer, const BranchIDLists &branchIDLists, ThinnedAssociationsHelper const &thinnedAssociationsHelper)
unsigned char const * bufferPointer() const
unsigned int curr_space_used_
static unsigned int compressBufferLZMA(unsigned char *inputBuffer, unsigned int inputSize, std::vector< unsigned char > &outputBuffer, int compressionLevel, unsigned int reserveSize, bool addHeader=true)
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
SelectedProducts const * selections_
static unsigned int compressBuffer(unsigned char *inputBuffer, unsigned int inputSize, std::vector< unsigned char > &outputBuffer, int compressionLevel, unsigned int reserveSize)
static constexpr unsigned int reserve_size
static ParentageRegistry * instance()
static Registry * instance()
edm::propagate_const< unsigned char * > ptr_
StreamSerializer(SelectedProducts const *selections)
edm::propagate_const< TClass * > tc_