CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IOVSchema.h
Go to the documentation of this file.
1 #ifndef CondCore_CondDB_IOVSchema_h
2 #define CondCore_CondDB_IOVSchema_h
3 
4 #include "DbCore.h"
5 #include "IDbSchema.h"
6 //
7 #include <boost/date_time/posix_time/posix_time.hpp>
8 
9 namespace cond {
10 
11  namespace persistency {
12 
13  table( TAG ) {
14 
15  column( NAME, std::string );
16  column( TIME_TYPE, cond::TimeType );
17  column( OBJECT_TYPE, std::string );
18  column( SYNCHRONIZATION, cond::SynchronizationType );
19  column( END_OF_VALIDITY, cond::Time_t );
20  column( DESCRIPTION, std::string );
21  column( LAST_VALIDATED_TIME, cond::Time_t );
22  column( INSERTION_TIME, boost::posix_time::ptime );
23  column( MODIFICATION_TIME, boost::posix_time::ptime );
24 
25  class Table : public ITagTable {
26  public:
27  explicit Table( coral::ISchema& schema );
28  virtual ~Table(){}
29  bool exists();
30  void create();
31  bool select( const std::string& name );
32  bool select( const std::string& name, cond::TimeType& timeType, std::string& objectType,
33  cond::Time_t& endOfValidity, std::string& description, cond::Time_t& lastValidatedTime );
34  bool getMetadata( const std::string& name, std::string& description,
35  boost::posix_time::ptime& insertionTime, boost::posix_time::ptime& modificationTime );
36  void insert( const std::string& name, cond::TimeType timeType, const std::string& objectType,
37  cond::SynchronizationType synchronizationType, cond::Time_t endOfValidity, const std::string& description,
38  cond::Time_t lastValidatedTime, const boost::posix_time::ptime& insertionTime );
39  void update( const std::string& name, cond::Time_t& endOfValidity, const std::string& description,
40  cond::Time_t lastValidatedTime, const boost::posix_time::ptime& updateTime );
41  void updateValidity( const std::string& name, cond::Time_t lastValidatedTime, const boost::posix_time::ptime& updateTime );
42  private:
43  coral::ISchema& m_schema;
44  };
45  }
46 
47  table ( PAYLOAD ) {
48 
49  static constexpr unsigned int PAYLOAD_HASH_SIZE = 40;
50 
51  column( HASH, std::string, PAYLOAD_HASH_SIZE );
52  column( OBJECT_TYPE, std::string );
54  //column( STREAMER, std::string );
55  column( STREAMER_INFO, cond::Binary );
57  column( INSERTION_TIME, boost::posix_time::ptime );
58 
59  class Table : public IPayloadTable {
60  public:
61  explicit Table( coral::ISchema& schema );
62  virtual ~Table(){}
63  bool exists();
64  void create();
65  bool select( const cond::Hash& payloadHash);
66  bool select( const cond::Hash& payloadHash, std::string& objectType, cond::Binary& payloadData);
67  bool getType( const cond::Hash& payloadHash, std::string& objectType );
68  bool insert( const cond::Hash& payloadHash, const std::string& objectType,
69  const cond::Binary& payloadData, const boost::posix_time::ptime& insertionTime);
70  cond::Hash insertIfNew( const std::string& objectType, const cond::Binary& payloadData,
71  const boost::posix_time::ptime& insertionTime );
72  private:
73  coral::ISchema& m_schema;
74  };
75  }
76 
77  table( IOV ) {
78 
79  column( TAG_NAME, std::string );
80  column( SINCE, cond::Time_t );
81  column( PAYLOAD_HASH, std::string, PAYLOAD::PAYLOAD_HASH_SIZE );
82  column( INSERTION_TIME, boost::posix_time::ptime );
83 
84  struct MAX_SINCE {
85  typedef cond::Time_t type;
86  static constexpr size_t size = 0;
87  static std::string tableName(){ return SINCE::tableName(); }
88  static std::string fullyQualifiedName(){
89  return std::string("MAX(")+SINCE::fullyQualifiedName()+")";
90  }
91  };
92  struct SINCE_GROUP {
93  typedef cond::Time_t type;
94  static constexpr size_t size = 0;
95  static std::string tableName(){ return SINCE::tableName(); }
96  static std::string fullyQualifiedName(){
97  std::string sgroupSize = boost::lexical_cast<std::string>(cond::time::SINCE_GROUP_SIZE);
98  return "("+SINCE::fullyQualifiedName()+"/"+sgroupSize+")*"+sgroupSize;
99  }
100  };
101 
102  struct SEQUENCE_SIZE {
103  typedef unsigned int type;
104  static constexpr size_t size = 0;
105  static std::string tableName(){ return SINCE::tableName(); }
106  static std::string fullyQualifiedName(){
107  return "COUNT(*)";
108  }
109  };
110 
111  class Table : public IIOVTable {
112  public:
113  explicit Table( coral::ISchema& schema );
114  virtual ~Table(){}
115  bool exists();
116  void create();
117  size_t selectGroups( const std::string& tag, std::vector<cond::Time_t>& groups );
118  size_t selectSnapshotGroups( const std::string& tag, const boost::posix_time::ptime& snapshotTime,
119  std::vector<cond::Time_t>& groups );
120  size_t selectLatestByGroup( const std::string& tag, cond::Time_t lowerGroup, cond::Time_t upperGroup,
121  std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs);
122  size_t selectSnapshotByGroup( const std::string& tag, cond::Time_t lowerGroup, cond::Time_t upperGroup,
123  const boost::posix_time::ptime& snapshotTime,
124  std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs);
125  size_t selectLatest( const std::string& tag, std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs);
126  bool getLastIov( const std::string& tag, cond::Time_t& since, cond::Hash& hash );
127  bool getSize( const std::string& tag, size_t& size );
128  bool getSnapshotSize( const std::string& tag, const boost::posix_time::ptime& snapshotTime, size_t& size );
129  void insertOne( const std::string& tag, cond::Time_t since, cond::Hash payloadHash, const boost::posix_time::ptime& insertTime);
130  void insertMany( const std::string& tag, const std::vector<std::tuple<cond::Time_t,cond::Hash,boost::posix_time::ptime> >& iovs );
131  private:
132  coral::ISchema& m_schema;
133  };
134  }
135 
136  // temporary... to be removed after the changeover.
137  table( TAG_MIGRATION ) {
138 
139  column( SOURCE_ACCOUNT, std::string );
140  column( SOURCE_TAG, std::string );
141  column( TAG_NAME, std::string );
142  column( INSERTION_TIME, boost::posix_time::ptime );
143 
144  class Table : public ITagMigrationTable {
145  public:
146  explicit Table( coral::ISchema& schema );
147  virtual ~Table(){}
148  bool exists();
149  void create();
150  bool select( const std::string& sourceAccount, const std::string& sourceTag, std::string& tagName);
151  void insert( const std::string& sourceAccount, const std::string& sourceTag, const std::string& tagName,
152  const boost::posix_time::ptime& insertionTime);
153  private:
154  coral::ISchema& m_schema;
155  };
156  }
157 
158  class IOVSchema : public IIOVSchema {
159  public:
160  explicit IOVSchema( coral::ISchema& schema );
161  virtual ~IOVSchema(){}
162  bool exists();
163  bool create();
164  ITagTable& tagTable();
165  IIOVTable& iovTable();
168  private:
169  TAG::Table m_tagTable;
170  IOV::Table m_iovTable;
171  PAYLOAD::Table m_payloadTable;
172  TAG_MIGRATION::Table m_tagMigrationTable;
173  };
174  }
175 }
176 #endif
type
Definition: HCALResponse.h:21
static constexpr unsigned int SINCE_GROUP_SIZE
Definition: Time.h:35
tuple TAG
Definition: utils.py:19
PAYLOAD::Table m_payloadTable
Definition: IOVSchema.h:171
TimeType
Definition: Time.h:21
unsigned long long Time_t
Definition: Time.h:16
TAG_MIGRATION::Table m_tagMigrationTable
Definition: IOVSchema.h:172
std::string Hash
Definition: Types.h:38
IPayloadTable & payloadTable()
Definition: IOVSchema.cc:402
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
ITagMigrationTable & tagMigrationTable()
Definition: IOVSchema.cc:406
tuple description
Definition: idDealer.py:66
IOVSchema(coral::ISchema &schema)
Definition: IOVSchema.cc:369
#define column(...)
Definition: DbCore.h:74
#define update(a, b)
SynchronizationType
Definition: Types.h:26
#define VERSION
Definition: scimark2.h:5
table(GLOBAL_TAG)
Definition: GTSchema.h:13
SurfaceDeformation * create(int type, const std::vector< double > &params)
tuple size
Write out results.
#define constexpr