#include <idDealer.h>
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 |
Definition at line 8 of file idDealer.h.
lumi::idDealer::idDealer | ( | coral::ISchema & | schema | ) | [explicit] |
Definition at line 14 of file idDealer.cc.
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, and csvReporter::r.
Referenced by lumi::HLT2DB::retrieveData(), lumi::TRGDummy2DB::retrieveData(), lumi::TRGWBM2DB::retrieveData(), lumi::LumiDummy2DB::retrieveData(), lumi::TRG2DB::retrieveData(), lumi::HLTDummy2DB::retrieveData(), and lumi::Lumi2DB::writeAllLumiData().
{ 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, and query::result.
{ 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; }
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.