#include <IOVEditor.h>
Public Member Functions | |
unsigned int | append (cond::Time_t sinceTime, const std::string &payloadToken) |
void | bulkAppend (std::vector< std::pair< cond::Time_t, std::string > > &values) |
Bulk append of iov chunck. | |
void | bulkAppend (std::vector< cond::IOVElement > &values) |
void | create (cond::TimeType timetype, cond::Time_t lastTill) |
void | create (cond::TimeType timetype) |
void | deleteEntries (bool withPayload=false) |
void | editMetadata (std::string const &metadata, bool append=false) |
edit metadata | |
Time_t | firstSince () const |
unsigned int | freeInsert (cond::Time_t sinceTime, const std::string &payloadToken) |
insert a payload with known since in any position | |
void | import (const std::string &sourceIOVtoken) |
unsigned int | insert (cond::Time_t tillTime, const std::string &payloadToken) |
Assign a payload with till time. Returns the payload index in the iov sequence. | |
IOVSequence & | iov () |
IOVEditor (cond::DbSession &dbSess, const std::string &token) | |
IOVEditor (cond::DbSession &dbSess) | |
Time_t | lastTill () const |
void | setScope (cond::IOVSequence::ScopeType scope) |
set the scope | |
void | stamp (std::string const &icomment, bool append=false) |
TimeType | timetype () const |
std::string const & | token () const |
Returns the token of the iov sequence associated with this editor. | |
unsigned int | truncate (bool withPayload=false) |
void | updateClosure (cond::Time_t newtillTime) |
Update the closure of the iov sequence. | |
~IOVEditor () | |
Destructor. | |
Private Member Functions | |
void | debugInfo (std::ostream &co) const |
void | flushInserts () |
void | flushUpdates () |
void | init () |
void | loadData (const std::string &token) |
void | reportError (std::string message, cond::Time_t time) const |
void | reportError (std::string message) const |
bool | validTime (cond::Time_t time) const |
bool | validTime (cond::Time_t time, cond::TimeType timetype) const |
Private Attributes | |
cond::DbSession | m_dbSess |
boost::shared_ptr < cond::IOVSequence > | m_iov |
bool | m_isActive |
std::string | m_token |
Definition at line 26 of file IOVEditor.h.
IOVEditor::IOVEditor | ( | cond::DbSession & | dbSess | ) | [explicit] |
Definition at line 12 of file IOVEditor.cc.
: m_dbSess(dbSess), m_token(""), m_isActive(false){ }
IOVEditor::IOVEditor | ( | cond::DbSession & | dbSess, |
const std::string & | token | ||
) |
Definition at line 18 of file IOVEditor.cc.
: m_dbSess(dbSess), m_token(token), m_isActive(false){ }
IOVEditor::~IOVEditor | ( | ) |
unsigned int IOVEditor::append | ( | cond::Time_t | sinceTime, |
const std::string & | payloadToken | ||
) |
Append a payload with known since time. The previous last payload's till time will be adjusted to the new payload since time. Returns the payload index in the iov sequence
Definition at line 263 of file IOVEditor.cc.
References cond::DbSession::classNameForItem(), flushUpdates(), init(), lastTill(), m_dbSess, m_iov, m_isActive, m_token, reportError(), runTheMatrix::ret, timetype(), cond::timeTypeSpecs, and validTime().
Referenced by cond::service::PoolDBOutputService::appendIOV(), cond::service::PoolDBOutputService::createNewIOV(), and cond::AlignSplitIOV::execute().
{ if( m_token.empty() ) { reportError("cond::IOVEditor::appendIOV cannot append to non-existing IOV index"); } if(!m_isActive) { this->init(); } if(!validTime(sinceTime)) reportError("cond::IOVEditor::append time not in global range",sinceTime); if( !m_iov->iovs().empty() ){ //range check in case cond::Time_t lastValidSince=m_iov->iovs().back().sinceTime(); if( sinceTime<= lastValidSince){ reportError("IOVEditor::append Error: since time out of range: below last since",sinceTime); } } // does it make sense? (in case of mixed till and since insertions...) if (lastTill()<=sinceTime) m_iov->updateLastTill( timeTypeSpecs[timetype()].endValue ); std::string payloadClassName = m_dbSess.classNameForItem( payloadToken ); unsigned int ret = m_iov->add(sinceTime,payloadToken, payloadClassName ); flushUpdates(); return ret; }
void IOVEditor::bulkAppend | ( | std::vector< cond::IOVElement > & | values | ) |
Definition at line 210 of file IOVEditor.cc.
References cond::DbSession::classNameForItem(), firstTime, flushUpdates(), init(), lastTill(), m_dbSess, m_iov, m_isActive, reportError(), and validTime().
{ if (values.empty()) return; if(!m_isActive) this->init(); cond::Time_t firstTime = values.front().sinceTime(); cond::Time_t lastTime = values.back().sinceTime(); if(!validTime(firstTime)) reportError("cond::IOVEditor::bulkInsert first time not in global range",firstTime); if(!validTime(lastTime)) reportError("cond::IOVEditor::bulkInsert last time not in global range",lastTime); if(lastTime>=lastTill() || ( !m_iov->iovs().empty() && firstTime<=m_iov->iovs().back().sinceTime()) ) reportError("cond::IOVEditor::bulkInsert IOV not in range",firstTime); for(std::vector< cond::IOVElement >::const_iterator it=values.begin(); it!=values.end(); ++it){ std::string payloadClassName = m_dbSess.classNameForItem( it->token() ); m_iov->add(it->sinceTime(),it->token(),payloadClassName ); } flushUpdates(); }
void IOVEditor::bulkAppend | ( | std::vector< std::pair< cond::Time_t, std::string > > & | values | ) |
Bulk append of iov chunck.
Definition at line 186 of file IOVEditor.cc.
References cond::DbSession::classNameForItem(), firstTime, flushUpdates(), init(), lastTill(), m_dbSess, m_iov, m_isActive, reportError(), validTime(), and makeHLTPrescaleTable::values.
{ if (values.empty()) return; if(!m_isActive) this->init(); cond::Time_t firstTime = values.front().first; cond::Time_t lastTime = values.back().first; if(!validTime(firstTime)) reportError("cond::IOVEditor::bulkInsert first time not in global range",firstTime); if(!validTime(lastTime)) reportError("cond::IOVEditor::bulkInsert last time not in global range",lastTime); if(lastTime>=lastTill() || ( !m_iov->iovs().empty() && firstTime<=m_iov->iovs().back().sinceTime()) ) reportError("cond::IOVEditor::bulkInsert IOV not in range",firstTime); for(std::vector< std::pair<cond::Time_t,std::string> >::const_iterator it=values.begin(); it!=values.end(); ++it){ std::string payloadClassName = m_dbSess.classNameForItem( it->second ); m_iov->add(it->first,it->second,payloadClassName ); } flushUpdates(); }
void IOVEditor::create | ( | cond::TimeType | timetype | ) |
Definition at line 70 of file IOVEditor.cc.
References flushInserts(), m_iov, m_isActive, m_token, and reportError().
Referenced by cond::service::PoolDBOutputService::createNewIOV(), and cond::AlignSplitIOV::execute().
{ if(!m_token.empty()){ // problem?? reportError("cond::IOVEditor::create cannot create a IOV using an initialized Editor"); } m_iov.reset( new cond::IOVSequence(timetype) ); flushInserts(); m_isActive=true; }
void IOVEditor::create | ( | cond::TimeType | timetype, |
cond::Time_t | lastTill | ||
) |
Definition at line 82 of file IOVEditor.cc.
References flushInserts(), m_iov, m_isActive, m_token, reportError(), and validTime().
{ if(!m_token.empty()){ // problem?? reportError("cond::IOVEditor::create cannot create a IOV using an initialized Editor"); } if(!validTime(lastTill, timetype)) reportError("cond::IOVEditor::create time not in global range",lastTill); m_iov.reset( new cond::IOVSequence((int)timetype,lastTill, " ") ); flushInserts(); m_isActive=true; }
void IOVEditor::debugInfo | ( | std::ostream & | co | ) | const [private] |
Definition at line 29 of file IOVEditor.cc.
References cond::DbSession::connectionString(), m_dbSess, m_iov, m_token, cond::TimeTypeSpecs::name, and cond::timeTypeSpecs.
Referenced by reportError().
{ co << "IOVEditor: "; co << "db " << m_dbSess.connectionString(); if(m_token.empty()) { co << " no token"; return; } if (!m_iov.get() ) { co << " no iov for token " << m_token; return; } co << " iov token " << m_token; co << "\nStamp: " << m_iov->comment() << "; time " << m_iov->timestamp() << "; revision " << m_iov->revision(); co <<". TimeType " << cond::timeTypeSpecs[ m_iov->timeType()].name; if( m_iov->iovs().empty() ) co << ". empty"; else co << ". size " << m_iov->iovs().size() << "; last since " << m_iov->iovs().back().sinceTime(); }
void IOVEditor::deleteEntries | ( | bool | withPayload = false | ) |
Definition at line 343 of file IOVEditor.cc.
References cond::DbSession::deleteObject(), init(), m_dbSess, m_iov, m_isActive, m_token, and reportError().
{ if( m_token.empty() ) reportError("cond::IOVEditor::deleteEntries cannot delete to non-existing IOV sequence"); if(!m_isActive) this->init(); if(withPayload){ std::string tokenStr; IOVSequence::const_iterator payloadIt; IOVSequence::const_iterator payloadItEnd=m_iov->piovs().end(); for(payloadIt=m_iov->piovs().begin();payloadIt!=payloadItEnd;++payloadIt){ tokenStr=payloadIt->token(); m_dbSess.deleteObject( tokenStr ); } } m_dbSess.deleteObject( m_token ); m_iov->piovs().clear(); }
void IOVEditor::editMetadata | ( | std::string const & | metadata, |
bool | append = false |
||
) |
edit metadata
Definition at line 241 of file IOVEditor.cc.
References flushUpdates(), init(), m_iov, and m_isActive.
{ if(!m_isActive) this->init(); m_iov->updateMetadata( metadata, append); flushUpdates(); }
Time_t IOVEditor::firstSince | ( | ) | const |
void IOVEditor::flushInserts | ( | ) | [private] |
Definition at line 113 of file IOVEditor.cc.
References cond::IOVNames::container(), cond::DbSession::isOldSchema(), m_dbSess, m_iov, m_token, cond::DbSession::storage(), and cond::DbSession::storeObject().
Referenced by create().
{ // ***** TEMPORARY FOR TRANSITION PHASE if( m_dbSess.isOldSchema() ){ PoolTokenWriter writer( m_dbSess.storage() ); m_iov->swapOIds( writer ); } // ***** m_token = m_dbSess.storeObject( m_iov.get(), cond::IOVNames::container() ); }
void IOVEditor::flushUpdates | ( | ) | [private] |
Definition at line 123 of file IOVEditor.cc.
References cond::DbSession::isOldSchema(), m_dbSess, m_iov, m_token, cond::DbSession::storage(), and cond::DbSession::updateObject().
Referenced by append(), bulkAppend(), editMetadata(), freeInsert(), insert(), setScope(), stamp(), and updateClosure().
{ // ***** TEMPORARY FOR TRANSITION PHASE if( m_dbSess.isOldSchema() ){ PoolTokenWriter writer( m_dbSess.storage() ); m_iov->swapOIds( writer ); } // ***** m_dbSess.updateObject( m_iov.get(), m_token ); }
unsigned int IOVEditor::freeInsert | ( | cond::Time_t | sinceTime, |
const std::string & | payloadToken | ||
) |
insert a payload with known since in any position
Definition at line 294 of file IOVEditor.cc.
References cond::DbSession::classNameForItem(), flushUpdates(), init(), lastTill(), m_dbSess, m_iov, m_isActive, m_token, reportError(), runTheMatrix::ret, timetype(), cond::timeTypeSpecs, and validTime().
Referenced by cond::service::PoolDBOutputService::appendIOV().
{ if( m_token.empty() ) { reportError("cond::IOVEditor::freeInsert cannot append to non-existing IOV index"); } if(!m_isActive) { this->init(); } // if( m_iov->iov.empty() ) reportError("cond::IOVEditor::freeInsert cannot insert to empty IOV index"); if(!validTime(sinceTime)) reportError("cond::IOVEditor::freeInsert time not in global range",sinceTime); // we do not support multiple iov with identical since... if (m_iov->exist(sinceTime)) reportError("cond::IOVEditor::freeInsert sinceTime already existing",sinceTime); // does it make sense? (in case of mixed till and since insertions...) if (lastTill()<sinceTime) m_iov->updateLastTill( timeTypeSpecs[timetype()].endValue ); std::string payloadClassName = m_dbSess.classNameForItem( payloadToken ); unsigned int ret = m_iov->add(sinceTime,payloadToken, payloadClassName ); flushUpdates(); return ret; }
void IOVEditor::import | ( | const std::string & | sourceIOVtoken | ) |
Definition at line 360 of file IOVEditor.cc.
References loadData(), m_token, and reportError().
{ if( !m_token.empty() ) reportError("cond::IOVEditor::import IOV sequence already exists, cannot import"); loadData( sourceIOVtoken ); //m_token=m_iov.toString(); m_token=sourceIOVtoken; }
void IOVEditor::init | ( | void | ) | [private] |
Definition at line 133 of file IOVEditor.cc.
References loadData(), m_isActive, and m_token.
Referenced by append(), bulkAppend(), deleteEntries(), editMetadata(), freeInsert(), insert(), setScope(), stamp(), truncate(), and updateClosure().
{ loadData( m_token ); m_isActive=true; }
unsigned int IOVEditor::insert | ( | cond::Time_t | tillTime, |
const std::string & | payloadToken | ||
) |
Assign a payload with till time. Returns the payload index in the iov sequence.
Definition at line 164 of file IOVEditor.cc.
References cond::DbSession::classNameForItem(), flushUpdates(), init(), lastTill(), m_dbSess, m_iov, m_isActive, reportError(), runTheMatrix::ret, and validTime().
{ if(!m_isActive) this->init(); if( m_iov->iovs().empty() ) reportError("cond::IOVEditor::insert cannot inser into empty IOV sequence",tillTime); if(!validTime(tillTime)) reportError("cond::IOVEditor::insert time not in global range",tillTime); if(tillTime<=lastTill() ) reportError("cond::IOVEditor::insert IOV not in range",tillTime); cond::Time_t newSince=lastTill()+1; std::string payloadClassName = m_dbSess.classNameForItem( payloadToken ); unsigned int ret = m_iov->add(newSince, payloadToken, payloadClassName); m_iov->updateLastTill(tillTime); flushUpdates(); return ret; }
IOVSequence & IOVEditor::iov | ( | ) |
Time_t IOVEditor::lastTill | ( | ) | const |
Definition at line 142 of file IOVEditor.cc.
References m_iov.
Referenced by append(), bulkAppend(), freeInsert(), and insert().
{ return m_iov->lastTill(); }
void IOVEditor::loadData | ( | const std::string & | token | ) | [private] |
Definition at line 97 of file IOVEditor.cc.
References cond::DbSession::getTypedObject(), cond::DbSession::isOldSchema(), m_dbSess, m_iov, geometryXMLtoCSV::parser, reportError(), cond::DbSession::storage(), and token().
Referenced by import(), and init().
{ if( token.empty()){ // problem? reportError("cond::IOVEditor::loadData cannot load empty token"); } m_iov = m_dbSess.getTypedObject<cond::IOVSequence>( token ); // lazy-loading for QVector m_iov->loadAll(); //**** temporary for the schema transition if( m_dbSess.isOldSchema() ){ PoolTokenParser parser( m_dbSess.storage() ); m_iov->swapTokens( parser ); } //**** }
void IOVEditor::reportError | ( | std::string | message, |
cond::Time_t | time | ||
) | const [private] |
Definition at line 59 of file IOVEditor.cc.
References debugInfo(), Exception, dbtoconf::out, and cond::rpcobgas::time.
{ std::ostringstream out; out << "Error in"; debugInfo(out); out << "\n" << message << " for time: " << time; throw cond::Exception(out.str()); }
void IOVEditor::reportError | ( | std::string | message | ) | const [private] |
Definition at line 51 of file IOVEditor.cc.
References debugInfo(), Exception, python::rootplot::argparse::message, and dbtoconf::out.
Referenced by append(), bulkAppend(), create(), deleteEntries(), freeInsert(), import(), insert(), loadData(), truncate(), and updateClosure().
{ std::ostringstream out; out << "Error in "; debugInfo(out); out << "\n" << message; throw cond::Exception(out.str()); }
void IOVEditor::setScope | ( | cond::IOVSequence::ScopeType | scope | ) |
set the scope
Definition at line 248 of file IOVEditor.cc.
References flushUpdates(), init(), m_iov, and m_isActive.
Referenced by cond::service::PoolDBOutputService::createNewIOV().
{ if(!m_isActive) this->init(); m_iov->setScope( scope ); flushUpdates(); }
void IOVEditor::stamp | ( | std::string const & | icomment, |
bool | append = false |
||
) |
Definition at line 234 of file IOVEditor.cc.
References flushUpdates(), init(), m_iov, and m_isActive.
Referenced by cond::service::PoolDBOutputService::appendIOV(), cond::service::PoolDBOutputService::closeIOV(), cond::service::PoolDBOutputService::createNewIOV(), and cond::AlignSplitIOV::execute().
{ if(!m_isActive) this->init(); m_iov->stamp(icomment, append); flushUpdates(); }
TimeType IOVEditor::timetype | ( | ) | const |
Definition at line 146 of file IOVEditor.cc.
References m_iov.
Referenced by append(), freeInsert(), and validTime().
{ return m_iov->timeType(); }
std::string const& cond::IOVEditor::token | ( | ) | const [inline] |
Returns the token of the iov sequence associated with this editor.
Definition at line 84 of file IOVEditor.h.
References m_token.
Referenced by cond::service::PoolDBOutputService::createNewIOV(), cond::AlignSplitIOV::execute(), and loadData().
{ return m_token;}
unsigned int IOVEditor::truncate | ( | bool | withPayload = false | ) |
Definition at line 327 of file IOVEditor.cc.
References cond::DbSession::deleteObject(), init(), m_dbSess, m_iov, m_isActive, m_token, reportError(), runTheMatrix::ret, and cond::DbSession::updateObject().
{ if( m_token.empty() ) reportError("cond::IOVEditor::truncate cannot delete to non-existing IOV sequence"); if(!m_isActive) this->init(); if (m_iov->piovs().empty()) return 0; if(withPayload){ std::string tokenStr = m_iov->piovs().back().token(); m_dbSess.deleteObject( tokenStr ); } unsigned int ret = m_iov->truncate(); m_dbSess.updateObject( m_iov.get(), m_token ); return ret; }
void IOVEditor::updateClosure | ( | cond::Time_t | newtillTime | ) |
Update the closure of the iov sequence.
Definition at line 255 of file IOVEditor.cc.
References flushUpdates(), init(), m_iov, m_isActive, m_token, and reportError().
Referenced by cond::service::PoolDBOutputService::appendIOV(), and cond::service::PoolDBOutputService::closeIOV().
{ if( m_token.empty() ) reportError("cond::IOVEditor::updateClosure cannot change non-existing IOV index"); if(!m_isActive) this->init(); m_iov->updateLastTill(newtillTime); flushUpdates(); }
bool IOVEditor::validTime | ( | cond::Time_t | time, |
cond::TimeType | timetype | ||
) | const [private] |
Definition at line 151 of file IOVEditor.cc.
References cond::TimeTypeSpecs::beginValue, cond::TimeTypeSpecs::endValue, timetype(), and cond::timeTypeSpecs.
Referenced by append(), bulkAppend(), create(), freeInsert(), insert(), and validTime().
{ return time>=timeTypeSpecs[timetype].beginValue && time<=timeTypeSpecs[timetype].endValue; }
bool IOVEditor::validTime | ( | cond::Time_t | time | ) | const [private] |
Definition at line 157 of file IOVEditor.cc.
References timetype(), and validTime().
cond::DbSession cond::IOVEditor::m_dbSess [private] |
Definition at line 109 of file IOVEditor.h.
Referenced by append(), bulkAppend(), debugInfo(), deleteEntries(), flushInserts(), flushUpdates(), freeInsert(), insert(), loadData(), and truncate().
boost::shared_ptr<cond::IOVSequence> cond::IOVEditor::m_iov [private] |
Definition at line 112 of file IOVEditor.h.
Referenced by append(), bulkAppend(), create(), debugInfo(), deleteEntries(), editMetadata(), firstSince(), flushInserts(), flushUpdates(), freeInsert(), insert(), iov(), lastTill(), loadData(), setScope(), stamp(), timetype(), truncate(), and updateClosure().
bool cond::IOVEditor::m_isActive [private] |
Definition at line 111 of file IOVEditor.h.
Referenced by append(), bulkAppend(), create(), deleteEntries(), editMetadata(), freeInsert(), init(), insert(), setScope(), stamp(), truncate(), and updateClosure().
std::string cond::IOVEditor::m_token [private] |
Definition at line 110 of file IOVEditor.h.
Referenced by append(), create(), debugInfo(), deleteEntries(), flushInserts(), flushUpdates(), freeInsert(), import(), init(), token(), truncate(), and updateClosure().