CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends
MultiFileBlob Class Reference

#include <MultiFileBlob.h>

Public Types

typedef std::pair< unsigned char const *, unsigned char const * > Range
 

Public Member Functions

void finalized (bool compress)
 
unsigned long long fullSize () const
 
bool isCompressed () const
 
 MultiFileBlob ()
 
Range rawBlob (const std::string &name) const
 
void read (const std::string &name, std::istream &is)
 read from real file give it name name More...
 
unsigned long long size (const std::string &name) const
 
void write (const std::string &name, std::ostream &os) const
 write to ostream More...
 
 ~MultiFileBlob ()
 

Private Types

typedef std::map< std::string, unsigned long long > Positions
 

Private Member Functions

void expand ()
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

std::vector< unsigned char > blob
 
bool compressed
 
bool expanded
 
unsigned long long isize
 
Positions positions
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

Detailed Description

Definition at line 11 of file MultiFileBlob.h.

Member Typedef Documentation

◆ Positions

typedef std::map<std::string, unsigned long long> MultiFileBlob::Positions
private

Definition at line 51 of file MultiFileBlob.h.

◆ Range

typedef std::pair<unsigned char const*, unsigned char const*> MultiFileBlob::Range

Definition at line 13 of file MultiFileBlob.h.

Constructor & Destructor Documentation

◆ MultiFileBlob()

MultiFileBlob::MultiFileBlob ( )

Definition at line 7 of file MultiFileBlob.cc.

7 : compressed(false), isize(0), expanded(false) {}

◆ ~MultiFileBlob()

MultiFileBlob::~MultiFileBlob ( )

Definition at line 9 of file MultiFileBlob.cc.

9 {}

Member Function Documentation

◆ expand()

void MultiFileBlob::expand ( )
private

Definition at line 66 of file MultiFileBlob.cc.

66  {
67  if (expanded)
68  return;
69  if (!compressed) {
70  expanded = true;
71  return;
72  }
73  std::vector<unsigned char> out(isize);
74  uLongf destLen = out.size();
75  int zerr = uncompress(&out.front(), &destLen, &blob.front(), blob.size());
76  if (zerr != 0 || out.size() != destLen)
77  edm::LogError("FileBlob") << "uncompressing error " << zerr << " original size was " << isize << " new size is "
78  << destLen;
79  blob.swap(out);
80  expanded = true;
81 }

References blob, compressed, expanded, isize, MillePedeFileConverter_cfg::out, and spu::zerr().

◆ finalized()

void MultiFileBlob::finalized ( bool  compress)

Definition at line 11 of file MultiFileBlob.cc.

11  {
12  if (!compress)
13  return;
14  if (0 == isize)
15  return;
16  compressed = true;
17  expanded = false;
18  std::vector<unsigned char> out(isize);
19  uLongf destLen = compressBound(isize);
20  int zerr = compress2(&out.front(), &destLen, &blob.front(), isize, 9);
21  if (zerr != 0)
22  edm::LogError("MultiFileBlob") << "Compression error " << zerr;
23  out.resize(destLen);
24  blob.swap(out);
25 }

References blob, compressed, expanded, isize, MillePedeFileConverter_cfg::out, and spu::zerr().

◆ fullSize()

unsigned long long MultiFileBlob::fullSize ( ) const
inline

Definition at line 39 of file MultiFileBlob.h.

39 { return isize; }

References isize.

◆ isCompressed()

bool MultiFileBlob::isCompressed ( ) const
inline

Definition at line 37 of file MultiFileBlob.h.

37 { return compressed; }

References compressed.

◆ rawBlob()

MultiFileBlob::Range MultiFileBlob::rawBlob ( const std::string &  name) const

Definition at line 45 of file MultiFileBlob.cc.

45  {
46  const_cast<MultiFileBlob*>(this)->expand();
47  Positions::const_iterator pos = positions.find(name);
48  if (pos == positions.end()) {
49  edm::LogError("MultiFileBlob:") << name << "not in this object";
50  return Range(nullptr, nullptr);
51  }
52  unsigned long long b = (*pos).second;
53  unsigned long long e = isize;
54  pos++;
55  if (pos != positions.end())
56  e = (*pos).second;
57 
58  return Range(&blob[b], &blob[e]);
59 }

References b, blob, MillePedeFileConverter_cfg::e, isize, Skims_PA_cff::name, and positions.

Referenced by size(), and write().

◆ read()

void MultiFileBlob::read ( const std::string &  name,
std::istream &  is 
)

read from real file give it name name

write name to real file read from istream

Definition at line 27 of file MultiFileBlob.cc.

27  {
28  Positions::const_iterator pos = positions.find(name);
29  if (pos != positions.end()) {
30  edm::LogError("MultiFileBlob:") << name << "already in this object";
31  return;
32  }
33  positions[name] = isize;
34  char c;
35  while (is.get(c))
36  blob.push_back((unsigned char)c);
37  isize = blob.size();
38 }

References blob, c, isize, Skims_PA_cff::name, and positions.

Referenced by edmIntegrityCheck.PublishToFileSystem::get().

◆ serialize()

template<class Archive >
void MultiFileBlob::serialize ( Archive &  ar,
const unsigned int  version 
)
private

◆ size()

unsigned long long MultiFileBlob::size ( const std::string &  name) const

Definition at line 61 of file MultiFileBlob.cc.

61  {
62  Range r = rawBlob(name);
63  return r.second - r.first;
64 }

References Skims_PA_cff::name, alignCSCRings::r, and rawBlob().

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

◆ write()

void MultiFileBlob::write ( const std::string &  name,
std::ostream &  os 
) const

write to ostream

Definition at line 40 of file MultiFileBlob.cc.

40  {
41  Range r = rawBlob(name);
42  os.write((const char*)(r.first), r.second - r.first);
43 }

References Skims_PA_cff::name, alignCSCRings::r, and rawBlob().

Referenced by pkg.AbstractPkg::generate().

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 57 of file MultiFileBlob.h.

◆ cond::serialization::access

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 57 of file MultiFileBlob.h.

Member Data Documentation

◆ blob

std::vector<unsigned char> MultiFileBlob::blob
private

Definition at line 50 of file MultiFileBlob.h.

Referenced by expand(), finalized(), rawBlob(), and read().

◆ compressed

bool MultiFileBlob::compressed
private

Definition at line 53 of file MultiFileBlob.h.

Referenced by expand(), finalized(), and isCompressed().

◆ expanded

bool MultiFileBlob::expanded
private

Definition at line 55 of file MultiFileBlob.h.

Referenced by expand(), and finalized().

◆ isize

unsigned long long MultiFileBlob::isize
private

Definition at line 54 of file MultiFileBlob.h.

Referenced by expand(), finalized(), fullSize(), rawBlob(), and read().

◆ positions

Positions MultiFileBlob::positions
private

Definition at line 52 of file MultiFileBlob.h.

Referenced by rawBlob(), and read().

MultiFileBlob::expanded
bool expanded
Definition: MultiFileBlob.h:55
pos
Definition: PixelAliasList.h:18
b
double b
Definition: hdecay.h:118
MultiFileBlob::isize
unsigned long long isize
Definition: MultiFileBlob.h:54
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
MultiFileBlob::compressed
bool compressed
Definition: MultiFileBlob.h:53
alignCSCRings.r
r
Definition: alignCSCRings.py:93
MultiFileBlob::positions
Positions positions
Definition: MultiFileBlob.h:52
MultiFileBlob::rawBlob
Range rawBlob(const std::string &name) const
Definition: MultiFileBlob.cc:45
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
MultiFileBlob::Range
std::pair< unsigned char const *, unsigned char const * > Range
Definition: MultiFileBlob.h:13
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
MultiFileBlob::blob
std::vector< unsigned char > blob
Definition: MultiFileBlob.h:50
spu::zerr
void zerr(int)
Definition: SherpackUtilities.cc:129
edm::Log
Definition: MessageLogger.h:70
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37