ATLAS Offline Software
TrigDBHelper.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 
4 #include "./TrigDBHelper.h"
5 
6 #include "RelationalAccess/ISchema.h"
7 #include <iostream>
8 
9 std::unique_ptr< coral::IQuery >
10 TrigConf::QueryDefinition::createQuery( coral::ISessionProxy * session )
11 {
12 
13  std::unique_ptr< coral::IQuery > query( session->nominalSchema().newQuery() );
14 
15  // set tables
16  for( auto & table : m_tables ) {
17  query->addToTableList( table.first, table.second );
18  }
19 
20  // ensure that all the requested variables are bound
21  for( auto & bindVar : m_bindList ) {
22  const std::string & fieldName = bindVar.specification().name();
23  if( m_bound.find( fieldName ) == m_bound.end() ) {
24  throw std::runtime_error( "Column " + fieldName + " has been bound, but not set to a value" );
25  }
26  }
27 
28  // condition
29  query->setCondition( m_condition, m_bindList );
30 
31  // output
32  query->defineOutput( m_attList );
33  for( const coral::Attribute & attr : m_attList ) {
34  query->addToOutputList(attr.specification().name());
35  }
36 
37  return query;
38 }
39 
40 
41 void
42 TrigConf::QueryDefinition::addToTableList(const std::string & table, const std::string & table_short)
43 {
44  m_tables.emplace_back(table, table_short);
45 }
46 
47 void
48 TrigConf::QueryDefinition::extendCondition(const std::string & condext) {
49  if( m_condition.size()>0 && condext.size()>0 && m_condition.back() != ' ' && condext[0] != ' ') {
50  m_condition += " ";
51  }
52  m_condition += condext;
53 }
54 
55 
56 
57 void
59  boost::iostreams::stream<boost::iostreams::array_source> stream( static_cast<const char*> ( blob.startingAddress()),
60  blob.size());
61  boost::property_tree::read_json(stream, pt);
62 }
TrigConf::QueryDefinition::m_condition
std::string m_condition
Definition: TrigDBHelper.h:57
test_pyathena.pt
pt
Definition: test_pyathena.py:11
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
query
Definition: query.py:1
taskman.fieldName
fieldName
Definition: taskman.py:492
TrigConf::QueryDefinition::m_attList
coral::AttributeList m_attList
Definition: TrigDBHelper.h:58
TrigConf::QueryDefinition::createQuery
std::unique_ptr< coral::IQuery > createQuery(coral::ISessionProxy *session)
Definition: TrigDBHelper.cxx:10
query_example.query
query
Definition: query_example.py:15
TrigConf::QueryDefinition::m_bindList
coral::AttributeList m_bindList
Definition: TrigDBHelper.h:59
ptree
boost::property_tree::ptree ptree
Definition: JsonFileLoader.cxx:16
python.ext.table_printer.table
list table
Definition: table_printer.py:81
TrigConf::QueryDefinition::extendCondition
void extendCondition(const std::string &condext)
Definition: TrigDBHelper.cxx:48
TrigConf::QueryDefinition::m_tables
std::vector< std::pair< std::string, std::string > > m_tables
Definition: TrigDBHelper.h:56
TrigConf::blobToPtree
void blobToPtree(const coral::Blob &blob, boost::property_tree::ptree &pt)
Definition: TrigDBHelper.cxx:58
TrigConf::QueryDefinition::m_bound
std::set< std::string > m_bound
Definition: TrigDBHelper.h:61
TrigDBHelper.h
TrigConf::QueryDefinition::addToTableList
void addToTableList(const std::string &table, const std::string &table_short="")
Definition: TrigDBHelper.cxx:42
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96