49 FDEBUG(6) <<
"StreamSerializer::serializeRegistry" << std::endl;
52 FDEBUG(9) <<
"Product List: " << std::endl;
56 FDEBUG(9) <<
"StreamOutput got product = " <<
selection.first->className() << std::endl;
71 int bres = data_buffer.
rootbuf_.WriteObjectAny((
char *)&sd, tc);
76 throw cms::Exception(
"StreamTranslation",
"Registry serialization failed")
77 <<
"StreamSerializer failed to serialize registry\n";
84 throw cms::Exception(
"StreamTranslation",
"Registry serialization truncated")
85 <<
"StreamSerializer module attempted to serialize\n" 86 <<
"a registry that is to big for the allocated buffers\n";
91 throw cms::Exception(
"StreamTranslation",
"Registry serialization failed")
92 <<
"StreamSerializer module got an unknown error code\n" 93 <<
" while attempting to serialize registry\n";
100 data_buffer.
ptr_ = (
unsigned char *)data_buffer.
rootbuf_.Buffer();
132 unsigned int reserveSize)
const {
134 selectionIDs.push_back(selectorConfig);
163 se.products().push_back(
175 int bres = data_buffer.
rootbuf_.WriteObjectAny(&se,
tc_);
179 throw cms::Exception(
"StreamTranslation",
"Event serialization failed")
180 <<
"StreamSerializer failed to serialize event: " <<
event.id();
187 throw cms::Exception(
"StreamTranslation",
"Event serialization truncated")
188 <<
"StreamSerializer module attempted to serialize an event\n" 189 <<
"that is to big for the allocated buffers: " <<
event.id();
194 throw cms::Exception(
"StreamTranslation",
"Event serialization failed")
195 <<
"StreamSerializer module got an unknown error code\n" 196 <<
" while attempting to serialize event: " <<
event.id();
202 data_buffer.
ptr_ = (
unsigned char *)data_buffer.
rootbuf_.Buffer();
205 if(data_buffer.
ptr_ != data_.ptr_) {
206 std::cerr <<
"ROOT reset the buffer!!!!\n";
207 data_.ptr_ = data_buffer.
ptr_;
217 unsigned int dest_size = 0;
218 switch (compressionAlgo) {
241 dest_size = data_buffer.
rootbuf_.Length();
242 if (data_buffer.
comp_buf_.size() < dest_size + reserveSize)
243 data_buffer.
comp_buf_.resize(dest_size + reserveSize);
245 (
char *)data_buffer.
rootbuf_.Buffer() + dest_size,
266 unsigned int inputSize,
267 std::vector<unsigned char> &outputBuffer,
269 unsigned int reserveSize) {
270 unsigned int resultSize = 0;
273 unsigned long dest_size = (
unsigned long)(
double(inputSize) * 1.002 + 1.0) + 12;
275 if (outputBuffer.size() < dest_size + reserveSize)
276 outputBuffer.resize(dest_size + reserveSize);
279 int ret = compress2(&outputBuffer[reserveSize], &dest_size, inputBuffer, inputSize, compressionLevel);
284 resultSize = dest_size;
286 FDEBUG(1) <<
" original size = " << inputSize <<
" final size = " << dest_size
287 <<
" ratio = " << double(dest_size) / double(inputSize) << std::endl;
290 <<
"Compression Return value: " << ret <<
" Okay = " << Z_OK << std::endl;
298 unsigned int inputSize,
299 std::vector<unsigned char> &outputBuffer,
301 unsigned int reserveSize,
304 unsigned int hdr_size = addHeader ? 4 : 0;
305 unsigned long dest_size = (
unsigned long)(
double(inputSize) * 1.01 + 1.0) + 12;
306 if (outputBuffer.size() < dest_size + reserveSize)
307 outputBuffer.resize(dest_size + reserveSize);
310 uint32_t dict_size_est = inputSize / 4;
311 lzma_stream stream = LZMA_STREAM_INIT;
312 lzma_options_lzma opt_lzma2;
314 {.id = LZMA_FILTER_LZMA2, .options = &opt_lzma2},
315 {.id = LZMA_VLI_UNKNOWN, .options =
nullptr},
317 lzma_ret returnStatus;
319 unsigned char *tgt = &outputBuffer[reserveSize];
325 if (compressionLevel > 9)
326 compressionLevel = 9;
328 lzma_bool presetStatus = lzma_lzma_preset(&opt_lzma2, compressionLevel);
330 throw cms::Exception(
"StreamSerializer",
"compressBufferLZMA") <<
"LZMA preset return status: " << presetStatus;
333 if (LZMA_DICT_SIZE_MIN > dict_size_est) {
334 dict_size_est = LZMA_DICT_SIZE_MIN;
336 if (opt_lzma2.dict_size > dict_size_est) {
340 opt_lzma2.dict_size = dict_size_est;
344 lzma_stream_encoder(&stream,
347 if (returnStatus != LZMA_OK) {
349 <<
"LZMA compression encoder return value: " << returnStatus;
352 stream.next_in = (
const uint8_t *)inputBuffer;
353 stream.avail_in = (size_t)(inputSize);
355 stream.next_out = (uint8_t *)(&tgt[hdr_size]);
356 stream.avail_out = (size_t)(dest_size - hdr_size);
358 returnStatus = lzma_code(&stream, LZMA_FINISH);
360 if (returnStatus != LZMA_STREAM_END) {
363 <<
"LZMA compression return value: " << returnStatus;
375 FDEBUG(1) <<
" LZMA original size = " << inputSize <<
" final size = " << stream.total_out
376 <<
" ratio = " << double(stream.total_out) / double(inputSize) << std::endl;
378 return stream.total_out + hdr_size;
382 unsigned int inputSize,
383 std::vector<unsigned char> &outputBuffer,
385 unsigned int reserveSize,
387 unsigned int hdr_size = addHeader ? 4 : 0;
388 unsigned int resultSize = 0;
391 size_t worst_size = ZSTD_compressBound(inputSize);
393 if (outputBuffer.size() < worst_size + reserveSize + hdr_size)
394 outputBuffer.resize(worst_size + reserveSize + hdr_size);
397 unsigned char *tgt = &outputBuffer[reserveSize];
406 size_t dest_size = ZSTD_compress(
407 (
void *)&outputBuffer[reserveSize + hdr_size], worst_size, (
void *)inputBuffer, inputSize, compressionLevel);
410 if (!ZSTD_isError(dest_size)) {
412 resultSize = (
unsigned int)dest_size + hdr_size;
414 FDEBUG(1) <<
" original size = " << inputSize <<
" final size = " << dest_size
415 <<
" ratio = " << double(dest_size) / double(inputSize) << std::endl;
418 <<
"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)
WrapperBase const * wrapper() const (true)
std::vector< BranchIDList > BranchIDLists
EventAuxiliary const & eventAuxiliary() const
bool isValid() const (true)
ret
prodAgent to be discontinued
Provenance const * provenance() const (true)
ProductProvenance const * productProvenance() const
std::vector< TPRegexp > filters
std::vector< EventSelectionID > EventSelectionIDVector
std::vector< std::pair< BranchDescription const *, EDGetToken > > SelectedProducts
std::vector< BranchID > const & parents() const
std::vector< unsigned char > comp_buf_
unsigned int curr_event_size_
bool getMapped(key_type const &k, value_type &result) const
TypeID unwrappedTypeID() const
unsigned char const * bufferPointer() const
int serializeRegistry(SerializeDataBuffer &data_buffer, const BranchIDLists &branchIDLists, ThinnedAssociationsHelper const &thinnedAssociationsHelper)
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_
int serializeEvent(SerializeDataBuffer &data_buffer, EventForOutput const &event, ParameterSetID const &selectorConfig, StreamerCompressionAlgo compressionAlgo, int compression_level, unsigned int reserveSize) const
static unsigned int compressBuffer(unsigned char *inputBuffer, unsigned int inputSize, std::vector< unsigned char > &outputBuffer, int compressionLevel, unsigned int reserveSize)
TClass * getTClass(const std::type_info &ti)
ParentageID const & parentageID() const
static constexpr unsigned int reserve_size
static ParentageRegistry * instance()
void fillMap(regmap_type &fillme) const
static Registry * instance()
edm::propagate_const< unsigned char * > ptr_
StreamSerializer(SelectedProducts const *selections)
edm::propagate_const< TClass * > tc_