CMS 3D CMS Logo

idDealer.cc
Go to the documentation of this file.
2 #include "RelationalAccess/ISchema.h"
3 #include "RelationalAccess/ITable.h"
4 #include "RelationalAccess/IQuery.h"
5 #include "RelationalAccess/ICursor.h"
6 #include "RelationalAccess/ITableDataEditor.h"
7 #include "CoralBase/AttributeList.h"
8 #include "CoralBase/AttributeSpecification.h"
9 #include "CoralBase/AttributeList.h"
10 #include "CoralBase/Attribute.h"
12 #include <sstream>
13 //#include <iostream>
14 lumi::idDealer::idDealer(coral::ISchema& schema)
15  : m_schema(schema),
16  m_idtablecolumnName(lumi::LumiNames::idTableColumnName()),
17  m_idtablecolumnType(lumi::LumiNames::idTableColumnType()) {}
20  coral::IQuery* q = m_schema.tableHandle(idtableName).newQuery();
21  q->addToOutputList(m_idtablecolumnName);
22  q->setForUpdate(); //lock it
23  coral::ICursor& cursor = q->execute();
24  unsigned long long result = 0;
25  while (cursor.next()) {
26  const coral::AttributeList& row = cursor.currentRow();
27  result = row[m_idtablecolumnName].data<unsigned long long>();
28  }
29  cursor.close();
30  delete q;
31  return result;
32 }
33 unsigned long long lumi::idDealer::generateNextIDForTable(const std::string& tableName, unsigned int interval) {
35  coral::IQuery* q = m_schema.tableHandle(idtableName).newQuery();
36  q->addToOutputList(m_idtablecolumnName);
37  unsigned long long r = 0;
38  coral::AttributeList myresult;
39  myresult.extend(m_idtablecolumnName, typeid(unsigned long long));
40  q->defineOutput(myresult);
41  q->setForUpdate(); //lock it
42  coral::ICursor& cursor = q->execute();
43  while (cursor.next()) {
44  const coral::AttributeList& row = cursor.currentRow();
45  r = row[m_idtablecolumnName].data<unsigned long long>();
46  }
47  coral::ITableDataEditor& dataEditor = m_schema.tableHandle(idtableName).dataEditor();
48  coral::AttributeList inputData;
49  //inputData.extend("interval",typeid(unsigned int));
50  //inputData["interval"].data<unsigned int>()=interval;
51  //dataEditor.updateRows(m_idtablecolumnName+"="+m_idtablecolumnName+"+1","",inputData);
52  std::stringstream ss;
53  ss << interval;
54  dataEditor.updateRows(m_idtablecolumnName + "=" + m_idtablecolumnName + "+" + ss.str(), "", inputData);
55  delete q;
56  return r + interval;
57 }
lumi::idDealer::getIDforTable
unsigned long long getIDforTable(const std::string &tableName)
Definition: idDealer.cc:18
idDealer.h
lumi::idDealer::idDealer
idDealer(coral::ISchema &schema)
Definition: idDealer.cc:14
LumiNames.h
HLT_Fake1_cff.tableName
tableName
Definition: HLT_Fake1_cff.py:10
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
lumi::idDealer::generateNextIDForTable
unsigned long long generateNextIDForTable(const std::string &tableName, unsigned int interval=1)
Definition: idDealer.cc:33
lumi::LumiNames::idTableName
static const std::string idTableName(const std::string &dataTableName)
Definition: LumiNames.cc:24
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
readEcalDQMStatus.interval
interval
Definition: readEcalDQMStatus.py:18
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
alignCSCRings.r
r
Definition: alignCSCRings.py:93
lumi::LumiNames
Definition: LumiNames.h:5
mps_fire.result
result
Definition: mps_fire.py:311
lumi
Definition: LumiSectionData.h:20