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) {}
unsigned long long isize
Definition: MultiFileBlob.h:54

◆ ~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.

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

Referenced by rawBlob().

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 }
void zerr(int)
std::vector< unsigned char > blob
Definition: MultiFileBlob.h:50
unsigned long long isize
Definition: MultiFileBlob.h:54

◆ finalized()

void MultiFileBlob::finalized ( bool  compress)

Definition at line 11 of file MultiFileBlob.cc.

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

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 }
void zerr(int)
std::vector< unsigned char > blob
Definition: MultiFileBlob.h:50
Log< level::Error, false > LogError
unsigned long long isize
Definition: MultiFileBlob.h:54

◆ fullSize()

unsigned long long MultiFileBlob::fullSize ( ) const
inline

Definition at line 39 of file MultiFileBlob.h.

References isize.

39 { return isize; }
unsigned long long isize
Definition: MultiFileBlob.h:54

◆ isCompressed()

bool MultiFileBlob::isCompressed ( ) const
inline

Definition at line 37 of file MultiFileBlob.h.

References compressed.

37 { return compressed; }

◆ rawBlob()

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

Definition at line 45 of file MultiFileBlob.cc.

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

Referenced by size(), and write().

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 }
std::pair< unsigned char const *, unsigned char const * > Range
Definition: MultiFileBlob.h:13
std::vector< unsigned char > blob
Definition: MultiFileBlob.h:50
Log< level::Error, false > LogError
unsigned long long isize
Definition: MultiFileBlob.h:54
Positions positions
Definition: MultiFileBlob.h:52
double b
Definition: hdecay.h:118

◆ 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.

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

Referenced by edmIntegrityCheck.PublishToFileSystem::get().

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 }
std::vector< unsigned char > blob
Definition: MultiFileBlob.h:50
Log< level::Error, false > LogError
unsigned long long isize
Definition: MultiFileBlob.h:54
Positions positions
Definition: MultiFileBlob.h:52

◆ 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.

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

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

61  {
62  Range r = rawBlob(name);
63  return r.second - r.first;
64 }
std::pair< unsigned char const *, unsigned char const * > Range
Definition: MultiFileBlob.h:13
Range rawBlob(const std::string &name) const

◆ write()

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

write to ostream

Definition at line 40 of file MultiFileBlob.cc.

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

Referenced by pkg.AbstractPkg::generate().

40  {
41  Range r = rawBlob(name);
42  os.write((const char*)(r.first), r.second - r.first);
43 }
std::pair< unsigned char const *, unsigned char const * > Range
Definition: MultiFileBlob.h:13
Range rawBlob(const std::string &name) const

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().