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::SelectOperation Class Reference

#include <RelationalOperation.h>

Inheritance diagram for ora::SelectOperation:
ora::IRelationalData

Public Member Functions

int addBlobData (const std::string &columnName)
 
int addData (const std::string &columnName, const std::type_info &columnType)
 
int addId (const std::string &columnName)
 
void addOrderId (const std::string &columnName)
 
int addWhereId (const std::string &columnName)
 
coral::AttributeListSpecification & attributeListSpecification ()
 
void clear ()
 
coral::AttributeList & data ()
 
void execute ()
 
bool nextCursorRow ()
 
 SelectOperation (const std::string &tableName, coral::ISchema &schema)
 
std::string & whereClause ()
 
coral::AttributeList & whereData ()
 
 ~SelectOperation ()
 
- Public Member Functions inherited from ora::IRelationalData
virtual ~IRelationalData ()
 

Private Attributes

coral::ICursor * m_cursor
 
std::vector< std::string > m_orderByCols
 
std::auto_ptr< coral::IQuery > m_query
 
coral::ISchema & m_schema
 
coral::AttributeListSpecification * m_spec
 
std::string m_tableName
 
std::string m_whereClause
 
coral::AttributeList m_whereData
 

Detailed Description

Definition at line 159 of file RelationalOperation.h.

Constructor & Destructor Documentation

ora::SelectOperation::SelectOperation ( const std::string &  tableName,
coral::ISchema &  schema 
)
explicit

Definition at line 241 of file RelationalOperation.cc.

242  :
243  m_spec( new coral::AttributeListSpecification ),
244  m_whereData(),
245  m_whereClause(""),
246  m_orderByCols(),
247  m_query(),
248  m_cursor( 0 ),
250  m_schema( schema ){
251 }
std::auto_ptr< coral::IQuery > m_query
coral::AttributeListSpecification * m_spec
coral::ISchema & m_schema
coral::ICursor * m_cursor
coral::AttributeList m_whereData
std::vector< std::string > m_orderByCols
ora::SelectOperation::~SelectOperation ( )

Definition at line 253 of file RelationalOperation.cc.

253  {
254  m_spec->release();
255 }
coral::AttributeListSpecification * m_spec

Member Function Documentation

int ora::SelectOperation::addBlobData ( const std::string &  columnName)
virtual

Implements ora::IRelationalData.

Definition at line 294 of file RelationalOperation.cc.

References customizeTrackingMonitorSeedNumber::idx.

294  {
295  int idx = m_spec->index( columnName );
296  if( idx == -1){
297  m_spec->extend<coral::Blob>( columnName );
298  idx = m_spec->size()-1;
299  }
300  return idx;
301 }
coral::AttributeListSpecification * m_spec
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
int ora::SelectOperation::addData ( const std::string &  columnName,
const std::type_info &  columnType 
)
virtual

Implements ora::IRelationalData.

Definition at line 284 of file RelationalOperation.cc.

References customizeTrackingMonitorSeedNumber::idx.

285  {
286  int idx = m_spec->index( columnName );
287  if( idx == -1){
288  m_spec->extend( columnName, columnType );
289  idx = m_spec->size()-1;
290  }
291  return idx;
292 }
coral::AttributeListSpecification * m_spec
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
int ora::SelectOperation::addId ( const std::string &  columnName)
virtual

Implements ora::IRelationalData.

Definition at line 275 of file RelationalOperation.cc.

References customizeTrackingMonitorSeedNumber::idx.

Referenced by ora::IteratorBuffer::IteratorBuffer().

275  {
276  int idx = m_spec->index( columnName );
277  if( idx == -1){
278  m_spec->extend< int >( columnName );
279  idx = m_spec->size()-1;
280  }
281  return idx;
282 }
coral::AttributeListSpecification * m_spec
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
void ora::SelectOperation::addOrderId ( const std::string &  columnName)

Definition at line 257 of file RelationalOperation.cc.

Referenced by ora::IteratorBuffer::IteratorBuffer().

257  {
258  m_orderByCols.push_back( columnName );
259 }
std::vector< std::string > m_orderByCols
int ora::SelectOperation::addWhereId ( const std::string &  columnName)
virtual

Implements ora::IRelationalData.

Definition at line 303 of file RelationalOperation.cc.

References ora::existAttribute(), and cmsHarvester::index.

Referenced by ora::OraPtrReadBuffer::build(), and ora::ReadBuffer::ReadBuffer().

303  {
304  int index = existAttribute( columnName, m_whereData );
305  if( index == -1){
306  m_whereData.extend<int>( columnName );
307  index = m_whereData.size()-1;
308  if(!m_whereClause.empty()) m_whereClause += " AND ";
309  m_whereClause += ( columnName +"= :"+columnName );
310  }
311  return index;
312 }
int existAttribute(const std::string &attributeName, const coral::AttributeList &data)
coral::AttributeList m_whereData
coral::AttributeListSpecification & ora::SelectOperation::attributeListSpecification ( )

Definition at line 346 of file RelationalOperation.cc.

346  {
347  return *m_spec;
348 }
coral::AttributeListSpecification * m_spec
void ora::SelectOperation::clear ( void  )
coral::AttributeList & ora::SelectOperation::data ( )
virtual

Implements ora::IRelationalData.

Definition at line 314 of file RelationalOperation.cc.

References ora::throwException().

Referenced by cuy.FindIssue::__init__().

314  {
315  if(!m_cursor) throwException( "Query on table "+m_tableName+" has not been executed.",
316  "ora::ReadOperation::data" );
317  return const_cast<coral::AttributeList&>(m_cursor->currentRow());
318 }
coral::ICursor * m_cursor
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
void ora::SelectOperation::execute ( )

Definition at line 328 of file RelationalOperation.cc.

References table.

Referenced by ora::OraPtrReadBuffer::read(), and ora::ReadBuffer::read().

328  {
329  m_cursor = 0;
330  coral::ITable& table = m_schema.tableHandle( m_tableName );
331  m_query.reset( table.newQuery() );
332  for ( coral::AttributeListSpecification::const_iterator iSpec = m_spec->begin();
333  iSpec != m_spec->end(); ++iSpec ) {
334  m_query->addToOutputList( iSpec->name() );
335  m_query->defineOutputType( iSpec->name(),iSpec->typeName());
336  }
337  for(std::vector<std::string>::iterator iCol = m_orderByCols.begin();
338  iCol != m_orderByCols.end(); iCol++ ){
339  m_query->addToOrderList( *iCol );
340  }
341  m_query->setCondition( m_whereClause, m_whereData );
342  m_query->setRowCacheSize( 100 ); // We should better define this value !!!
343  m_cursor = &m_query->execute();
344 }
std::auto_ptr< coral::IQuery > m_query
coral::AttributeListSpecification * m_spec
#define table(NAME)
Definition: DbCore.h:49
coral::ISchema & m_schema
coral::ICursor * m_cursor
coral::AttributeList m_whereData
std::vector< std::string > m_orderByCols
bool ora::SelectOperation::nextCursorRow ( )

Definition at line 261 of file RelationalOperation.cc.

References hitfit::clear(), and run_regression::ret.

Referenced by ora::OraPtrReadBuffer::read(), and ora::ReadBuffer::read().

261  {
262  bool ret = false;
263  if( m_query.get() ){
264  ret = m_cursor->next();
265  if(!ret) clear();
266  }
267  return ret;
268 }
std::auto_ptr< coral::IQuery > m_query
coral::ICursor * m_cursor
std::string & ora::SelectOperation::whereClause ( )
virtual

Implements ora::IRelationalData.

Definition at line 324 of file RelationalOperation.cc.

324  {
325  return m_whereClause;
326 }
coral::AttributeList & ora::SelectOperation::whereData ( )
virtual

Implements ora::IRelationalData.

Definition at line 320 of file RelationalOperation.cc.

Referenced by ora::OraPtrReadBuffer::read(), and ora::ReadBuffer::read().

320  {
321  return m_whereData;
322 }
coral::AttributeList m_whereData

Member Data Documentation

coral::ICursor* ora::SelectOperation::m_cursor
private

Definition at line 190 of file RelationalOperation.h.

std::vector<std::string> ora::SelectOperation::m_orderByCols
private

Definition at line 188 of file RelationalOperation.h.

std::auto_ptr<coral::IQuery> ora::SelectOperation::m_query
private

Definition at line 189 of file RelationalOperation.h.

coral::ISchema& ora::SelectOperation::m_schema
private

Definition at line 192 of file RelationalOperation.h.

coral::AttributeListSpecification* ora::SelectOperation::m_spec
private

Definition at line 185 of file RelationalOperation.h.

std::string ora::SelectOperation::m_tableName
private

Definition at line 191 of file RelationalOperation.h.

std::string ora::SelectOperation::m_whereClause
private

Definition at line 187 of file RelationalOperation.h.

coral::AttributeList ora::SelectOperation::m_whereData
private

Definition at line 186 of file RelationalOperation.h.