CMS 3D CMS Logo

DbCore.h
Go to the documentation of this file.
1 #ifndef CondCore_ConditionDatabase_DbCore_h
2 #define CondCore_ConditionDatabase_DbCore_h
3 //
4 // Package: CondDB
5 // Class : DbCore
6 //
10 //
11 // Author: Miguel Ojeda, Giacomo Govi
12 // Created: May 2013
13 //
14 //
15 
20 // coral includes
21 #include "CoralBase/AttributeList.h"
22 #include "CoralBase/Attribute.h"
23 #include "CoralBase/AttributeSpecification.h"
24 #include "CoralBase/Blob.h"
25 #include "CoralBase/TimeStamp.h"
26 #include "RelationalAccess/ICursor.h"
27 #include "RelationalAccess/ISchema.h"
28 #include "RelationalAccess/ISessionProxy.h"
29 #include "RelationalAccess/IQuery.h"
30 #include "RelationalAccess/TableDescription.h"
31 #include "RelationalAccess/ITable.h"
32 #include "RelationalAccess/ITableDataEditor.h"
33 #include "RelationalAccess/IBulkOperation.h"
34 #include "RelationalAccess/IBulkOperation.h"
35 #include "RelationalAccess/SchemaException.h"
36 //
37 #include <tuple>
38 #include <cstring>
39 #include <set>
40 #include <map>
41 #include <memory>
42 //
43 #include <boost/date_time/posix_time/posix_time.hpp>
44 
45 // macros for the schema definition
46 
47 // table definition
48 #define conddb_table( NAME ) namespace NAME {\
49  static constexpr char const* tname = #NAME ;\
50  }\
51  namespace NAME
52 
53 // implementation for the column definition:
54 
55 // case with 3 params
56 #define FIXSIZE_COLUMN( NAME, TYPE, SIZE ) struct NAME {\
57  static constexpr char const* name = #NAME; \
58  typedef TYPE type;\
59  static constexpr size_t size = SIZE;\
60  static std::string tableName(){ return std::string(tname); }\
61  static std::string fullyQualifiedName(){ return std::string(tname)+"."+name; }\
62  };\
63 
64 // case with 2 params
65 #define VARSIZE_COLUMN( NAME, TYPE ) FIXSIZE_COLUMN( NAME, TYPE, 0 )
66 
67 // trick to select the case
68 #define GET_4TH_ARG(arg1, arg2, arg3, arg4, ... ) arg4
69 #define WRONG_PAR_NUMBER_ERROR( ... ) static_assert( false, "\"column\" macro accepts exactly 2 or 3 parameters" )
70 #define SELECT_COLUMN_MACRO(...) GET_4TH_ARG(__VA_ARGS__, FIXSIZE_COLUMN, VARSIZE_COLUMN, WRONG_PAR_NUMBER_ERROR )
71 
72 // the final column definition macro
73 #define conddb_column( ... ) SELECT_COLUMN_MACRO(__VA_ARGS__)(__VA_ARGS__)
74 
75 namespace cond {
76 
77  namespace persistency {
78 
79  // helper function to asses the equality of the underlying types, regardless if they are references and their constness
80  template <typename T, typename P>
82  static_assert( std::is_same<typename std::decay<T>::type, typename std::decay<P>::type>::value, "Parameter types don't match with the RowBuffer types" );
83  };
84 
85  // functions ( specilized for specific types ) for adding data in AttributeList buffers
86  template<typename T> inline void f_add_attribute( coral::AttributeList& data, const std::string& attributeName, const T& param, bool init=true ){
87  if(init) data.extend<T>( attributeName );
88  data[ attributeName ].data<T>() = param;
89  }
90 
91  template<> inline void f_add_attribute( coral::AttributeList& data, const std::string& attributeName, const cond::Binary& param, bool init ){
92  if(init) data.extend<coral::Blob>( attributeName );
93  data[ attributeName ].bind( param.get() );
94  }
95 
96  template<> inline void f_add_attribute( coral::AttributeList& data, const std::string& attributeName, const boost::posix_time::ptime& param, bool init ){
97  if(init) data.extend<coral::TimeStamp>( attributeName );
98  data[ attributeName ].data<coral::TimeStamp>() = coral::TimeStamp(param);
99  }
100 
101  template<> inline void f_add_attribute( coral::AttributeList& data, const std::string& attributeName, const cond::TimeType& param, bool init ){
102  if(init) data.extend<std::string>( attributeName );
103  data[ attributeName ].data<std::string>() = cond::time::timeTypeName( param );
104  }
105 
106  template<> inline void f_add_attribute( coral::AttributeList& data, const std::string& attributeName, const cond::SynchronizationType& param, bool init ){
107  if(init) data.extend<std::string>( attributeName );
108  data[ attributeName ].data<std::string>() = synchronizationTypeNames( param );
109  }
110 
111  // function for adding into an AttributeList buffer data for a specified column. Performs type checking.
112  template<typename Column, typename P> inline void f_add_column_data( coral::AttributeList& data, const P& param, bool init=true ){
113  static_assert_is_same_decayed<typename Column::type,P>();
114  f_add_attribute( data, Column::name, param, init );
115  }
116 
117  // function for adding into an AttributeList buffer data for a specified condition. Performs type checking.
118  template<typename Column, typename P> inline void f_add_condition_data( coral::AttributeList& data, std::string& whereClause, const P& value, const std::string condition = "="){
119  static_assert_is_same_decayed<typename Column::type,P>();
120  std::stringstream varId;
121  unsigned int id = data.size();
122  varId << Column::name <<"_"<<id;
123  if( !whereClause.empty() ) whereClause += " AND ";
124  whereClause += Column::fullyQualifiedName() + " " + condition + " :" + varId.str() + " ";
125  f_add_attribute( data, varId.str(), value );
126  }
127 
128  // function for appending conditions to a where clause
129  template<typename C1, typename C2> inline void f_add_condition( std::string& whereClause, const std::string condition = "="){
130  if( !whereClause.empty() ) whereClause += " AND ";
131  whereClause += C1::fullyQualifiedName() + " " + condition + " " + C2::fullyQualifiedName() + " ";
132  }
133 
134  // buffer for data to be inserted into a table
135  // maybe better only leave the template set methods ( no class template )
136  template<typename... Columns> class RowBuffer {
137  private:
138 
139  template<typename Params, int n, typename T1, typename... Ts>
140  void _set(const Params & params, bool init=true) {
141  f_add_column_data<T1>( m_data, std::get<n>( params ), init );
142  _set<Params, n+1, Ts...>(params, init);
143  }
144 
145  template<typename Params, int n>
146  void _set(const Params &, bool) {
147  }
148 
149  public:
151  m_data(){
152  }
153 
154  template<typename P>
155  explicit RowBuffer(const P & params):
156  m_data() {
157  _set<P, 0, Columns...>(params);
158  }
159 
160  template<typename P>
161  void set( const P & params ){
162  bool init = (m_data.size()==0);
163  // if RowBuffer becames a single type, we need to run either the equivalent of _RowBuffer ( having addAttribute ) when m_data.size()=0, or _set in all other cases
164  _set<P, 0, Columns...>(params, init);
165  }
166 
167  const coral::AttributeList& get() const {
168  return m_data;
169  }
170 
171  protected:
172  coral::AttributeList m_data;
173  };
174 
175  template<typename T> struct AttributeTypeName {
177  return coral::AttributeSpecification::typeNameForType<T>();
178  }
179  };
180  template<> struct AttributeTypeName<cond::Binary> {
182  return coral::AttributeSpecification::typeNameForType<coral::Blob>();
183  }
184  };
185  template<> struct AttributeTypeName<boost::posix_time::ptime> {
187  return coral::AttributeSpecification::typeNameForType<coral::TimeStamp>();
188  }
189  };
190  template<> struct AttributeTypeName<cond::TimeType> {
192  return coral::AttributeSpecification::typeNameForType<std::string>();
193  }
194  };
197  return coral::AttributeSpecification::typeNameForType<std::string>();
198  }
199  };
200 
201  template<typename T> void f_add_column_description( coral::TableDescription& table, const std::string& columnName, size_t size = 0, bool notNull=true ){
202  table.insertColumn( columnName, AttributeTypeName<T>()(), size );
203  if( notNull ) table.setNotNullConstraint( columnName );
204  }
205 
206  template <typename T, typename Arg1> constexpr bool is_same_any() {
208  };
209 
210  template <typename T, typename Arg1, typename Arg2, typename... Args> constexpr bool is_same_any() {
211  return is_same_any<T, Arg1>() || is_same_any<T, Arg2, Args...>();
212  };
213 
214  template<typename... Types>
216  private:
217 
218  template<int n> void addColumn( coral::TableDescription& ) {}
219 
220  template<int n,typename Arg1, typename... Args> void addColumn( coral::TableDescription& tableDescription ){
221  std::string columnName( Arg1::name );
222  f_add_column_description<typename Arg1::type>( m_description, columnName, Arg1::size );
223  addColumn<n+1, Args...>( m_description );
224  }
225 
226  template<int,typename Col1, typename... Cols> void checkColumns(){
227  static_assert(is_same_any<Col1,Types...>(), "Specified Column has not been found in the table.");
228  checkColumns<0,Cols...>();
229  }
230 
231  template<int> void checkColumns(){
232  }
233 
234  public:
235  explicit TableDescription( const char* name):
236  m_description( "ConditionDatabase" ){
237  m_description.setName( name );
238  addColumn<0,Types...>( m_description );
239  }
240 
241  // for all these methods, we should check that the specified columns belongs to the table columns...
242  template<typename... ColumnTypes> void setPrimaryKey(){
243  checkColumns<0,ColumnTypes...>();
244  m_description.setPrimaryKey( makeList<ColumnTypes...>() );
245  }
246 
247  template<typename... ColumnTypes> void setUniqueConstraint( const std::string& name ){
248  checkColumns<0,ColumnTypes...>();
249  m_description.setUniqueConstraint( makeList<ColumnTypes...>(), name );
250  }
251 
252  template<typename... ColumnTypes> void createIndex( const std::string& name ){
253  checkColumns<0,ColumnTypes...>();
254  m_description.createIndex( name, makeList<ColumnTypes...>() );
255  }
256 
257  template<typename Column, typename ReferencedColumn> void setForeignKey( const std::string& name ){
258  checkColumns<0,Column>();
259  m_description.createForeignKey( name, Column::name, ReferencedColumn::tableName(), ReferencedColumn::name );
260  }
261 
262  const coral::TableDescription& get() {
263  return m_description;
264  }
265 
266  private:
267  template<int n> void _makeList( std::vector<std::string>& ) {}
268 
269  template<int n, typename Arg1, typename... Args> void _makeList( std::vector<std::string>& columnNames ) {
270  columnNames.push_back( Arg1::name );
271  _makeList<n+1, Args...>( columnNames );
272  }
273 
274  template<typename... ColumnTypes> std::vector<std::string> makeList(){
275  std::vector<std::string> columnList;
276  _makeList<0,ColumnTypes...>( columnList );
277  return columnList;
278  }
279 
280  private:
281  coral::TableDescription m_description;
282  };
283 
284  template <typename T> struct GetFromRow { T operator()( const coral::AttributeList& row, const std::string& fullyQualifiedName ){
285  return row[ fullyQualifiedName ].data<T>();
286  } };
287  template <> struct GetFromRow<cond::Binary> { cond::Binary operator()( const coral::AttributeList& row, const std::string& fullyQualifiedName ){
288  return cond::Binary(row[ fullyQualifiedName ].data<coral::Blob>());
289  } };
290  template <> struct GetFromRow<boost::posix_time::ptime> { boost::posix_time::ptime operator()( const coral::AttributeList& row, const std::string& fullyQualifiedName ){
291  return row[ fullyQualifiedName ].data<coral::TimeStamp>().time();
292  } };
293  template <> struct GetFromRow<cond::TimeType> { cond::TimeType operator()( const coral::AttributeList& row, const std::string& fullyQualifiedName ){
294  return cond::time::timeTypeFromName( row[ fullyQualifiedName ].data<std::string>() );
295  } };
296  template <> struct GetFromRow<cond::SynchronizationType> { cond::SynchronizationType operator()( const coral::AttributeList& row, const std::string& fullyQualifiedName ){
297  return cond::synchronizationTypeFromName( row[ fullyQualifiedName ].data<std::string>() );
298  } };
299  template <std::size_t n> struct GetFromRow< std::array<char,n> > { std::string operator()( const coral::AttributeList& row, const std::string& fullyQualifiedName ){
300  std::string val = row[ fullyQualifiedName ].data<std::string>();
301  if( val.size() != n ) throwException("Retrieved string size does not match with the expected string size.","getFromRow");
302  std::array<char,n> ret;
303  ::memcpy(ret.data(),val.c_str(),n);
304  return ret;
305  } };
306 
307  template<typename... Types> class Query;
308 
309  template<typename... Types> class QueryIterator: public std::iterator<std::input_iterator_tag,std::tuple<Types...> > {
310 
311  public:
313  }
314 
316  m_query( rhs.m_query ),
317  m_currentRow( rhs.m_currentRow ){
318  }
319 
321  m_query( parent ){
322  }
323 
325  m_query = rhs.m_query;
326  m_currentRow = rhs.m_currentRow;
327  return *this;
328  }
329 
330  template <typename T> typename T::type get() const {
331  return GetFromRow<typename T::type>()( *m_currentRow, T::fullyQualifiedName() );
332  }
333 
334  auto operator*() -> decltype( std::make_tuple( this->get<Types>()... ) ) {
335  return std::make_tuple( get<Types>()... );
336  }
337 
339  m_currentRow = m_query->next() ? &m_query->currentRow() : nullptr;
340  return *this;
341  }
342 
344  QueryIterator tmp( *this );
345  operator++();
346  return tmp;
347  }
348 
349  bool operator==( const QueryIterator& rhs ) const {
350  if (rhs.m_query == nullptr && m_query == nullptr)
351  return true;
352  return m_query == rhs.m_query && m_currentRow == rhs.m_currentRow;
353  }
354  bool operator!=( const QueryIterator& rhs ) const {
355  return !operator==(rhs);
356  }
357 
358  operator bool() const {
359  return m_currentRow;
360  }
361 
362  private:
363  Query<Types...>* m_query = nullptr;
364  const coral::AttributeList* m_currentRow=nullptr;
365  };
366 
367  template<typename T> struct DefineQueryOutput { static void make( coral::IQuery& query, const std::string& fullyQualifiedName ){
368  query.addToOutputList( fullyQualifiedName );
369  query.defineOutputType( fullyQualifiedName, coral::AttributeSpecification::typeNameForType<T>() );
370  } };
371  template<> struct DefineQueryOutput<cond::Binary>{ static void make( coral::IQuery& query, const std::string& fullyQualifiedName ){
372  query.addToOutputList( fullyQualifiedName );
373  query.defineOutputType( fullyQualifiedName, coral::AttributeSpecification::typeNameForType<coral::Blob>() );
374  } };
375  template<> struct DefineQueryOutput<boost::posix_time::ptime>{ static void make( coral::IQuery& query, const std::string& fullyQualifiedName ){
376  query.addToOutputList( fullyQualifiedName );
377  query.defineOutputType( fullyQualifiedName, coral::AttributeSpecification::typeNameForType<coral::TimeStamp>() );
378  } };
379  template<> struct DefineQueryOutput<cond::TimeType>{ static void make( coral::IQuery& query, const std::string& fullyQualifiedName ){
380  query.addToOutputList( fullyQualifiedName );
381  query.defineOutputType( fullyQualifiedName, coral::AttributeSpecification::typeNameForType<std::string>() );
382  } };
383  template<> struct DefineQueryOutput<cond::SynchronizationType>{ static void make( coral::IQuery& query, const std::string& fullyQualifiedName ){
384  query.addToOutputList( fullyQualifiedName );
385  query.defineOutputType( fullyQualifiedName, coral::AttributeSpecification::typeNameForType<std::string>() );
386  } };
387  template <std::size_t n> struct DefineQueryOutput< std::array<char,n> > { static void make( coral::IQuery& query, const std::string& fullyQualifiedName ){
388  query.addToOutputList( fullyQualifiedName );
389  query.defineOutputType( fullyQualifiedName, coral::AttributeSpecification::typeNameForType<std::string>() );
390  } };
391 
392 
393  template<typename... Types> class Query {
394  public:
395  Query( const coral::ISchema& schema, bool distinct=false ):
396  m_coralQuery( schema.newQuery() ),
397  m_whereData(),
398  m_whereClause(""),
399  m_tables(){
400  _Query<0, Types...>();
401  if( distinct ) m_coralQuery->setDistinct();
402  }
403 
405  }
406 
407  template<typename Col> Query& addTable(){
408  if( m_tables.find( Col::tableName() )==m_tables.end() ){
409  m_coralQuery->addToTableList( Col::tableName() );
410  m_tables.insert( Col::tableName() );
411  }
412  return *this;
413  }
414 
415  template<int n>
416  void _Query() {}
417 
418  template<int n, typename Arg1, typename... Args>
419  void _Query() {
420  addTable<Arg1>();
421  DefineQueryOutput<typename Arg1::type>::make( *m_coralQuery, Arg1::fullyQualifiedName() );
422  _Query<n+1, Args...>();
423  }
424 
425  template<typename C, typename T> Query& addCondition( const T& value, const std::string condition = "="){
426  addTable<C>();
427  f_add_condition_data<C>( m_whereData, m_whereClause, value, condition );
428  return *this;
429  }
430 
431  template<typename C1, typename C2> Query& addCondition( const std::string condition = "="){
432  addTable<C1>();
433  addTable<C2>();
434  f_add_condition<C1,C2>( m_whereClause, condition );
435  return *this;
436  }
437 
438  template<typename C> Query& addOrderClause( bool ascending=true ){
439  std::string orderClause( C::fullyQualifiedName() );
440  if(!ascending) orderClause += " DESC";
441  m_coralQuery->addToOrderList( orderClause );
442  return *this;
443  }
444 
445  Query& groupBy( const std::string& expression ){
446  m_coralQuery->groupBy( expression );
447  return *this;
448  }
449 
451  m_coralQuery->setForUpdate();
452  return *this;
453  }
454 
455  bool next(){
456  if(!m_cursor) throwException( "The query has not been executed.","Query::currentRow");
457  bool ret = m_cursor->next();
458  if( ret ) m_retrievedRows++;
459  return ret;
460  }
461 
462  const coral::AttributeList& currentRow() const {
463  if(!m_cursor) throwException( "The query has not been executed.","Query::currentRow");
464  return m_cursor->currentRow();
465  }
466 
467  const QueryIterator<Types...> begin() {
468  m_coralQuery->setCondition( m_whereClause, m_whereData );
469  m_cursor = &m_coralQuery->execute();
470  m_retrievedRows = 0;
471  QueryIterator<Types...> ret ( this );
472  return ++ret;
473  }
474 
475  const QueryIterator<Types...> end() {
476  return QueryIterator<Types...>( this );
477  }
478 
479  size_t retrievedRows() const {
480  return m_retrievedRows;
481  }
482 
483  private:
484  std::unique_ptr<coral::IQuery> m_coralQuery;
485  coral::ICursor* m_cursor = nullptr;
486  size_t m_retrievedRows = 0;
487  coral::AttributeList m_whereData;
489  std::set<std::string> m_tables;
490  };
491 
492  class UpdateBuffer {
493  private:
494  template<typename Params, int n, typename C1, typename... Cs>
495  void _set(const Params & params) {
496  f_add_column_data<C1>( m_data, std::get<n>( params ) );
497  if( !m_setClause.empty() ) m_setClause += ", ";
498  m_setClause += std::string(C1::name) + " = :" + std::string(C1::name);
499  _set<Params, n+1, Cs...>(params);
500  }
501 
502  template<typename Params, int n>
503  void _set(const Params &) {
504  }
505 
506 
507  public:
509  m_data(),
510  m_setClause(""),
511  m_whereClause(""){
512  }
513 
514  template <typename... Columns, typename Params> void setColumnData( const Params& params ){
515  _set<Params,0,Columns...>( params );
516  }
517 
518  template <typename Column1, typename Column2> void setColumnMatch(){
519  if( !m_setClause.empty() ) m_setClause +=", ";
520  m_setClause += std::string(Column1::name) + " = " + std::string(Column2::name);
521  }
522 
523  template <typename Column, typename P> void addWhereCondition( const P& param, const std::string condition = "=" ){
524  f_add_condition_data<Column>( m_data, m_whereClause, param, condition );
525  }
526 
527  template <typename Column1, typename Column2> void addWhereCondition( const std::string condition = "=" ){
528  f_add_condition<Column1,Column2>( m_whereClause, condition );
529  }
530 
531  const coral::AttributeList& get() const {
532  return m_data;
533  }
534 
535  const std::string& setClause() const {
536  return m_setClause;
537  }
538 
539  const std::string& whereClause() const {
540  return m_whereClause;
541  }
542 
543  private:
544  coral::AttributeList m_data;
547  };
548 
549  class DeleteBuffer {
550 
551  public:
553  m_data(),
554  m_whereClause(""){
555  }
556 
557  template <typename Column, typename P> void addWhereCondition( const P& param, const std::string condition = "=" ){
558  f_add_condition_data<Column>( m_data, m_whereClause, param, condition );
559  }
560 
561  template <typename Column1, typename Column2> void addWhereCondition( const std::string condition = "=" ){
562  f_add_condition<Column1,Column2>( m_whereClause, condition );
563  }
564 
565  const coral::AttributeList& get() const {
566  return m_data;
567  }
568 
569  const std::string& whereClause() const {
570  return m_whereClause;
571  }
572 
573  private:
574  coral::AttributeList m_data;
576  };
577 
578  template <typename... Types> class BulkInserter {
579  public:
580  static constexpr size_t cacheSize = 1000;
581  BulkInserter( coral::ISchema& schema, const char* tableName ):
582  m_schema( schema ),
583  m_tableName( tableName ),
584  m_buffer(),
585  m_coralInserter(){
586  //fix me: maybe with
587  //m_coralInserter.reset( schema.tableHandle( std::string(tableName ) ).dataEditor().bulkInsert( m_buffer.get(), cacheSize ) );
588  }
589 
590  template <typename P> void insert( const P& params ){
591  m_buffer.set( params );
592  if( !m_coralInserter.get() ) m_coralInserter.reset( m_schema.tableHandle( m_tableName ).dataEditor().bulkInsert( m_buffer.get(), cacheSize ) );
593  m_coralInserter->processNextIteration();
594  }
595 
596  void flush(){
597  if( m_coralInserter.get() ) m_coralInserter->flush();
598  }
599  private:
600  // fixme
601  coral::ISchema& m_schema;
603  //
605  std::unique_ptr<coral::IBulkOperation> m_coralInserter;
606  };
607 
608  namespace {
609 
610 
611  inline bool existsTable( coral::ISchema& schema, const char* tableName ){
612  return schema.existsTable( std::string( tableName ) );
613  }
614 
615  inline void createTable( coral::ISchema& schema, const coral::TableDescription& descr ){
616  schema.createTable( descr );
617  }
618 
619  inline bool insertInTable( coral::ISchema& schema, const char* tableName, const coral::AttributeList& row, bool failOnDuplicate=true ){
620  bool ret = false;
621  try{
622  schema.tableHandle( std::string(tableName ) ).dataEditor().insertRow( row );
623  ret = true;
624  } catch ( const coral::DuplicateEntryInUniqueKeyException& ){
625  if( failOnDuplicate ) throw;
626  }
627  return ret;
628  }
629 
630  inline void updateTable( coral::ISchema& schema, const char* tableName, const UpdateBuffer& data ){
631  schema.tableHandle( std::string(tableName ) ).dataEditor().updateRows( data.setClause(), data.whereClause(), data.get() );
632  }
633 
634  inline void deleteFromTable( coral::ISchema& schema, const char* tableName, const DeleteBuffer& data ){
635  schema.tableHandle( std::string(tableName ) ).dataEditor().deleteRows( data.whereClause(), data.get() );
636  }
637  }
638 
639  }
640 
641 }
642 
643 #endif
size
Write out results.
void addColumn(coral::TableDescription &)
Definition: DbCore.h:218
type
Definition: HCALResponse.h:21
std::vector< std::string > makeList()
Definition: DbCore.h:274
void createIndex(const std::string &name)
Definition: DbCore.h:252
void static_assert_is_same_decayed()
Definition: DbCore.h:81
Query< Types... > * m_query
Definition: DbCore.h:363
QueryIterator(Query< Types... > *parent)
Definition: DbCore.h:320
void _set(const Params &params, bool init=true)
Definition: DbCore.h:140
T operator()(const coral::AttributeList &row, const std::string &fullyQualifiedName)
Definition: DbCore.h:284
Definition: CLHEP.h:16
coral::AttributeList m_data
Definition: DbCore.h:544
std::string synchronizationTypeNames(SynchronizationType type)
Definition: Types.cc:46
QueryIterator & operator=(const QueryIterator &rhs)
Definition: DbCore.h:324
RowBuffer< Types... > m_buffer
Definition: DbCore.h:604
void f_add_condition_data(coral::AttributeList &data, std::string &whereClause, const P &value, const std::string condition="=")
Definition: DbCore.h:118
int init
Definition: HydjetWrapper.h:67
void insert(const P &params)
Definition: DbCore.h:590
const coral::AttributeList * m_currentRow
Definition: DbCore.h:364
RowBuffer(const P &params)
Definition: DbCore.h:155
std::string operator()(const coral::AttributeList &row, const std::string &fullyQualifiedName)
Definition: DbCore.h:299
bool is_same_any()
Definition: DbCore.h:206
void addWhereCondition(const std::string condition="=")
Definition: DbCore.h:561
size_t retrievedRows() const
Definition: DbCore.h:479
static void make(coral::IQuery &query, const std::string &fullyQualifiedName)
Definition: DbCore.h:367
bool distinct(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:72
TimeType
Definition: Time.h:21
Query(const coral::ISchema &schema, bool distinct=false)
Definition: DbCore.h:395
Definition: query.py:1
void _set(const Params &params)
Definition: DbCore.h:495
const std::string & setClause() const
Definition: DbCore.h:535
void setForeignKey(const std::string &name)
Definition: DbCore.h:257
void _makeList(std::vector< std::string > &columnNames)
Definition: DbCore.h:269
void f_add_column_data(coral::AttributeList &data, const P &param, bool init=true)
Definition: DbCore.h:112
TimeType timeTypeFromName(const std::string &name)
Definition: Time.cc:24
Query & groupBy(const std::string &expression)
Definition: DbCore.h:445
SynchronizationType synchronizationTypeFromName(const std::string &name)
Definition: Types.cc:50
static void make(coral::IQuery &query, const std::string &fullyQualifiedName)
Definition: DbCore.h:379
void f_add_column_description(coral::TableDescription &table, const std::string &columnName, size_t size=0, bool notNull=true)
Definition: DbCore.h:201
void f_add_attribute(coral::AttributeList &data, const std::string &attributeName, const T &param, bool init=true)
Definition: DbCore.h:86
void setUniqueConstraint(const std::string &name)
Definition: DbCore.h:247
static void make(coral::IQuery &query, const std::string &fullyQualifiedName)
Definition: DbCore.h:383
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
const coral::AttributeList & currentRow() const
Definition: DbCore.h:462
Query & addCondition(const T &value, const std::string condition="=")
Definition: DbCore.h:425
void f_add_condition(std::string &whereClause, const std::string condition="=")
Definition: DbCore.h:129
Definition: Types.py:1
Definition: value.py:1
coral::AttributeList m_whereData
Definition: DbCore.h:487
bool operator==(const QueryIterator &rhs) const
Definition: DbCore.h:349
cond::TimeType operator()(const coral::AttributeList &row, const std::string &fullyQualifiedName)
Definition: DbCore.h:293
const QueryIterator< Types... > end()
Definition: DbCore.h:475
Query & addOrderClause(bool ascending=true)
Definition: DbCore.h:438
static void make(coral::IQuery &query, const std::string &fullyQualifiedName)
Definition: DbCore.h:371
std::unique_ptr< coral::IQuery > m_coralQuery
Definition: DbCore.h:484
const std::string & whereClause() const
Definition: DbCore.h:539
std::string m_whereClause
Definition: DbCore.h:488
Definition: init.py:1
QueryIterator operator++(int)
Definition: DbCore.h:343
const coral::AttributeList & get() const
Definition: DbCore.h:531
void setColumnData(const Params &params)
Definition: DbCore.h:514
Query & addCondition(const std::string condition="=")
Definition: DbCore.h:431
QueryIterator & operator++()
Definition: DbCore.h:338
void _set(const Params &, bool)
Definition: DbCore.h:146
std::pair< OmniClusterRef, TrackingParticleRef > P
const coral::AttributeList & get() const
Definition: DbCore.h:565
auto operator*() -> decltype(std::make_tuple(this->get< Types >()...))
Definition: DbCore.h:334
static void make(coral::IQuery &query, const std::string &fullyQualifiedName)
Definition: DbCore.h:375
cond::SynchronizationType operator()(const coral::AttributeList &row, const std::string &fullyQualifiedName)
Definition: DbCore.h:296
BulkInserter(coral::ISchema &schema, const char *tableName)
Definition: DbCore.h:581
const QueryIterator< Types... > begin()
Definition: DbCore.h:467
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void _makeList(std::vector< std::string > &)
Definition: DbCore.h:267
coral::TableDescription m_description
Definition: DbCore.h:281
Definition: plugin.cc:24
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const coral::Blob & get() const
Definition: Binary.cc:36
void addColumn(coral::TableDescription &tableDescription)
Definition: DbCore.h:220
bool operator!=(const QueryIterator &rhs) const
Definition: DbCore.h:354
SynchronizationType
Definition: Types.h:29
Query & setForUpdate()
Definition: DbCore.h:450
static void make(coral::IQuery &query, const std::string &fullyQualifiedName)
Definition: DbCore.h:387
coral::ISchema & m_schema
Definition: DbCore.h:601
std::unique_ptr< coral::IBulkOperation > m_coralInserter
Definition: DbCore.h:605
cond::Binary operator()(const coral::AttributeList &row, const std::string &fullyQualifiedName)
Definition: DbCore.h:287
coral::AttributeList m_data
Definition: DbCore.h:172
std::set< std::string > m_tables
Definition: DbCore.h:489
const std::string & whereClause() const
Definition: DbCore.h:569
long double T
void addWhereCondition(const std::string condition="=")
Definition: DbCore.h:527
std::string timeTypeName(TimeType type)
Definition: Time.cc:19
TableDescription(const char *name)
Definition: DbCore.h:235
QueryIterator(const QueryIterator &rhs)
Definition: DbCore.h:315
void addWhereCondition(const P &param, const std::string condition="=")
Definition: DbCore.h:523
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
#define constexpr
void _set(const Params &)
Definition: DbCore.h:503
boost::posix_time::ptime operator()(const coral::AttributeList &row, const std::string &fullyQualifiedName)
Definition: DbCore.h:290
coral::AttributeList m_data
Definition: DbCore.h:574
void addWhereCondition(const P &param, const std::string condition="=")
Definition: DbCore.h:557