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, cond::SynchronizationType& synchronizationType,
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  void setValidationMode(){}
43  private:
44  coral::ISchema& m_schema;
45  };
46  }
47 
48  table ( PAYLOAD ) {
49 
50  static constexpr unsigned int PAYLOAD_HASH_SIZE = 40;
51 
52  column( HASH, std::string, PAYLOAD_HASH_SIZE );
53  column( OBJECT_TYPE, 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,
67  cond::Binary& payloadData, cond::Binary& streamerInfoData);
68  bool getType( const cond::Hash& payloadHash, std::string& objectType );
69  bool insert( const cond::Hash& payloadHash, const std::string& objectType,
70  const cond::Binary& payloadData, const cond::Binary& streamerInfoData,
71  const boost::posix_time::ptime& insertionTime);
72  cond::Hash insertIfNew( const std::string& objectType, const cond::Binary& payloadData,
73  const cond::Binary& streamerInfoData, const boost::posix_time::ptime& insertionTime );
74  private:
75  coral::ISchema& m_schema;
76  };
77  }
78 
79  table( IOV ) {
80 
81  column( TAG_NAME, std::string );
82  column( SINCE, cond::Time_t );
83  column( PAYLOAD_HASH, std::string, PAYLOAD::PAYLOAD_HASH_SIZE );
84  column( INSERTION_TIME, boost::posix_time::ptime );
85 
86  struct MAX_SINCE {
87  typedef cond::Time_t type;
88  static constexpr size_t size = 0;
89  static std::string tableName(){ return SINCE::tableName(); }
90  static std::string fullyQualifiedName(){
91  return std::string("MAX(")+SINCE::fullyQualifiedName()+")";
92  }
93  };
94  struct SINCE_GROUP {
95  typedef cond::Time_t type;
96  static constexpr size_t size = 0;
97  static std::string tableName(){ return SINCE::tableName(); }
98  static std::string fullyQualifiedName(){
99  std::string sgroupSize = boost::lexical_cast<std::string>(cond::time::SINCE_GROUP_SIZE);
100  return "("+SINCE::fullyQualifiedName()+"/"+sgroupSize+")*"+sgroupSize;
101  }
102  };
103 
104  struct SEQUENCE_SIZE {
105  typedef unsigned int type;
106  static constexpr size_t size = 0;
107  static std::string tableName(){ return SINCE::tableName(); }
108  static std::string fullyQualifiedName(){
109  return "COUNT(*)";
110  }
111  };
112 
113  class Table : public IIOVTable {
114  public:
115  explicit Table( coral::ISchema& schema );
116  virtual ~Table(){}
117  bool exists();
118  void create();
119  size_t selectGroups( const std::string& tag, std::vector<cond::Time_t>& groups );
120  size_t selectSnapshotGroups( const std::string& tag, const boost::posix_time::ptime& snapshotTime,
121  std::vector<cond::Time_t>& groups );
122  size_t selectLatestByGroup( const std::string& tag, cond::Time_t lowerGroup, cond::Time_t upperGroup,
123  std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs);
124  size_t selectSnapshotByGroup( const std::string& tag, cond::Time_t lowerGroup, cond::Time_t upperGroup,
125  const boost::posix_time::ptime& snapshotTime,
126  std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs);
127  size_t selectLatest( const std::string& tag, std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs);
128  bool getLastIov( const std::string& tag, cond::Time_t& since, cond::Hash& hash );
129  bool getSize( const std::string& tag, size_t& size );
130  bool getSnapshotSize( const std::string& tag, const boost::posix_time::ptime& snapshotTime, size_t& size );
131  void insertOne( const std::string& tag, cond::Time_t since, cond::Hash payloadHash, const boost::posix_time::ptime& insertTime);
132  void insertMany( const std::string& tag, const std::vector<std::tuple<cond::Time_t,cond::Hash,boost::posix_time::ptime> >& iovs );
133  void erase( const std::string& tag );
134  private:
135  coral::ISchema& m_schema;
136  };
137  }
138 
139  // temporary... to be removed after the changeover.
140  table( TAG_MIGRATION ) {
141 
142  column( SOURCE_ACCOUNT, std::string );
143  column( SOURCE_TAG, std::string );
144  column( TAG_NAME, std::string );
145  column( STATUS_CODE, int );
146  column( INSERTION_TIME, boost::posix_time::ptime );
147 
148  class Table : public ITagMigrationTable {
149  public:
150  explicit Table( coral::ISchema& schema );
151  virtual ~Table(){}
152  bool exists();
153  void create();
154  bool select( const std::string& sourceAccount, const std::string& sourceTag, std::string& tagName, int& statusCode);
155  void insert( const std::string& sourceAccount, const std::string& sourceTag, const std::string& tagName,
156  int statusCode, const boost::posix_time::ptime& insertionTime);
157  void updateValidationCode( const std::string& sourceAccount, const std::string& sourceTag, int statusCode );
158  private:
159  coral::ISchema& m_schema;
160  };
161  }
162 
163  class IOVSchema : public IIOVSchema {
164  public:
165  explicit IOVSchema( coral::ISchema& schema );
166  virtual ~IOVSchema(){}
167  bool exists();
168  bool create();
169  ITagTable& tagTable();
170  IIOVTable& iovTable();
173  private:
174  TAG::Table m_tagTable;
175  IOV::Table m_iovTable;
176  PAYLOAD::Table m_payloadTable;
177  TAG_MIGRATION::Table m_tagMigrationTable;
178  };
179  }
180 }
181 #endif
type
Definition: HCALResponse.h:21
static constexpr unsigned int SINCE_GROUP_SIZE
Definition: Time.h:35
PAYLOAD::Table m_payloadTable
Definition: IOVSchema.h:176
TimeType
Definition: Time.h:21
unsigned long long Time_t
Definition: Time.h:16
TAG_MIGRATION::Table m_tagMigrationTable
Definition: IOVSchema.h:177
std::string Hash
Definition: Types.h:43
IPayloadTable & payloadTable()
Definition: IOVSchema.cc:420
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
ITagMigrationTable & tagMigrationTable()
Definition: IOVSchema.cc:424
tuple description
Definition: idDealer.py:66
IOVSchema(coral::ISchema &schema)
Definition: IOVSchema.cc:387
#define column(...)
Definition: DbCore.h:74
#define update(a, b)
SynchronizationType
Definition: Types.h:31
#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