![]() |
![]() |
00001 #ifndef INCLUDE_ORA_MULTIRECORDINSERTOPERATION_H 00002 #define INCLUDE_ORA_MULTIRECORDINSERTOPERATION_H 00003 00004 #include "CondCore/ORA/interface/Record.h" 00005 #include "RelationalOperation.h" 00006 00007 #define INSERTCACHESIZE 50000 00008 00009 namespace coral { 00010 class AttibuteList; 00011 } 00012 00013 namespace ora { 00014 00015 class InsertCache { 00016 public: 00017 InsertCache( const RecordSpec& m_spec, const coral::AttributeList& data ); 00018 ~InsertCache(); 00019 void processNextIteration(); 00020 const std::vector<Record*>& records() const; 00021 private: 00022 const RecordSpec& m_spec; 00023 std::vector<Record*> m_records; 00024 const coral::AttributeList& m_data; 00025 }; 00026 00027 class MultiRecordInsertOperation : public IRelationalData, public IRelationalOperation { 00028 public: 00029 MultiRecordInsertOperation( const std::string& tableName, coral::ISchema& schema ); 00030 ~MultiRecordInsertOperation(); 00031 InsertCache& setUp( int rowCacheSize ); 00032 00033 public: 00034 void addId( const std::string& columnName ); 00035 void addData( const std::string& columnName, const std::type_info& columnType ); 00036 void addBlobData(const std::string& columnName); 00037 void addWhereId( const std::string& columnName ); 00038 coral::AttributeList& data(); 00039 coral::AttributeList& whereData(); 00040 std::string& whereClause(); 00041 00042 public: 00043 bool isRequired(); 00044 bool execute(); 00045 void reset(); 00046 private: 00047 InputRelationalData m_relationalData; 00048 RecordSpec m_spec; 00049 std::string m_tableName; 00050 coral::ISchema& m_schema; 00051 std::vector<InsertCache*> m_bulkInserts; 00052 }; 00053 } 00054 00055 #endif