CMS 3D CMS Logo

Public Member Functions | Private Attributes

cond::IOVImportIterator Class Reference

#include <IOVEditor.h>

List of all members.

Public Member Functions

bool hasMoreElements ()
size_t importAll ()
size_t importMoreElements ()
 IOVImportIterator (boost::shared_ptr< cond::IOVProxyData > &destIov)
void setUp (cond::DbSession &sourceSess, const std::string &sourceIovToken, size_t bulkSize=1)
void setUp (cond::IOVProxy &sourceIov, 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, cond::Time_t since, cond::Time_t till, bool outOfOrder, 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.

                                                                                  :
    m_sourceIov(),
    m_destIov( destIov ),
    m_lastSince( 0 ),
    m_bulkSize( 0 ),
    m_cursor(),
    m_till()
  {
  }
cond::IOVImportIterator::~IOVImportIterator ( ) [virtual]

Definition at line 60 of file IOVEditor.cc.

                                       {
  }

Member Function Documentation

bool cond::IOVImportIterator::hasMoreElements ( )

Definition at line 133 of file IOVEditor.cc.

References m_cursor, and m_till.

Referenced by importAll().

                                         {
    return m_cursor != m_till;
  }
size_t cond::IOVImportIterator::importAll ( )

Definition at line 152 of file IOVEditor.cc.

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

                                     {
    size_t total = 0;
    while( hasMoreElements() ){
      total += importMoreElements();
    }
    return total;
  }
size_t cond::IOVImportIterator::importMoreElements ( )

Definition at line 137 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().

                                              {
    size_t i = 0;    
    boost::shared_ptr<IOVSequence>& diov = m_destIov->data;
    for( ; i<m_bulkSize && m_cursor != m_till; ++i, ++m_cursor, m_lastSince=m_cursor->sinceTime() ){
      std::string newPtoken = m_destIov->dbSession.importObject( m_sourceIov.db(),m_cursor->token());
      ora::OId poid;
      poid.fromString( newPtoken );
      ora::Container cont = m_destIov->dbSession.storage().containerHandle( poid.containerId() );
      diov->add(m_lastSince, newPtoken, cont.className());
    }
    if( m_cursor == m_till ) diov->stamp(cond::userInfo(),false);
    updateIOV( m_destIov->dbSession, diov, m_destIov->token );
    return i;
  }
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 94 of file IOVEditor.cc.

References setUp().

                                                  {
    IOVProxy sourceIov( sourceSess, sourceIovToken );
    setUp( sourceIov, since, till, outOfOrder, bulkSize );
  }
void cond::IOVImportIterator::setUp ( cond::DbSession sourceSess,
const std::string &  sourceIovToken,
size_t  bulkSize = 1 
)

Definition at line 126 of file IOVEditor.cc.

References setUp().

                                                  {
    IOVProxy sourceIov( sourceSess, sourceIovToken );
    setUp( sourceIov, bulkSize );
  }
void cond::IOVImportIterator::setUp ( cond::IOVProxy sourceIov,
size_t  bulkSize = 1 
)

Definition at line 104 of file IOVEditor.cc.

References cond::IOVSequence::firstSince(), cond::IOVProxy::iov(), cond::IOVSequence::iovs(), m_bulkSize, m_cursor, m_destIov, m_lastSince, m_sourceIov, and m_till.

                                                  { 

    m_sourceIov = sourceIov;
    const IOVSequence& siov = m_sourceIov.iov();
    cond::Time_t dsince = siov.firstSince();

    IOVSequence::const_iterator ifirstTill = siov.iovs().begin();
    IOVSequence::const_iterator isecondTill = siov.iovs().end();
    
    IOVSequence& diov = *m_destIov->data;
    if (!diov.iovs().empty()) { // do not waist time
      if (dsince <= diov.iovs().back().sinceTime())
        throw cond::Exception("IOVImportIterator::setUp Error: since time out of range, below last since");
    }

    m_lastSince = dsince;
    m_cursor = ifirstTill;
    m_till = isecondTill;
    m_bulkSize = bulkSize;
  }
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 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().

                                                  {  
    m_sourceIov = sourceIov;
    const IOVSequence& siov = m_sourceIov.iov();
    cond::Time_t dsince = std::max(since, siov.firstSince());
    IOVSequence::const_iterator ifirstTill = siov.find(dsince);
    IOVSequence::const_iterator isecondTill = siov.find(till);
    if( isecondTill != siov.iovs().end() ) isecondTill++;
    
    if (ifirstTill==isecondTill) 
      throw cond::Exception("IOVImportIterator::setUp Error: empty input range");
    
    IOVSequence& diov = *m_destIov->data;
    if ( diov.iovs().empty()) ; // do not waist time
    else if (outOfOrder) {
      for( IOVSequence::const_iterator it=ifirstTill;
           it!=isecondTill; ++it)
        if (diov.exist(it->sinceTime()))
          throw cond::Exception("IOVImportIterator::setUp Error: since time already exists");
    } else if (dsince <= diov.iovs().back().sinceTime())
      throw cond::Exception("IOVImportIterator::setUp Error: since time out of range, below last since");
    
    m_lastSince = dsince;
    m_cursor = ifirstTill;
    m_till = isecondTill;
    m_bulkSize = bulkSize;
 }

Member Data Documentation

Definition at line 51 of file IOVEditor.h.

Referenced by importMoreElements(), and setUp().

Definition at line 52 of file IOVEditor.h.

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

Definition at line 49 of file IOVEditor.h.

Referenced by importMoreElements(), and setUp().

Definition at line 50 of file IOVEditor.h.

Referenced by importMoreElements(), and setUp().

Definition at line 48 of file IOVEditor.h.

Referenced by importMoreElements(), and setUp().

Definition at line 53 of file IOVEditor.h.

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