10 const std::string& iovToken ){
11 if( iovToken.empty()){
27 const boost::shared_ptr<IOVSequence>&
data,
28 bool swapOIds=
false ){
32 data->swapOIds( writer );
39 const boost::shared_ptr<IOVSequence>&
data,
40 const std::string& token ){
44 data->swapOIds( writer );
73 if( isecondTill != siov.
iovs().
end() ) isecondTill++;
75 if (ifirstTill==isecondTill)
76 throw cond::Exception(
"IOVImportIterator::setUp Error: empty input range");
80 else if (outOfOrder) {
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();
99 const std::string& sourceIovToken,
104 IOVProxy sourceIov( sourceSess, sourceIovToken );
105 setUp( sourceIov, since, till, outOfOrder, bulkSize );
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();
135 const std::string& sourceIovToken,
137 IOVProxy sourceIov( sourceSess, sourceIovToken );
138 setUp( sourceIov, bulkSize );
147 boost::shared_ptr<IOVSequence>& diov =
m_destIov->data;
153 diov->add(m_lastSince, newPtoken, cont.
className());
176 const std::string& token ):
193 boost::shared_ptr<IOVSequence>&
iov =
m_iov->data;
195 co <<
"db " <<
m_iov->dbSession.connectionString();
196 if(
m_iov->token.empty()) {
197 co <<
" no token";
return;
199 if (!
m_iov->data.get() ) {
200 co <<
" no iov for token " <<
m_iov->token;
203 co <<
" iov token " <<
m_iov->token;
204 co <<
"\nStamp: " << iov->comment()
205 <<
"; time " << iov->timestamp()
206 <<
"; revision " << iov->revision();
208 if( iov->iovs().empty() )
211 co <<
". size " << iov->iovs().size()
212 <<
"; last since " << iov->iovs().back().sinceTime();
216 std::ostringstream
out;
225 std::ostringstream
out;
228 out <<
"\n" << message <<
" for time: " <<
time;
253 const std::string& metadata ) {
282 const std::string& payloadToken ){
286 boost::shared_ptr<IOVSequence>&
iov =
m_iov->data;
287 if( iov->iovs().empty() )
288 reportError(
"cond::IOVEditor::insert cannot inser into empty IOV sequence",tillTime);
291 reportError(
"cond::IOVEditor::insert time not in global range",tillTime);
293 if(tillTime<=iov->lastTill() )
294 reportError(
"cond::IOVEditor::insert IOV not in range",tillTime);
297 std::string payloadClassName =
m_iov->dbSession.classNameForItem( payloadToken );
298 unsigned int ret = iov->add(newSince, payloadToken, payloadClassName);
299 iov->updateLastTill(tillTime);
306 if (
values.empty())
return;
310 boost::shared_ptr<IOVSequence>&
iov =
m_iov->data;
314 reportError(
"cond::IOVEditor::bulkInsert first time not in global range",firstTime);
317 reportError(
"cond::IOVEditor::bulkInsert last time not in global range",lastTime);
319 if(lastTime>= iov->lastTill() ||
320 ( !iov->iovs().empty() && firstTime<=iov->iovs().back().sinceTime())
322 reportError(
"cond::IOVEditor::bulkInsert IOV not in range",firstTime);
324 for(std::vector< std::pair<cond::Time_t,std::string> >::const_iterator it=
values.begin(); it!=
values.end(); ++it){
325 std::string payloadClassName =
m_iov->dbSession.classNameForItem( it->second );
326 iov->add(it->first,it->second,payloadClassName );
333 if (values.empty())
return;
337 boost::shared_ptr<IOVSequence>&
iov =
m_iov->data;
341 reportError(
"cond::IOVEditor::bulkInsert first time not in global range",firstTime);
344 reportError(
"cond::IOVEditor::bulkInsert last time not in global range",lastTime);
346 if(lastTime>=iov->lastTill() ||
347 ( !iov->iovs().empty() && firstTime<=iov->iovs().back().sinceTime())
348 )
reportError(
"cond::IOVEditor::bulkInsert IOV not in range",firstTime);
350 for(std::vector< cond::IOVElement >::const_iterator it=values.begin(); it!=values.end(); ++it){
351 std::string payloadClassName =
m_iov->dbSession.classNameForItem( it->token() );
352 iov->add(it->sinceTime(),it->token(),payloadClassName );
364 boost::shared_ptr<IOVSequence>&
iov =
m_iov->data;
365 iov->stamp(icomment, append);
374 boost::shared_ptr<IOVSequence>&
iov =
m_iov->data;
375 iov->updateMetadata( metadata, append);
383 boost::shared_ptr<IOVSequence>&
iov =
m_iov->data;
384 iov->setScope( scope );
390 if(
m_iov->token.empty() )
reportError(
"cond::IOVEditor::updateClosure cannot change non-existing IOV index");
394 boost::shared_ptr<IOVSequence>&
iov =
m_iov->data;
395 iov->updateLastTill(newtillTime);
401 const std::string& payloadToken ){
402 if(
m_iov->token.empty() ) {
403 reportError(
"cond::IOVEditor::appendIOV cannot append to non-existing IOV index");
409 boost::shared_ptr<IOVSequence>&
iov =
m_iov->data;
412 reportError(
"cond::IOVEditor::append time not in global range",sinceTime);
414 if( !iov->iovs().empty() ){
416 cond::Time_t lastValidSince=iov->iovs().back().sinceTime();
417 if( sinceTime<= lastValidSince){
418 std::ostringstream errStr;
419 errStr <<
"IOVEditor::append Error: trying to append a since time " << lastValidSince
420 <<
" which is not larger than last since";
427 std::string payloadClassName =
m_iov->dbSession.classNameForItem( payloadToken );
428 unsigned int ret = iov->add(sinceTime,payloadToken, payloadClassName );
436 const std::string& payloadToken ){
437 if(
m_iov->token.empty() ) {
438 reportError(
"cond::IOVEditor::freeInsert cannot append to non-existing IOV index");
444 boost::shared_ptr<IOVSequence>&
iov =
m_iov->data;
450 reportError(
"cond::IOVEditor::freeInsert time not in global range",sinceTime);
454 if (
m_iov->data->exist(sinceTime))
455 reportError(
"cond::IOVEditor::freeInsert sinceTime already existing",sinceTime);
461 std::string payloadClassName =
m_iov->dbSession.classNameForItem( payloadToken );
462 unsigned int ret = iov->add(sinceTime,payloadToken, payloadClassName );
470 if(
m_iov->token.empty() )
reportError(
"cond::IOVEditor::truncate cannot delete to non-existing IOV sequence");
474 boost::shared_ptr<IOVSequence>&
iov =
m_iov->data;
475 if (iov->piovs().empty())
return 0;
477 std::string tokenStr = iov->piovs().back().token();
478 m_iov->dbSession.deleteObject( tokenStr );
480 unsigned int ret = iov->truncate();
489 if(
m_iov->token.empty() )
reportError(
"cond::IOVEditor::deleteEntries cannot delete to non-existing IOV sequence");
493 boost::shared_ptr<IOVSequence>&
iov =
m_iov->data;
495 std::string tokenStr;
498 for(payloadIt=iov->piovs().begin();payloadIt!=payloadItEnd;++payloadIt){
499 tokenStr=payloadIt->token();
500 m_iov->dbSession.deleteObject( tokenStr );
503 m_iov->dbSession.deleteObject(
m_iov->token );
504 iov->piovs().clear();
508 const std::string& sourceIovToken ){
510 importer->setUp( sourceSess, sourceIovToken );
511 return importer->importAll();
514 boost::shared_ptr<IOVImportIterator>
523 return m_iov->data->timeType();
const TimeTypeSpecs timeTypeSpecs[]
std::string create(cond::TimeType timetype)
void debugInfo(std::ostream &co) const
void load(const std::string &token)
void reportError(std::string message) const
const_iterator find(cond::Time_t time) const
void updateIOV(cond::DbSession &dbSess, const boost::shared_ptr< IOVSequence > &data, const std::string &token)
bool validTime(cond::Time_t time, cond::TimeType timetype) const
cond::Time_t firstSince() const
Container const & iovs() const
size_t import(cond::DbSession &sourceSess, const std::string &sourceIovToken)
std::string const & token() const
boost::shared_ptr< cond::IOVSequence > loadIOV(cond::DbSession &dbSess, const std::string &iovToken)
void setScope(cond::IOVSequence::ScopeType scope)
set the scope
Container::const_iterator const_iterator
unsigned int freeInsert(cond::Time_t sinceTime, const std::string &payloadToken)
insert a payload with known since in any position
cond::IOVProxy m_sourceIov
IOVSequence::const_iterator m_cursor
IOVImportIterator(boost::shared_ptr< cond::IOVProxyData > &destIov)
const std::string & className()
unsigned int truncate(bool withPayload=false)
bool exist(cond::Time_t time) const
unsigned long long Time_t
TimeType timetype() const
const T & max(const T &a, const T &b)
IOVSequence const & iov() const
std::string storeObject(const T *object, const std::string &containerName)
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.
bool createIOVContainerIfNecessary()
size_t importMoreElements()
IOVSequence::const_iterator m_till
void updateClosure(cond::Time_t newtillTime)
Update the closure of the iov sequence.
unsigned int append(cond::Time_t sinceTime, const std::string &payloadToken)
std::string insertIOV(cond::DbSession &dbSess, const boost::shared_ptr< IOVSequence > &data, bool swapOIds=false)
static std::string container()
virtual ~IOVImportIterator()
char data[epos_bytes_allocation]
void bulkAppend(std::vector< std::pair< cond::Time_t, std::string > > &values)
Bulk append of iov chunck.
void stamp(std::string const &icomment, bool append=false)
bool existsIOVContainer()
void deleteEntries(bool withPayload=false)
bool createIOVContainer()
create iov tables
IOVEditor(cond::DbSession &dbSess)
boost::shared_ptr< IOVImportIterator > importIterator()
bool fromString(const std::string &s)
bool updateObject(const T *object, const std::string &objectId)
boost::shared_ptr< T > getTypedObject(const std::string &objectId)
ora::Database & storage()
void setUp(cond::IOVProxy &sourceIov, cond::Time_t since, cond::Time_t till, bool outOfOrder, size_t bulkSize=1)
boost::shared_ptr< cond::IOVProxyData > m_destIov
boost::shared_ptr< cond::IOVProxyData > m_iov
void editMetadata(std::string const &metadata, bool append=false)
edit metadata