CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MultiRecordSelectOperation.cc
Go to the documentation of this file.
3 #include "RecordManip.h"
4 // externals
5 #include "CoralBase/Blob.h"
6 
8  coral::ISchema& schema ):
9  m_query( tableName, schema ),
10  m_idCols(),
11  m_cache(),
12  m_spec(),
13  m_row(){
14  //m_row( 0 ){
15 }
16 
18 }
19 
21  m_query.addOrderId( columnName );
22  m_idCols.push_back( columnName );
23 }
24 
25 void ora::MultiRecordSelectOperation::selectRow( const std::vector<int>& selection ){
26  if(!m_row.get())
27  throwException( "No row available.",
28  "MultiRecordSelectOperation::selectRow" );
29  //m_row = &m_cache.lookup( selection );
30  Record rec; m_cache.lookupAndClear( selection,rec );
31  newAttributeListFromRecord( *m_row, rec );
32 }
33 
35  size_t numberOfIndexes ){
36  if(m_cache.size()==0) return 0;
37  return m_cache.branchSize(selection, numberOfIndexes);
38 }
39 
41  m_row.reset();
42  //m_row = 0;
43  m_cache.clear();
44  //m_idCols.clear();
45  m_query.clear();
46 }
47 
49  m_spec.add( columnName, typeid(int) );
50  return m_query.addId( columnName );
51 }
52 
54  const std::type_info& columnType ){
55  m_spec.add( columnName, columnType );
56  return m_query.addData( columnName, columnType );
57 }
58 
60  m_spec.add( columnName, typeid(coral::Blob) );
61  return m_query.addBlobData( columnName );
62 }
63 
65  return m_query.addWhereId( columnName );
66 }
67 
68 coral::AttributeList& ora::MultiRecordSelectOperation::data(){
69  //if(!m_row){
70  if(!m_row.get()){
71  throwException( "No record available.",
72  "MultiRecordSelectOperation::data" );
73  }
74  return *m_row;
75 }
76 
78  return m_query.whereData();
79 }
80 
82  return m_query.whereClause();
83 }
84 
86  //m_row = 0;
87  // m_row.reset();
88  m_cache.clear();
89  m_query.execute();
90  std::vector<int> indexes;
91  while( m_query.nextCursorRow() ){
92  coral::AttributeList& row = m_query.data();
93  for(size_t i=0;i<m_idCols.size();i++){
94  indexes.push_back( row[m_idCols[i]].data<int>() );
95  }
96  Record rec(m_spec);
97  newRecordFromAttributeList(rec, row );
98  m_cache.push( indexes, rec );
99  indexes.clear();
100  }
101  m_row.reset(new coral::AttributeList(m_query.attributeListSpecification(), true ));
102  m_query.clear();
103 }
104 
105 
int i
Definition: DBlmapReader.cc:9
size_t selectionSize(const std::vector< int > &selection, size_t numberOfIndexes)
selection
main part
Definition: corrVsCorr.py:98
int addId(const std::string &columnName)
MultiRecordSelectOperation(const std::string &tableName, coral::ISchema &schema)
int addData(const std::string &columnName, const std::type_info &columnType)
int addWhereId(const std::string &columnName)
int addBlobData(const std::string &columnName)
void addOrderId(const std::string &columnName)
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
void selectRow(const std::vector< int > &selection)