CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
ora::OraPtrReadBuffer Class Reference

Public Member Functions

bool build (DataElement &dataElement)
 
 OraPtrReadBuffer (const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
 
void * read (const std::vector< int > &fullId)
 
 ~OraPtrReadBuffer ()
 

Private Attributes

DataElementm_dataElement
 
DataElement m_localElement
 
MappingElementm_mapping
 
edm::TypeWithDict m_objectType
 
SelectOperation m_query
 
std::auto_ptr< IRelationalReaderm_reader
 
ContainerSchemam_schema
 

Detailed Description

Definition at line 16 of file OraPtrStreamer.cc.

Constructor & Destructor Documentation

ora::OraPtrReadBuffer::OraPtrReadBuffer ( const edm::TypeWithDict objectType,
MappingElement mapping,
ContainerSchema contSchema 
)
inline

Definition at line 18 of file OraPtrStreamer.cc.

18  :
19  m_objectType( objectType ),
20  m_mapping( mapping ),
21  m_schema( contSchema ),
23  m_query( mapping.tableName(), contSchema.storageSchema() ),
24  m_dataElement( 0 ),
25  m_reader(){
26  }
DataElement * m_dataElement
std::auto_ptr< IRelationalReader > m_reader
SelectOperation m_query
edm::TypeWithDict m_objectType
MappingElement & m_mapping
ContainerSchema & m_schema
ora::OraPtrReadBuffer::~OraPtrReadBuffer ( )
inline

Definition at line 28 of file OraPtrStreamer.cc.

28  {
29  }

Member Function Documentation

bool ora::OraPtrReadBuffer::build ( DataElement dataElement)
inline

Definition at line 31 of file OraPtrStreamer.cc.

References ora::SelectOperation::addWhereId(), ora::DataElement::clear(), ora::MappingElement::columnNames(), edm::TypeWithDict::cppName(), ora::MappingElement::end(), ora::MappingElement::find(), i, m_dataElement, m_localElement, m_mapping, m_objectType, m_query, m_reader, m_schema, edm::TypeWithDict::name(), ora::RelationalStreamerFactory::newReader(), ora::ClassUtils::resolvedType(), AlCaHLTBitMon_QueryRunRegistry::string, edm::TypeWithDict::templateArgumentAt(), and ora::throwException().

Referenced by psClasses.BuildThread::run().

31  {
32  m_dataElement = &dataElement;
34 
35  const std::vector<std::string>& columns = m_mapping.columnNames();
36  size_t cols = columns.size();
37  for( size_t i=0; i<cols; i++ ){
38  m_query.addWhereId( columns[ i ] );
39  }
40 
41  // Check the type
43  edm::TypeWithDict ptrResolvedType = ClassUtils::resolvedType(ptrType);
44  // Check the component type
45  if ( ! ptrType || !ptrResolvedType ) {
46  throwException( "Missing dictionary information for the type of the pointer \"" +
47  m_objectType.cppName() + "\"",
48  "OraPtrReadBuffer::build" );
49  }
50 
51  std::string ptrTypeName = ptrType.name();
52  // Retrieve the relevant mapping element
53  MappingElement::iterator iMe = m_mapping.find( ptrTypeName );
54  if ( iMe == m_mapping.end() ) {
55  throwException( "Item for \"" + ptrTypeName + "\" not found in the mapping element",
56  "OraPtrReadBuffer::build" );
57  }
58  RelationalStreamerFactory streamerFactory( m_schema );
59  m_reader.reset( streamerFactory.newReader( ptrResolvedType, iMe->second ) );
60  return m_reader->build( m_localElement, m_query );
61  }
int i
Definition: DBlmapReader.cc:9
edm::TypeWithDict resolvedType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:486
DataElement * m_dataElement
std::auto_ptr< IRelationalReader > m_reader
int addWhereId(const std::string &columnName)
TypeWithDict templateArgumentAt(size_t index) const
std::string name() const
std::string cppName() const
SelectOperation m_query
iterator find(const std::string &key)
Retrieves a sub-element.
std::map< std::string, MappingElement >::iterator iterator
Iterator definition.
const std::vector< std::string > & columnNames() const
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
iterator end()
Returns an iterator in the end of the sequence.
edm::TypeWithDict m_objectType
MappingElement & m_mapping
ContainerSchema & m_schema
void* ora::OraPtrReadBuffer::read ( const std::vector< int > &  fullId)
inline

Definition at line 63 of file OraPtrStreamer.cc.

References ora::SelectOperation::clear(), ora::ClassUtils::constructObject(), cmsStageWithFailover::destination, ora::SelectOperation::execute(), i, m_dataElement, m_objectType, m_query, m_reader, ora::SelectOperation::nextCursorRow(), edm::TypeWithDict::templateArgumentAt(), ora::throwException(), and ora::SelectOperation::whereData().

Referenced by edmIntegrityCheck.PublishToFileSystem::get(), Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::goto(), ora::RelationalPtrLoader::load(), and Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::setFilterBranches().

63  {
64  if(!m_dataElement) throwException( "Read buffer has not been built.","OraPtrReadBuffer::read");
65 
66  if(!fullId.size()) throwException( "Object id set is empty.","OraPtrReadBuffer::read");
67 
68  coral::AttributeList& whereBuff = m_query.whereData();
69  coral::AttributeList::iterator iCol = whereBuff.begin();
70  size_t i=0;
71  for( coral::AttributeList::iterator iCol = whereBuff.begin(); iCol != whereBuff.end(); ++iCol ){
72  if( i<fullId.size() ){
73  iCol->data<int>() = fullId[i];
74  }
75  i++;
76  }
77 
78  std::vector<int> recordId( fullId.size()-1 );
79  for( size_t i=0; i<fullId.size()-1; i++ ){
80  recordId[i] = fullId[i+1];
81  ++i;
82  }
83 
84  m_query.execute();
85  m_reader->select( fullId[0] );
86  void* destination = 0;
87  if( m_query.nextCursorRow() ){
89  m_reader->setRecordId( recordId );
90  m_reader->read( destination );
91  }
92  m_query.clear();
93  m_reader->clear();
94  return destination;
95  }
int i
Definition: DBlmapReader.cc:9
DataElement * m_dataElement
std::auto_ptr< IRelationalReader > m_reader
TypeWithDict templateArgumentAt(size_t index) const
SelectOperation m_query
coral::AttributeList & whereData()
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
void * constructObject(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:205
edm::TypeWithDict m_objectType

Member Data Documentation

DataElement* ora::OraPtrReadBuffer::m_dataElement
private

Definition at line 103 of file OraPtrStreamer.cc.

Referenced by build(), and read().

DataElement ora::OraPtrReadBuffer::m_localElement
private

Definition at line 101 of file OraPtrStreamer.cc.

Referenced by build().

MappingElement& ora::OraPtrReadBuffer::m_mapping
private

Definition at line 99 of file OraPtrStreamer.cc.

Referenced by build().

edm::TypeWithDict ora::OraPtrReadBuffer::m_objectType
private

Definition at line 98 of file OraPtrStreamer.cc.

Referenced by build(), and read().

SelectOperation ora::OraPtrReadBuffer::m_query
private

Definition at line 102 of file OraPtrStreamer.cc.

Referenced by build(), and read().

std::auto_ptr<IRelationalReader> ora::OraPtrReadBuffer::m_reader
private

Definition at line 104 of file OraPtrStreamer.cc.

Referenced by build(), and read().

ContainerSchema& ora::OraPtrReadBuffer::m_schema
private

Definition at line 100 of file OraPtrStreamer.cc.

Referenced by build().