CMS 3D CMS Logo

Public Member Functions | Private Attributes

ora::SelectOperation Class Reference

#include <RelationalOperation.h>

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

List of all members.

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 ()

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.

                                                             :
  m_spec( new coral::AttributeListSpecification ),
  m_whereData(),
  m_whereClause(""),
  m_orderByCols(),
  m_query(),
  m_cursor( 0 ),
  m_tableName( tableName ),
  m_schema( schema ){
}
ora::SelectOperation::~SelectOperation ( )

Definition at line 253 of file RelationalOperation.cc.

                                    {
  m_spec->release();
}

Member Function Documentation

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

Implements ora::IRelationalData.

Definition at line 294 of file RelationalOperation.cc.

References UserOptions_cff::idx.

                                                               {
  int idx = m_spec->index( columnName );
  if( idx == -1){
    m_spec->extend<coral::Blob>( columnName );
    idx = m_spec->size()-1;
  }
  return idx;
}
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 UserOptions_cff::idx.

                                                                  {
  int idx = m_spec->index( columnName );
  if( idx == -1){
    m_spec->extend( columnName, columnType );
    idx = m_spec->size()-1;
  }
  return idx;
}
int ora::SelectOperation::addId ( const std::string &  columnName) [virtual]

Implements ora::IRelationalData.

Definition at line 275 of file RelationalOperation.cc.

References UserOptions_cff::idx.

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

                                                        {
  int idx = m_spec->index( columnName );
  if( idx == -1){
    m_spec->extend< int >( columnName );
    idx = m_spec->size()-1;
  }
  return idx;
}
void ora::SelectOperation::addOrderId ( const std::string &  columnName)

Definition at line 257 of file RelationalOperation.cc.

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

                                                              {
  m_orderByCols.push_back( columnName );
}
int ora::SelectOperation::addWhereId ( const std::string &  columnName) [virtual]

Implements ora::IRelationalData.

Definition at line 303 of file RelationalOperation.cc.

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

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

                                                               {
  int index = existAttribute( columnName, m_whereData );
  if( index == -1){
    m_whereData.extend<int>( columnName );
    index = m_whereData.size()-1;
    if(!m_whereClause.empty()) m_whereClause += " AND ";
    m_whereClause += ( columnName +"= :"+columnName );
  }
  return index;
}
coral::AttributeListSpecification & ora::SelectOperation::attributeListSpecification ( )

Definition at line 346 of file RelationalOperation.cc.

                                                                               {
  return *m_spec;
}
void ora::SelectOperation::clear ( void  )

Definition at line 270 of file RelationalOperation.cc.

Referenced by ora::ReadBuffer::read().

                              {
  m_query.reset();
  m_cursor = 0;
}
coral::AttributeList & ora::SelectOperation::data ( ) [virtual]

Implements ora::IRelationalData.

Definition at line 314 of file RelationalOperation.cc.

References ora::throwException().

                                            {
  if(!m_cursor) throwException( "Query on table "+m_tableName+" has not been executed.",
                                "ora::ReadOperation::data" );
  return const_cast<coral::AttributeList&>(m_cursor->currentRow());
}
void ora::SelectOperation::execute ( )

Definition at line 328 of file RelationalOperation.cc.

References asciidump::table.

Referenced by ora::ReadBuffer::read().

                                {
  m_cursor = 0;
  coral::ITable& table = m_schema.tableHandle( m_tableName );
  m_query.reset( table.newQuery() );
  for ( coral::AttributeListSpecification::const_iterator iSpec = m_spec->begin();
        iSpec != m_spec->end(); ++iSpec ) {
    m_query->addToOutputList( iSpec->name() );
    m_query->defineOutputType( iSpec->name(),iSpec->typeName());
  }
  for(std::vector<std::string>::iterator iCol = m_orderByCols.begin();
      iCol != m_orderByCols.end(); iCol++ ){
    m_query->addToOrderList( *iCol );
  }
  m_query->setCondition( m_whereClause, m_whereData );
  m_query->setRowCacheSize( 100 ); // We should better define this value !!!
  m_cursor = &m_query->execute();
}
bool ora::SelectOperation::nextCursorRow ( )

Definition at line 261 of file RelationalOperation.cc.

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

Referenced by ora::ReadBuffer::read().

                                      {
  bool ret = false;
  if( m_query.get() ){
    ret = m_cursor->next();
    if(!ret) clear();
  }
  return ret;
}
std::string & ora::SelectOperation::whereClause ( ) [virtual]

Implements ora::IRelationalData.

Definition at line 324 of file RelationalOperation.cc.

                                          {
  return m_whereClause;
}
coral::AttributeList & ora::SelectOperation::whereData ( ) [virtual]

Implements ora::IRelationalData.

Definition at line 320 of file RelationalOperation.cc.

Referenced by ora::ReadBuffer::read().

                                                 {
  return 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.