#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) |
std::string | create (cond::TimeType timetype) |
std::string | create (cond::TimeType timetype, cond::Time_t lastTill) |
std::string | create (cond::TimeType timetype, cond::Time_t lastTill, const std::string &metadata) |
bool | createIOVContainerIfNecessary () |
void | deleteEntries (bool withPayload=false) |
void | editMetadata (std::string const &metadata, bool append=false) |
edit metadata | |
unsigned int | freeInsert (cond::Time_t sinceTime, const std::string &payloadToken) |
insert a payload with known since in any position | |
size_t | import (cond::DbSession &sourceSess, const std::string &sourceIovToken) |
boost::shared_ptr < IOVImportIterator > | importIterator () |
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. | |
IOVEditor (cond::DbSession &dbSess, const std::string &token) | |
IOVEditor (cond::DbSession &dbSess) | |
void | load (const std::string &token) |
cond::IOVProxy | proxy () |
void | reload () |
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 |
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 | reportError (std::string message, cond::Time_t time) const |
void | reportError (std::string message) const |
bool | validTime (cond::Time_t time, cond::TimeType timetype) const |
bool | validTime (cond::Time_t time) const |
Private Attributes | |
boost::shared_ptr < cond::IOVProxyData > | m_iov |
bool | m_isLoaded |
Definition at line 56 of file IOVEditor.h.
IOVEditor::IOVEditor | ( | cond::DbSession & | dbSess | ) | [explicit] |
Definition at line 170 of file IOVEditor.cc.
: m_isLoaded(false), m_iov( new IOVProxyData( dbSess ) ){ }
IOVEditor::IOVEditor | ( | cond::DbSession & | dbSess, |
const std::string & | token | ||
) |
Definition at line 175 of file IOVEditor.cc.
: m_isLoaded(false), m_iov( new IOVProxyData( dbSess, token )){ }
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 400 of file IOVEditor.cc.
References cond::TimeTypeSpecs::endValue, o2o::iov, m_iov, m_isLoaded, reload(), reportError(), run_regression::ret, AlCaHLTBitMon_QueryRunRegistry::string, cond::timeTypeSpecs, cond::updateIOV(), and validTime().
Referenced by cond::service::PoolDBOutputService::appendIOV(), cond::service::PoolDBOutputService::createNewIOV(), cond::AlignSplitIOV::execute(), and TestFunct::WriteWithIOV().
{ if( m_iov->token.empty() ) { reportError("cond::IOVEditor::appendIOV cannot append to non-existing IOV index"); } if( !m_isLoaded ){ reload(); } boost::shared_ptr<IOVSequence>& iov = m_iov->data; if(!validTime(sinceTime)) reportError("cond::IOVEditor::append time not in global range",sinceTime); if( !iov->iovs().empty() ){ //range check in case cond::Time_t lastValidSince=iov->iovs().back().sinceTime(); if( sinceTime<= lastValidSince){ std::ostringstream errStr; errStr << "IOVEditor::append Error: trying to append a since time " << lastValidSince << " which is not larger than last since"; reportError(errStr.str(), sinceTime); } } // does it make sense? (in case of mixed till and since insertions...) if (iov->lastTill()<=sinceTime) iov->updateLastTill( timeTypeSpecs[iov->timeType()].endValue ); std::string payloadClassName = m_iov->dbSession.classNameForItem( payloadToken ); unsigned int ret = iov->add(sinceTime,payloadToken, payloadClassName ); updateIOV( m_iov->dbSession, iov, m_iov->token ); return ret; }
void IOVEditor::bulkAppend | ( | std::vector< std::pair< cond::Time_t, std::string > > & | values | ) |
Bulk append of iov chunck.
Definition at line 305 of file IOVEditor.cc.
References firstTime, o2o::iov, m_iov, m_isLoaded, reload(), reportError(), AlCaHLTBitMon_QueryRunRegistry::string, cond::updateIOV(), validTime(), and makeHLTPrescaleTable::values.
{ if (values.empty()) return; if( !m_isLoaded ){ reload(); } boost::shared_ptr<IOVSequence>& iov = m_iov->data; 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>= iov->lastTill() || ( !iov->iovs().empty() && firstTime<=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_iov->dbSession.classNameForItem( it->second ); iov->add(it->first,it->second,payloadClassName ); } updateIOV( m_iov->dbSession, iov, m_iov->token ); }
void IOVEditor::bulkAppend | ( | std::vector< cond::IOVElement > & | values | ) |
Definition at line 332 of file IOVEditor.cc.
References firstTime, o2o::iov, m_iov, m_isLoaded, reload(), reportError(), AlCaHLTBitMon_QueryRunRegistry::string, cond::updateIOV(), and validTime().
{ if (values.empty()) return; if( !m_isLoaded ){ reload(); } boost::shared_ptr<IOVSequence>& iov = m_iov->data; 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>=iov->lastTill() || ( !iov->iovs().empty() && firstTime<=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_iov->dbSession.classNameForItem( it->token() ); iov->add(it->sinceTime(),it->token(),payloadClassName ); } updateIOV( m_iov->dbSession, iov, m_iov->token ); }
std::string IOVEditor::create | ( | cond::TimeType | timetype, |
cond::Time_t | lastTill, | ||
const std::string & | metadata | ||
) |
Definition at line 251 of file IOVEditor.cc.
References cond::insertIOV(), m_iov, and m_isLoaded.
{ m_iov->data.reset( new cond::IOVSequence((int)timetype,lastTill, metadata) ); m_iov->token = insertIOV( m_iov->dbSession, m_iov->data ); m_isLoaded=true; return m_iov->token; }
std::string IOVEditor::create | ( | cond::TimeType | timetype | ) |
Definition at line 244 of file IOVEditor.cc.
References cond::insertIOV(), m_iov, and m_isLoaded.
Referenced by cond::service::PoolDBOutputService::createNewIOV(), cond::ExportIOVUtilities::execute(), cond::AlignSplitIOV::execute(), and TestFunct::WriteWithIOV().
{ m_iov->data.reset( new cond::IOVSequence(timetype) ); m_iov->token = insertIOV( m_iov->dbSession, m_iov->data ); m_isLoaded=true; return m_iov->token; }
std::string IOVEditor::create | ( | cond::TimeType | timetype, |
cond::Time_t | lastTill | ||
) |
Definition at line 261 of file IOVEditor.cc.
References cond::insertIOV(), m_iov, m_isLoaded, and AlCaHLTBitMon_QueryRunRegistry::string.
{ m_iov->data.reset( new cond::IOVSequence((int)timetype,lastTill, std::string(" ")) ); m_iov->token = insertIOV( m_iov->dbSession, m_iov->data ); m_isLoaded=true; return m_iov->token; }
bool IOVEditor::createIOVContainerIfNecessary | ( | ) |
Definition at line 233 of file IOVEditor.cc.
References cond::IOVSchemaUtility::createIOVContainer(), cond::IOVSchemaUtility::existsIOVContainer(), m_iov, and run_regression::ret.
Referenced by cond::ExportIOVUtilities::execute().
{ bool ret = false; cond::IOVSchemaUtility schemaUtil( m_iov->dbSession ); if( !schemaUtil.existsIOVContainer() ){ schemaUtil.createIOVContainer(); ret = true; } return ret; }
void IOVEditor::debugInfo | ( | std::ostream & | co | ) | const [private] |
Definition at line 192 of file IOVEditor.cc.
References o2o::iov, m_iov, cond::TimeTypeSpecs::name, and cond::timeTypeSpecs.
Referenced by reportError().
{ boost::shared_ptr<IOVSequence>& iov = m_iov->data; co << "IOVEditor: "; co << "db " << m_iov->dbSession.connectionString(); if(m_iov->token.empty()) { co << " no token"; return; } if (!m_iov->data.get() ) { co << " no iov for token " << m_iov->token; return; } co << " iov token " << m_iov->token; co << "\nStamp: " << iov->comment() << "; time " << iov->timestamp() << "; revision " << iov->revision(); co <<". TimeType " << cond::timeTypeSpecs[ iov->timeType()].name; if( iov->iovs().empty() ) co << ". empty"; else co << ". size " << iov->iovs().size() << "; last since " << iov->iovs().back().sinceTime(); }
void IOVEditor::deleteEntries | ( | bool | withPayload = false | ) |
Definition at line 488 of file IOVEditor.cc.
References o2o::iov, m_iov, m_isLoaded, reload(), reportError(), and AlCaHLTBitMon_QueryRunRegistry::string.
{ if( m_iov->token.empty() ) reportError("cond::IOVEditor::deleteEntries cannot delete to non-existing IOV sequence"); if( !m_isLoaded ){ reload(); } boost::shared_ptr<IOVSequence>& iov = m_iov->data; if(withPayload){ std::string tokenStr; IOVSequence::const_iterator payloadIt; IOVSequence::const_iterator payloadItEnd=iov->piovs().end(); for(payloadIt=iov->piovs().begin();payloadIt!=payloadItEnd;++payloadIt){ tokenStr=payloadIt->token(); m_iov->dbSession.deleteObject( tokenStr ); } } m_iov->dbSession.deleteObject( m_iov->token ); iov->piovs().clear(); }
void IOVEditor::editMetadata | ( | std::string const & | metadata, |
bool | append = false |
||
) |
edit metadata
Definition at line 369 of file IOVEditor.cc.
References o2o::iov, m_iov, m_isLoaded, reload(), and cond::updateIOV().
unsigned int IOVEditor::freeInsert | ( | cond::Time_t | sinceTime, |
const std::string & | payloadToken | ||
) |
insert a payload with known since in any position
Definition at line 435 of file IOVEditor.cc.
References cond::TimeTypeSpecs::endValue, o2o::iov, m_iov, m_isLoaded, reload(), reportError(), run_regression::ret, AlCaHLTBitMon_QueryRunRegistry::string, cond::timeTypeSpecs, cond::updateIOV(), and validTime().
Referenced by cond::service::PoolDBOutputService::appendIOV().
{ if( m_iov->token.empty() ) { reportError("cond::IOVEditor::freeInsert cannot append to non-existing IOV index"); } if( !m_isLoaded ){ reload(); } boost::shared_ptr<IOVSequence>& iov = m_iov->data; // if( m_iov->data->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->data->exist(sinceTime)) reportError("cond::IOVEditor::freeInsert sinceTime already existing",sinceTime); // does it make sense? (in case of mixed till and since insertions...) if (iov->lastTill()<sinceTime) iov->updateLastTill( timeTypeSpecs[iov->timeType()].endValue ); std::string payloadClassName = m_iov->dbSession.classNameForItem( payloadToken ); unsigned int ret = iov->add(sinceTime,payloadToken, payloadClassName ); updateIOV( m_iov->dbSession, iov, m_iov->token ); return ret; }
size_t IOVEditor::import | ( | cond::DbSession & | sourceSess, |
const std::string & | sourceIovToken | ||
) |
Definition at line 507 of file IOVEditor.cc.
References importIterator().
{ boost::shared_ptr<IOVImportIterator> importer = importIterator(); importer->setUp( sourceSess, sourceIovToken ); return importer->importAll(); }
boost::shared_ptr< IOVImportIterator > IOVEditor::importIterator | ( | ) |
Definition at line 515 of file IOVEditor.cc.
References m_iov, m_isLoaded, and reload().
Referenced by cond::ExportIOVUtilities::execute(), and import().
{ if( !m_isLoaded ){ reload(); } return boost::shared_ptr<IOVImportIterator>( new IOVImportIterator( m_iov )); }
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 281 of file IOVEditor.cc.
References o2o::iov, m_iov, m_isLoaded, reload(), reportError(), run_regression::ret, AlCaHLTBitMon_QueryRunRegistry::string, cond::updateIOV(), and validTime().
{ if( !m_isLoaded ){ reload(); } boost::shared_ptr<IOVSequence>& iov = m_iov->data; if( 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<=iov->lastTill() ) reportError("cond::IOVEditor::insert IOV not in range",tillTime); cond::Time_t newSince=iov->lastTill()+1; std::string payloadClassName = m_iov->dbSession.classNameForItem( payloadToken ); unsigned int ret = iov->add(newSince, payloadToken, payloadClassName); iov->updateLastTill(tillTime); updateIOV( m_iov->dbSession, iov, m_iov->token ); return ret; }
void IOVEditor::load | ( | const std::string & | token | ) |
Definition at line 186 of file IOVEditor.cc.
References m_iov, m_isLoaded, and token().
Referenced by cond::ExportIOVUtilities::execute().
{ m_iov->token = token; m_iov->refresh(); m_isLoaded = true; }
IOVProxy IOVEditor::proxy | ( | ) |
Definition at line 530 of file IOVEditor.cc.
References m_iov.
Referenced by cond::ExportIOVUtilities::execute().
{ return IOVProxy( m_iov ); }
void IOVEditor::reload | ( | ) |
Definition at line 181 of file IOVEditor.cc.
References m_iov, and m_isLoaded.
Referenced by append(), bulkAppend(), deleteEntries(), editMetadata(), cond::ExportIOVUtilities::execute(), freeInsert(), importIterator(), insert(), setScope(), stamp(), truncate(), and updateClosure().
{ m_iov->refresh(); m_isLoaded = true; }
void IOVEditor::reportError | ( | std::string | message | ) | const [private] |
Definition at line 215 of file IOVEditor.cc.
References debugInfo(), Exception, python::rootplot::argparse::message, and dbtoconf::out.
Referenced by append(), bulkAppend(), deleteEntries(), freeInsert(), insert(), truncate(), and updateClosure().
{ std::ostringstream out; out << "Error in "; debugInfo(out); out << "\n" << message; throw cond::Exception(out.str()); }
void IOVEditor::reportError | ( | std::string | message, |
cond::Time_t | time | ||
) | const [private] |
Definition at line 223 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::setScope | ( | cond::IOVSequence::ScopeType | scope | ) |
set the scope
Definition at line 379 of file IOVEditor.cc.
References o2o::iov, m_iov, m_isLoaded, reload(), and cond::updateIOV().
Referenced by cond::service::PoolDBOutputService::createNewIOV(), and cond::ExportIOVUtilities::execute().
void IOVEditor::stamp | ( | std::string const & | icomment, |
bool | append = false |
||
) |
Definition at line 359 of file IOVEditor.cc.
References o2o::iov, m_iov, m_isLoaded, reload(), and cond::updateIOV().
Referenced by cond::service::PoolDBOutputService::appendIOV(), cond::service::PoolDBOutputService::closeIOV(), cond::service::PoolDBOutputService::createNewIOV(), and cond::AlignSplitIOV::execute().
TimeType IOVEditor::timetype | ( | ) | const |
Definition at line 522 of file IOVEditor.cc.
References m_iov.
Referenced by cond::ExportIOVUtilities::execute(), and validTime().
{ return m_iov->data->timeType(); }
std::string const & IOVEditor::token | ( | ) | const |
Definition at line 526 of file IOVEditor.cc.
References m_iov.
Referenced by cond::service::PoolDBOutputService::createNewIOV(), cond::AlignSplitIOV::execute(), load(), and TestFunct::WriteWithIOV().
{ return m_iov->token; }
unsigned int IOVEditor::truncate | ( | bool | withPayload = false | ) |
Definition at line 469 of file IOVEditor.cc.
References o2o::iov, m_iov, m_isLoaded, reload(), reportError(), run_regression::ret, AlCaHLTBitMon_QueryRunRegistry::string, and cond::updateIOV().
{ if( m_iov->token.empty() ) reportError("cond::IOVEditor::truncate cannot delete to non-existing IOV sequence"); if( !m_isLoaded ){ reload(); } boost::shared_ptr<IOVSequence>& iov = m_iov->data; if (iov->piovs().empty()) return 0; if(withPayload){ std::string tokenStr = iov->piovs().back().token(); m_iov->dbSession.deleteObject( tokenStr ); } unsigned int ret = iov->truncate(); updateIOV( m_iov->dbSession, iov, m_iov->token ); return ret; }
void IOVEditor::updateClosure | ( | cond::Time_t | newtillTime | ) |
Update the closure of the iov sequence.
Definition at line 389 of file IOVEditor.cc.
References o2o::iov, m_iov, m_isLoaded, reload(), reportError(), and cond::updateIOV().
Referenced by cond::service::PoolDBOutputService::appendIOV(), and cond::service::PoolDBOutputService::closeIOV().
{ if( m_iov->token.empty() ) reportError("cond::IOVEditor::updateClosure cannot change non-existing IOV index"); if( !m_isLoaded ){ reload(); } boost::shared_ptr<IOVSequence>& iov = m_iov->data; iov->updateLastTill(newtillTime); updateIOV( m_iov->dbSession, iov, m_iov->token ); }
bool IOVEditor::validTime | ( | cond::Time_t | time | ) | const [private] |
Definition at line 274 of file IOVEditor.cc.
References m_iov, and validTime().
bool IOVEditor::validTime | ( | cond::Time_t | time, |
cond::TimeType | timetype | ||
) | const [private] |
Definition at line 268 of file IOVEditor.cc.
References cond::TimeTypeSpecs::beginValue, cond::TimeTypeSpecs::endValue, timetype(), and cond::timeTypeSpecs.
Referenced by append(), bulkAppend(), freeInsert(), insert(), and validTime().
{ return time>=timeTypeSpecs[timetype].beginValue && time<=timeTypeSpecs[timetype].endValue; }
boost::shared_ptr<cond::IOVProxyData> cond::IOVEditor::m_iov [private] |
Definition at line 140 of file IOVEditor.h.
Referenced by append(), bulkAppend(), create(), createIOVContainerIfNecessary(), debugInfo(), deleteEntries(), editMetadata(), freeInsert(), importIterator(), insert(), load(), proxy(), reload(), setScope(), stamp(), timetype(), token(), truncate(), updateClosure(), and validTime().
bool cond::IOVEditor::m_isLoaded [private] |
Definition at line 139 of file IOVEditor.h.
Referenced by append(), bulkAppend(), create(), deleteEntries(), editMetadata(), freeInsert(), importIterator(), insert(), load(), reload(), setScope(), stamp(), truncate(), and updateClosure().