ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PoolCollectionConverter Class Reference

This class provides an interface to POOL collections. More...

#include <PoolCollectionConverter.h>

Collaboration diagram for PoolCollectionConverter:

Public Member Functions

 PoolCollectionConverter (const std::string &collectionType, const std::string &inputCollection, unsigned int contextId, const std::string &query, const IPoolSvc *svc)
 Constructor. More...
 
virtual ~PoolCollectionConverter ()
 Destructor. More...
 
StatusCode initialize ()
 Required by all Gaudi Services. More...
 
StatusCode disconnectDb ()
 Disconnect Database. More...
 
StatusCode isValid () const
 Check whether has valid pool::ICollection*. More...
 
pool::ICollectionCursorselectAll ()
 
pool::ICollectionCursorexecuteQuery ()
 Query the collection. More...
 
std::string retrieveToken (const pool::ICollectionCursor *cursor, const std::string &refName) const
 

Private Member Functions

 PoolCollectionConverter (const PoolCollectionConverter &rhs)
 
PoolCollectionConverteroperator= (const PoolCollectionConverter &rhs)
 

Private Attributes

std::string m_collectionType
 
std::string m_connection
 
std::string m_inputCollection
 
unsigned int m_contextId
 
std::string m_query
 
const IPoolSvcm_poolSvc
 
pool::ICollectionm_poolCollection
 
pool::ICollectionQuerym_collectionQuery
 
std::string m_inputContainer
 

Detailed Description

This class provides an interface to POOL collections.

Definition at line 27 of file PoolCollectionConverter.h.

Constructor & Destructor Documentation

◆ PoolCollectionConverter() [1/2]

PoolCollectionConverter::PoolCollectionConverter ( const std::string &  collectionType,
const std::string &  inputCollection,
unsigned int  contextId,
const std::string &  query,
const IPoolSvc svc 
)

Constructor.

Parameters
collectionType[IN] type of the collection ("ExplicitROOT", "ExplicitMySQL", "ExplicitMySQLlt" or "ImplicitROOT").
inputCollection[IN] name of the collection.
query[IN] query string.
svc[IN] pointer to the PoolSvc.
contextId[IN] id for PoolSvc persistency service to use for input.

Definition at line 31 of file PoolCollectionConverter.cxx.

35  :
37  m_connection(),
38  m_inputCollection(inputCollection),
39  m_contextId(contextId),
40  m_query(query),
41  m_poolSvc(svc),
42  m_poolCollection(nullptr),
43  m_collectionQuery(nullptr),
45  // Find out if the user specified a container
46  std::string::size_type p_colon = collectionType.rfind(':');
47  if (p_colon != std::string::npos) {
48  m_inputContainer = collectionType.substr(p_colon + 1);
49  m_collectionType = collectionType.substr(0, p_colon);
50  } else {
51  // The user didn't specify any container. Using the default one.
52  m_inputContainer = "POOLContainer";
53  m_collectionType = collectionType;
54  }
55  std::string::size_type p_slash = m_inputContainer.find('/');
56  if (p_slash != std::string::npos) {
57  m_inputContainer.resize(p_slash);
58  }
59 }

◆ ~PoolCollectionConverter()

PoolCollectionConverter::~PoolCollectionConverter ( )
virtual

Destructor.

Definition at line 61 of file PoolCollectionConverter.cxx.

61  {
62  if (m_poolCollection) {
64  delete m_collectionQuery; m_collectionQuery = nullptr;
65  delete m_poolCollection; m_poolCollection = nullptr;
66  }
67 }

◆ PoolCollectionConverter() [2/2]

PoolCollectionConverter::PoolCollectionConverter ( const PoolCollectionConverter rhs)
private

Member Function Documentation

◆ disconnectDb()

StatusCode PoolCollectionConverter::disconnectDb ( )

Disconnect Database.

Definition at line 113 of file PoolCollectionConverter.cxx.

113  {
114  if (m_poolCollection == nullptr) {
115  return(StatusCode::SUCCESS);
116  }
117  if (m_poolCollection->description().type() == "ImplicitCollection") {
119  }
120  return(StatusCode::SUCCESS);
121 }

◆ executeQuery()

pool::ICollectionCursor & PoolCollectionConverter::executeQuery ( )

Query the collection.

Returns
ICollectionCursor over the results of the query

Definition at line 135 of file PoolCollectionConverter.cxx.

135  {
136  assert(m_poolCollection);
137  delete m_collectionQuery; m_collectionQuery = nullptr;
141  m_collectionQuery->setRowCacheSize(100); //MN: FIXME - just an arbitrary number
142  return(m_collectionQuery->execute());
143 }

◆ initialize()

StatusCode PoolCollectionConverter::initialize ( )

Required by all Gaudi Services.

Definition at line 69 of file PoolCollectionConverter.cxx.

69  {
70  std::string collectionTypeString;
71  if (m_collectionType == "ExplicitROOT") {
72  collectionTypeString = "RootCollection";
73  } else if (m_collectionType == "ImplicitROOT") {
74  collectionTypeString = "ImplicitCollection";
75  } else {
76  return(StatusCode::FAILURE);
77  }
78  if (collectionTypeString == "ImplicitCollection") {
79  // Check if already prefixed
80  if (m_inputCollection.starts_with( "PFN:")
81  || m_inputCollection.starts_with( "LFN:")
82  || m_inputCollection.starts_with( "FID:")) {
83  // Aready prefixed
85  } else {
86  // Prefix with PFN:
88  }
89  try {
91  } catch (std::exception &e) {
92  m_poolCollection = nullptr;
93  }
94  if (m_poolCollection == nullptr) {
95  // Now set where to look in the implicit file
96  m_inputCollection = m_inputContainer + "(DataHeader)";
97  }
98  }
99  try {
100  if (m_poolCollection == nullptr) {
102  }
103  if (m_poolCollection == nullptr && collectionTypeString == "ImplicitCollection") {
104  m_inputCollection = m_inputContainer + "_DataHeader";
106  }
107  } catch (std::exception &e) {
108  return(StatusCode::RECOVERABLE);
109  }
110  return(StatusCode::SUCCESS);
111 }

◆ isValid()

StatusCode PoolCollectionConverter::isValid ( ) const

Check whether has valid pool::ICollection*.

Definition at line 123 of file PoolCollectionConverter.cxx.

123  {
124  return(m_poolCollection != nullptr ? StatusCode::SUCCESS : StatusCode::FAILURE);
125 }

◆ operator=()

PoolCollectionConverter& PoolCollectionConverter::operator= ( const PoolCollectionConverter rhs)
private

◆ retrieveToken()

std::string PoolCollectionConverter::retrieveToken ( const pool::ICollectionCursor cursor,
const std::string &  refName 
) const
Parameters
it[IN] collection iterator.
refName[IN] attribute name.

Definition at line 145 of file PoolCollectionConverter.cxx.

146  {
147 // Retrieve the DataHeader Token from POOL.
148 // If header name is non-zero, then search the attibute list for
149 // the corresponding ref. Otherwise, use the main token
150  std::string tokenStr;
151  if (!refName.empty()) {
152  std::string attrName = refName + "_ref";
153  try {
154  tokenStr = cursor->currentRow().tokenList()[attrName].toString();
155  } catch (...) {
156  // check also in attributes, for backward compatibility
157  try {
158  tokenStr = cursor->currentRow().attributeList()[attrName].data<std::string>();
159  } catch (std::exception& e) {
160  return("");
161  }
162  }
163  } else {
164  tokenStr = cursor->eventRef().toString();
165  }
166  return(tokenStr);
167 }

◆ selectAll()

pool::ICollectionCursor & PoolCollectionConverter::selectAll ( )
Returns
ICollectionCursor over all entries

Definition at line 127 of file PoolCollectionConverter.cxx.

127  {
128  assert(m_poolCollection);
129  delete m_collectionQuery; m_collectionQuery = nullptr;
131  m_collectionQuery->setRowCacheSize(100); //MN: FIXME - just an arbitrary number
132  return(m_collectionQuery->execute());
133 }

Member Data Documentation

◆ m_collectionQuery

pool::ICollectionQuery* PoolCollectionConverter::m_collectionQuery
private

Definition at line 74 of file PoolCollectionConverter.h.

◆ m_collectionType

std::string PoolCollectionConverter::m_collectionType
private

Definition at line 67 of file PoolCollectionConverter.h.

◆ m_connection

std::string PoolCollectionConverter::m_connection
private

Definition at line 68 of file PoolCollectionConverter.h.

◆ m_contextId

unsigned int PoolCollectionConverter::m_contextId
private

Definition at line 70 of file PoolCollectionConverter.h.

◆ m_inputCollection

std::string PoolCollectionConverter::m_inputCollection
private

Definition at line 69 of file PoolCollectionConverter.h.

◆ m_inputContainer

std::string PoolCollectionConverter::m_inputContainer
private

Definition at line 75 of file PoolCollectionConverter.h.

◆ m_poolCollection

pool::ICollection* PoolCollectionConverter::m_poolCollection
private

Definition at line 73 of file PoolCollectionConverter.h.

◆ m_poolSvc

const IPoolSvc* PoolCollectionConverter::m_poolSvc
private

Definition at line 72 of file PoolCollectionConverter.h.

◆ m_query

std::string PoolCollectionConverter::m_query
private

Definition at line 71 of file PoolCollectionConverter.h.


The documentation for this class was generated from the following files:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
PoolCollectionConverter::m_contextId
unsigned int m_contextId
Definition: PoolCollectionConverter.h:70
PoolCollectionConverter::m_connection
std::string m_connection
Definition: PoolCollectionConverter.h:68
pool::ICollectionQuery::execute
virtual pool::ICollectionCursor & execute()=0
Processes the query and returns a cursor over the query result.
pool::ICollection::close
virtual void close()=0
Closes the collection and terminates any database connections.
PoolCollectionConverter::m_collectionType
std::string m_collectionType
Definition: PoolCollectionConverter.h:67
pool::ICollectionDescription::type
virtual const std::string & type() const =0
Returns the storage technology type of the collection.
pool::ICollectionQuery::selectAll
virtual void selectAll()=0
Adds all Token and Attribute columns to the query select list.
PoolCollectionConverter::m_inputCollection
std::string m_inputCollection
Definition: PoolCollectionConverter.h:69
PoolCollectionConverter::m_inputContainer
std::string m_inputContainer
Definition: PoolCollectionConverter.h:75
pool::ICollection::newQuery
virtual ICollectionQuery * newQuery()=0
Returns an object used to query the collection.
query
Definition: query.py:1
PoolCollectionConverter::m_poolSvc
const IPoolSvc * m_poolSvc
Definition: PoolCollectionConverter.h:72
calibdata.exception
exception
Definition: calibdata.py:496
pool::ICollection::description
virtual const ICollectionDescription & description() const =0
Returns an object used to describe the collection properties.
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
PoolCollectionConverter::m_query
std::string m_query
Definition: PoolCollectionConverter.h:71
PoolCollectionConverter::m_collectionQuery
pool::ICollectionQuery * m_collectionQuery
Definition: PoolCollectionConverter.h:74
pool::ICollectionQuery::setCondition
virtual void setCondition(const std::string &whereClause, coral::AttributeList *attributeBindData=0, TokenList *tokenBindData=0)=0
Sets the predicates of the query.
PoolCollectionConverter::m_poolCollection
pool::ICollection * m_poolCollection
Definition: PoolCollectionConverter.h:73
python.PoolAttributeHelper.attrName
attrName
Definition: PoolAttributeHelper.py:100
query_example.cursor
cursor
Definition: query_example.py:21
IPoolSvc::disconnectDb
virtual StatusCode disconnectDb(const std::string &connection, unsigned int contextId=IPoolSvc::kInputStream) const =0
Disconnect single Database.
pool::ICollectionQuery::setRowCacheSize
virtual void setRowCacheSize(int rowCacheSize)=0
Sets the cache size used to store the query result.
IPoolSvc::createCollection
virtual pool::ICollection * createCollection(const std::string &collectionType, const std::string &connection, const std::string &collectionName, unsigned int contextId=IPoolSvc::kInputStream) const =0