CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
cond::IOVImportIterator Class Reference

#include <IOVEditor.h>

Public Member Functions

bool hasMoreElements ()
 
size_t importAll ()
 
size_t importMoreElements ()
 
 IOVImportIterator (boost::shared_ptr< cond::IOVProxyData > &destIov)
 
void setUp (cond::IOVProxy &sourceIov, cond::Time_t since, cond::Time_t till, bool outOfOrder, size_t bulkSize=1)
 
void setUp (cond::DbSession &sourceSess, const std::string &sourceIovToken, cond::Time_t since, cond::Time_t till, bool outOfOrder, size_t bulkSize=1)
 
void setUp (cond::IOVProxy &sourceIov, size_t bulkSize=1)
 
void setUp (cond::DbSession &sourceSess, const std::string &sourceIovToken, size_t bulkSize=1)
 
virtual ~IOVImportIterator ()
 

Private Attributes

size_t m_bulkSize
 
IOVSequence::const_iterator m_cursor
 
boost::shared_ptr
< cond::IOVProxyData
m_destIov
 
cond::Time_t m_lastSince
 
cond::IOVProxy m_sourceIov
 
IOVSequence::const_iterator m_till
 

Detailed Description

Definition at line 26 of file IOVEditor.h.

Constructor & Destructor Documentation

cond::IOVImportIterator::IOVImportIterator ( boost::shared_ptr< cond::IOVProxyData > &  destIov)
explicit

Definition at line 50 of file IOVEditor.cc.

50  :
51  m_sourceIov(),
52  m_destIov( destIov ),
53  m_lastSince( 0 ),
54  m_bulkSize( 0 ),
55  m_cursor(),
56  m_till()
57  {
58  }
cond::IOVProxy m_sourceIov
Definition: IOVEditor.h:48
IOVSequence::const_iterator m_cursor
Definition: IOVEditor.h:52
IOVSequence::const_iterator m_till
Definition: IOVEditor.h:53
cond::Time_t m_lastSince
Definition: IOVEditor.h:50
boost::shared_ptr< cond::IOVProxyData > m_destIov
Definition: IOVEditor.h:49
cond::IOVImportIterator::~IOVImportIterator ( )
virtual

Definition at line 60 of file IOVEditor.cc.

60  {
61  }

Member Function Documentation

bool cond::IOVImportIterator::hasMoreElements ( )

Definition at line 141 of file IOVEditor.cc.

References m_cursor, and m_till.

Referenced by importAll().

141  {
142  return m_cursor != m_till;
143  }
IOVSequence::const_iterator m_cursor
Definition: IOVEditor.h:52
IOVSequence::const_iterator m_till
Definition: IOVEditor.h:53
size_t cond::IOVImportIterator::importAll ( )

Definition at line 160 of file IOVEditor.cc.

References hasMoreElements(), importMoreElements(), and pileupDistInMC::total.

160  {
161  size_t total = 0;
162  while( hasMoreElements() ){
163  total += importMoreElements();
164  }
165  return total;
166  }
size_t cond::IOVImportIterator::importMoreElements ( )

Definition at line 145 of file IOVEditor.cc.

References ora::Container::className(), cont, ora::OId::containerId(), cond::IOVProxy::db(), ora::OId::fromString(), i, m_bulkSize, m_cursor, m_destIov, m_lastSince, m_sourceIov, m_till, cond::updateIOV(), and cond::userInfo().

Referenced by importAll().

145  {
146  size_t i = 0;
147  boost::shared_ptr<IOVSequence>& diov = m_destIov->data;
148  for( ; i<m_bulkSize && m_cursor != m_till; ++i, ++m_cursor, m_lastSince=m_cursor->sinceTime() ){
149  std::string newPtoken = m_destIov->dbSession.importObject( m_sourceIov.db(),m_cursor->token());
150  ora::OId poid;
151  poid.fromString( newPtoken );
152  ora::Container cont = m_destIov->dbSession.storage().containerHandle( poid.containerId() );
153  diov->add(m_lastSince, newPtoken, cont.className());
154  }
155  if( m_cursor == m_till ) diov->stamp(cond::userInfo(),false);
156  updateIOV( m_destIov->dbSession, diov, m_destIov->token );
157  return i;
158  }
int i
Definition: DBlmapReader.cc:9
void updateIOV(cond::DbSession &dbSess, const boost::shared_ptr< IOVSequence > &data, const std::string &token)
Definition: IOVEditor.cc:38
DbSession & db() const
Definition: IOVProxy.cc:311
Definition: OId.h:8
cond::IOVProxy m_sourceIov
Definition: IOVEditor.h:48
IOVSequence::const_iterator m_cursor
Definition: IOVEditor.h:52
const std::string & className()
Definition: Container.cc:75
int containerId() const
Definition: OId.cc:50
IOVSequence::const_iterator m_till
Definition: IOVEditor.h:53
cond::Time_t m_lastSince
Definition: IOVEditor.h:50
int cont
std::string userInfo()
Definition: IOVInfo.cc:9
bool fromString(const std::string &s)
Definition: OId.cc:64
boost::shared_ptr< cond::IOVProxyData > m_destIov
Definition: IOVEditor.h:49
void cond::IOVImportIterator::setUp ( cond::IOVProxy sourceIov,
cond::Time_t  since,
cond::Time_t  till,
bool  outOfOrder,
size_t  bulkSize = 1 
)

Definition at line 63 of file IOVEditor.cc.

References ora::QueryableVector< Tp >::back(), ora::QueryableVector< Tp >::empty(), ora::QueryableVector< Tp >::end(), edm::hlt::Exception, cond::IOVSequence::exist(), cond::IOVSequence::find(), cond::IOVSequence::firstSince(), cond::IOVProxy::iov(), cond::IOVSequence::iovs(), m_bulkSize, m_cursor, m_destIov, m_lastSince, m_sourceIov, m_till, and max().

Referenced by setUp().

67  {
68  m_sourceIov = sourceIov;
69  const IOVSequence& siov = m_sourceIov.iov();
70  cond::Time_t dsince = std::max(since, siov.firstSince());
71  IOVSequence::const_iterator ifirstTill = siov.find(dsince);
72  IOVSequence::const_iterator isecondTill = siov.find(till);
73  if( isecondTill != siov.iovs().end() ) isecondTill++;
74 
75  if (ifirstTill==isecondTill)
76  throw cond::Exception("IOVImportIterator::setUp Error: empty input range");
77 
78  IOVSequence& diov = *m_destIov->data;
79  if ( diov.iovs().empty()) ; // do not waist time
80  else if (outOfOrder) {
81  for( IOVSequence::const_iterator it=ifirstTill;
82  it!=isecondTill; ++it)
83  if (diov.exist(it->sinceTime()))
84  throw cond::Exception("IOVImportIterator::setUp Error: since time already exists");
85  } else if (dsince <= diov.iovs().back().sinceTime()) {
86  std::ostringstream errStr;
87  errStr << "IOVImportIterator::setUp Error: trying to append a since time " << dsince
88  << " which is not larger than last since " << diov.iovs().back().sinceTime();
89  throw cond::Exception(errStr.str());
90  }
91 
92  m_lastSince = dsince;
93  m_cursor = ifirstTill;
94  m_till = isecondTill;
95  m_bulkSize = bulkSize;
96  }
Container::const_iterator const_iterator
Definition: IOVSequence.h:28
cond::IOVProxy m_sourceIov
Definition: IOVEditor.h:48
IOVSequence::const_iterator m_cursor
Definition: IOVEditor.h:52
unsigned long long Time_t
Definition: Time.h:16
const T & max(const T &a, const T &b)
IOVSequence const & iov() const
Definition: IOVProxy.cc:276
IOVSequence::const_iterator m_till
Definition: IOVEditor.h:53
cond::Time_t m_lastSince
Definition: IOVEditor.h:50
boost::shared_ptr< cond::IOVProxyData > m_destIov
Definition: IOVEditor.h:49
void cond::IOVImportIterator::setUp ( cond::DbSession sourceSess,
const std::string &  sourceIovToken,
cond::Time_t  since,
cond::Time_t  till,
bool  outOfOrder,
size_t  bulkSize = 1 
)

Definition at line 98 of file IOVEditor.cc.

References setUp().

103  {
104  IOVProxy sourceIov( sourceSess, sourceIovToken );
105  setUp( sourceIov, since, till, outOfOrder, bulkSize );
106  }
void setUp(cond::IOVProxy &sourceIov, cond::Time_t since, cond::Time_t till, bool outOfOrder, size_t bulkSize=1)
Definition: IOVEditor.cc:63
void cond::IOVImportIterator::setUp ( cond::IOVProxy sourceIov,
size_t  bulkSize = 1 
)

Definition at line 108 of file IOVEditor.cc.

References ora::QueryableVector< Tp >::back(), ora::QueryableVector< Tp >::begin(), ora::QueryableVector< Tp >::empty(), ora::QueryableVector< Tp >::end(), edm::hlt::Exception, cond::IOVSequence::firstSince(), cond::IOVProxy::iov(), cond::IOVSequence::iovs(), m_bulkSize, m_cursor, m_destIov, m_lastSince, m_sourceIov, and m_till.

109  {
110 
111  m_sourceIov = sourceIov;
112  const IOVSequence& siov = m_sourceIov.iov();
113  cond::Time_t dsince = siov.firstSince();
114 
115  IOVSequence::const_iterator ifirstTill = siov.iovs().begin();
116  IOVSequence::const_iterator isecondTill = siov.iovs().end();
117 
118  IOVSequence& diov = *m_destIov->data;
119  if (!diov.iovs().empty()) { // do not waist time
120  if (dsince <= diov.iovs().back().sinceTime()) {
121  std::ostringstream errStr;
122  errStr << "IOVImportIterator::setUp Error: trying to append a since time " << dsince
123  << " which is not larger than last since " << diov.iovs().back().sinceTime();
124  throw cond::Exception(errStr.str());
125  }
126  }
127 
128  m_lastSince = dsince;
129  m_cursor = ifirstTill;
130  m_till = isecondTill;
131  m_bulkSize = bulkSize;
132  }
cond::Time_t firstSince() const
Definition: IOVSequence.h:62
Container::const_iterator const_iterator
Definition: IOVSequence.h:28
cond::IOVProxy m_sourceIov
Definition: IOVEditor.h:48
IOVSequence::const_iterator m_cursor
Definition: IOVEditor.h:52
unsigned long long Time_t
Definition: Time.h:16
IOVSequence const & iov() const
Definition: IOVProxy.cc:276
IOVSequence::const_iterator m_till
Definition: IOVEditor.h:53
cond::Time_t m_lastSince
Definition: IOVEditor.h:50
boost::shared_ptr< cond::IOVProxyData > m_destIov
Definition: IOVEditor.h:49
void cond::IOVImportIterator::setUp ( cond::DbSession sourceSess,
const std::string &  sourceIovToken,
size_t  bulkSize = 1 
)

Definition at line 134 of file IOVEditor.cc.

References setUp().

136  {
137  IOVProxy sourceIov( sourceSess, sourceIovToken );
138  setUp( sourceIov, bulkSize );
139  }
void setUp(cond::IOVProxy &sourceIov, cond::Time_t since, cond::Time_t till, bool outOfOrder, size_t bulkSize=1)
Definition: IOVEditor.cc:63

Member Data Documentation

size_t cond::IOVImportIterator::m_bulkSize
private

Definition at line 51 of file IOVEditor.h.

Referenced by importMoreElements(), and setUp().

IOVSequence::const_iterator cond::IOVImportIterator::m_cursor
private

Definition at line 52 of file IOVEditor.h.

Referenced by hasMoreElements(), importMoreElements(), and setUp().

boost::shared_ptr<cond::IOVProxyData> cond::IOVImportIterator::m_destIov
private

Definition at line 49 of file IOVEditor.h.

Referenced by importMoreElements(), and setUp().

cond::Time_t cond::IOVImportIterator::m_lastSince
private

Definition at line 50 of file IOVEditor.h.

Referenced by importMoreElements(), and setUp().

cond::IOVProxy cond::IOVImportIterator::m_sourceIov
private

Definition at line 48 of file IOVEditor.h.

Referenced by importMoreElements(), and setUp().

IOVSequence::const_iterator cond::IOVImportIterator::m_till
private

Definition at line 53 of file IOVEditor.h.

Referenced by hasMoreElements(), importMoreElements(), and setUp().