CMS 3D CMS Logo

Public Member Functions | Private Attributes

lumi::idDealer Class Reference

#include <idDealer.h>

List of all members.

Public Member Functions

unsigned long long generateNextIDForTable (const std::string &tableName, unsigned int interval=1)
unsigned long long getIDforTable (const std::string &tableName)
 idDealer (coral::ISchema &schema)

Private Attributes

std::string m_idtablecolumnName
std::string m_idtablecolumnType
coral::ISchema & m_schema

Detailed Description

Definition at line 8 of file idDealer.h.


Constructor & Destructor Documentation

lumi::idDealer::idDealer ( coral::ISchema &  schema) [explicit]

Member Function Documentation

unsigned long long lumi::idDealer::generateNextIDForTable ( const std::string &  tableName,
unsigned int  interval = 1 
)

Definition at line 31 of file idDealer.cc.

References python::IdGenerator::idtableName, nameDealer::idTableName(), idDealer::inputData, MergeJob_cfg::interval, lumiQueryAPI::q, alignCSCRings::r, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by lumi::RevisionDML::bookNewEntry(), lumi::RevisionDML::bookNewRevision(), lumi::TRGDummy2DB::retrieveData(), lumi::TRGWBM2DB::retrieveData(), lumi::LumiDummy2DB::retrieveData(), lumi::HLTDummy2DB::retrieveData(), lumi::Lumi2DB::writeAllLumiData(), lumi::HLTV32DB::writeHltData(), and lumi::TRGScalers2DB::writeTrgData().

                                                                                                         {
  std::string idtableName=lumi::LumiNames::idTableName(tableName);
  coral::IQuery* q=m_schema.tableHandle(idtableName).newQuery();
  q->addToOutputList(m_idtablecolumnName);
  unsigned long long r=0;
  coral::AttributeList myresult;
  myresult.extend(m_idtablecolumnName,typeid(unsigned long long));
  q->defineOutput(myresult);
  q->setForUpdate(); //lock it
  coral::ICursor& cursor=q->execute();
  while ( cursor.next() ){
    const coral::AttributeList& row = cursor.currentRow();
    r = row[m_idtablecolumnName].data<unsigned long long>();
  }
  coral::ITableDataEditor& dataEditor=m_schema.tableHandle(idtableName).dataEditor();
  coral::AttributeList inputData;
  //inputData.extend("interval",typeid(unsigned int));
  //inputData["interval"].data<unsigned int>()=interval;
  //dataEditor.updateRows(m_idtablecolumnName+"="+m_idtablecolumnName+"+1","",inputData);
  std::stringstream ss;
  ss<<interval;
  dataEditor.updateRows(m_idtablecolumnName+"="+m_idtablecolumnName+"+"+ss.str(),"",inputData);
  delete q;
  return r+interval;
}
unsigned long long lumi::idDealer::getIDforTable ( const std::string &  tableName)

Definition at line 16 of file idDealer.cc.

References python::IdGenerator::idtableName, nameDealer::idTableName(), lumiQueryAPI::q, query::result, and AlCaHLTBitMon_QueryRunRegistry::string.

                                                                          {
  std::string idtableName=lumi::LumiNames::idTableName(tableName);
  coral::IQuery* q=m_schema.tableHandle(idtableName).newQuery();
  q->addToOutputList(m_idtablecolumnName);
  q->setForUpdate(); //lock it
  coral::ICursor& cursor=q->execute();
  unsigned long long result=0;
  while ( cursor.next() ){
    const coral::AttributeList& row = cursor.currentRow();
    result = row[m_idtablecolumnName].data<unsigned long long>();
  }
  cursor.close();
  delete q;
  return result;
}

Member Data Documentation

std::string lumi::idDealer::m_idtablecolumnName [private]

Definition at line 15 of file idDealer.h.

std::string lumi::idDealer::m_idtablecolumnType [private]

Definition at line 16 of file idDealer.h.

coral::ISchema& lumi::idDealer::m_schema [private]

Definition at line 14 of file idDealer.h.