1 #ifndef CondTools_L1Trigger_OMDSReader_h 2 #define CondTools_L1Trigger_OMDSReader_h 27 #include "RelationalAccess/IQuery.h" 28 #include "CoralBase/AttributeList.h" 29 #include "CoralBase/AttributeSpecification.h" 30 #include "CoralBase/Attribute.h" 32 #include "RelationalAccess/ITable.h" 33 #include "RelationalAccess/IView.h" 34 #include "RelationalAccess/ISchema.h" 35 #include "RelationalAccess/ISessionProxy.h" 36 #include "RelationalAccess/ICursor.h" 201 coral::ISchema& schema = schemaName.empty() ? coralSession.nominalSchema() : coralSession.schema(schemaName);
206 std::shared_ptr<coral::IQuery>
query(
table.newQuery());
209 std::vector<std::string>::const_iterator
it =
columnNames.begin();
210 std::vector<std::string>::const_iterator end =
columnNames.end();
211 for (;
it != end; ++
it) {
216 if (!conditionLHS.empty() && conditionRHS.
numberRows() == 1) {
217 if (!conditionRHSName.empty()) {
219 coral::AttributeList attList;
220 attList.extend(conditionRHSName,
typeid(
T));
223 attList[conditionRHSName].data<
T>() =
tmp;
225 query->setCondition(conditionLHS +
" = :" + conditionRHSName, attList);
229 query->setCondition(conditionLHS +
" = :" + conditionRHS.
columnNames().front(),
234 coral::ICursor& cursor =
query->execute();
238 std::vector<coral::AttributeList> atts;
239 while (cursor.next()) {
240 atts.push_back(cursor.currentRow());
255 return basicQueryGenericKey<T>(
columnNames, schemaName,
tableName, conditionLHS, conditionRHS, conditionRHSName);
260 std::vector<std::string>
names;
261 names.push_back(
"dummy");
263 coral::AttributeList attList;
264 attList.extend(
"dummy",
typeid(
T));
265 attList[
"dummy"].data<
T>() =
data;
267 std::vector<coral::AttributeList> atts;
268 atts.push_back(attList);
281 T& outputVariable)
const {
283 if (rowNumber < 0 || rowNumber >= numberRows())
285 const coral::AttributeList& row = m_attributeLists[rowNumber];
286 if (row[columnName].isNull())
288 outputVariable = row[columnName].template data<T>();
294 return fillVariableFromRow(0, outputVariable);
300 if (rowNumber < 0 || rowNumber >= numberRows() || m_columnNames.size() != 1)
302 const coral::AttributeList& row = m_attributeLists[rowNumber];
303 if (row[m_columnNames.front()].isNull())
305 outputVariable = row[m_columnNames.front()].template data<T>();
const QueryResults singleAttribute(const T &data) const
const std::string names[nVars_]
const QueryResults basicQueryGenericKey(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &tableName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="")
const std::vector< coral::AttributeList > & attributeLists() const
QueryResults(const std::vector< std::string > &columnNames, const std::vector< coral::AttributeList > &attLists)
std::vector< std::string > columnNames(const std::string &schemaName, const std::string &tableName)
const QueryResults basicQuery(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &tableName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="")
const std::vector< std::string > & columnNames() const
bool fillVariableFromRow(const std::string &columnName, int rowNumber, T &outputVariable) const
bool fillVariable(const std::string &columnName, T &outputVariable) const
void connect(const std::string &connectString, const std::string &authenticationPath)
std::vector< std::string > columnNamesView(const std::string &schemaName, const std::string &viewName)
const QueryResults basicQueryView(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &viewName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="")
coral::ISessionProxy & coralSession()
char data[epos_bytes_allocation]
const OMDSReader & operator=(const OMDSReader &)=delete
std::vector< coral::AttributeList > m_attributeLists
cond::persistency::Session session
std::vector< std::string > m_columnNames