CMS 3D CMS Logo

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  conddb_table( TAG ) {
14 
22  conddb_column( INSERTION_TIME, boost::posix_time::ptime );
23  conddb_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::SynchronizationType synchronizationType, 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 );
43  private:
44  coral::ISchema& m_schema;
45  };
46  }
47 
48  conddb_table ( PAYLOAD ) {
49 
50  static constexpr unsigned int PAYLOAD_HASH_SIZE = 40;
51 
52  conddb_column( HASH, std::string, PAYLOAD_HASH_SIZE );
57  conddb_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  conddb_table( IOV ) {
80 
84  conddb_column( INSERTION_TIME, boost::posix_time::ptime );
85 
86  struct SINCE_GROUP {
87  typedef cond::Time_t type;
88  static constexpr size_t size = 0;
89  static std::string tableName(){ return SINCE::tableName(); }
91  return "MIN("+SINCE::fullyQualifiedName()+")";
92  }
93  static std::string group(){
94  std::string sgroupSize = std::to_string(cond::time::SINCE_GROUP_SIZE);
95  return "CAST("+SINCE::fullyQualifiedName()+"/"+sgroupSize+" AS INT )*"+sgroupSize;
96  }
97  };
98 
99  struct SEQUENCE_SIZE {
100  typedef unsigned int type;
101  static constexpr size_t size = 0;
102  static std::string tableName(){ return SINCE::tableName(); }
104  return "COUNT(*)";
105  }
106  };
107 
108  struct MIN_SINCE {
109  typedef cond::Time_t type;
110  static constexpr size_t size = 0;
111  static std::string tableName(){ return SINCE::tableName(); }
113  return "MIN("+SINCE::fullyQualifiedName()+")";
114  }
115  };
116 
117  struct MAX_SINCE {
118  typedef cond::Time_t type;
119  static constexpr size_t size = 0;
120  static std::string tableName(){ return SINCE::tableName(); }
122  return "MAX("+SINCE::fullyQualifiedName()+")";
123  }
124  };
125 
126  class Table : public IIOVTable {
127  public:
128  explicit Table( coral::ISchema& schema );
129  virtual ~Table(){}
130  bool exists();
131  void create();
132  size_t getGroups( const std::string& tag, const boost::posix_time::ptime& snapshotTime,
133  std::vector<cond::Time_t>& groups );
134  size_t select( const std::string& tag, cond::Time_t lowerGroup, cond::Time_t upperGroup,
135  const boost::posix_time::ptime& snapshotTime,
136  std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs);
137  bool getLastIov( const std::string& tag, const boost::posix_time::ptime& snapshotTime, cond::Time_t& since, cond::Hash& hash );
138  bool getSize( const std::string& tag, const boost::posix_time::ptime& snapshotTime, size_t& size );
139  bool getRange( const std::string& tag, cond::Time_t begin, cond::Time_t end,
140  const boost::posix_time::ptime& snapshotTime, std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs );
141  void insertOne( const std::string& tag, cond::Time_t since, cond::Hash payloadHash, const boost::posix_time::ptime& insertTime);
142  void insertMany( const std::string& tag, const std::vector<std::tuple<cond::Time_t,cond::Hash,boost::posix_time::ptime> >& iovs );
143  void erase( const std::string& tag );
144  private:
145  coral::ISchema& m_schema;
146  };
147  }
148 
149  conddb_table( TAG_LOG ) {
150 
152  conddb_column( EVENT_TIME, boost::posix_time::ptime );
158 
159  class Table : public ITagLogTable {
160  public:
161  explicit Table( coral::ISchema& schema );
162  virtual ~Table(){}
163  bool exists();
164  void create();
165  void insert( const std::string& tag, const boost::posix_time::ptime& eventTime, const std::string& userName, const std::string& hostName,
166  const std::string& command, const std::string& action, const std::string& userText );
167  private:
168  coral::ISchema& m_schema;
169  };
170  }
171 
172  class IOVSchema : public IIOVSchema {
173  public:
174  explicit IOVSchema( coral::ISchema& schema );
175  virtual ~IOVSchema(){}
176  bool exists();
177  bool create();
178  ITagTable& tagTable();
179  IIOVTable& iovTable();
180  ITagLogTable& tagLogTable();
181  IPayloadTable& payloadTable();
182  private:
187  };
188 
189  }
190 }
191 #endif
size
Write out results.
static std::string tableName()
Definition: IOVSchema.h:120
static constexpr unsigned int SINCE_GROUP_SIZE
Definition: Time.h:39
static std::string group()
Definition: IOVSchema.h:93
def create(alignables, pedeDump, additionalData, outputFile, config)
static std::string tableName()
Definition: IOVSchema.h:111
#define conddb_column(...)
Definition: DbCore.h:73
#define constexpr
PAYLOAD::Table m_payloadTable
Definition: IOVSchema.h:186
coral::ISchema & m_schema
Definition: IOVSchema.h:44
TimeType
Definition: Time.h:21
coral::ISchema & m_schema
Definition: IOVSchema.h:145
unsigned long long Time_t
Definition: Time.h:16
std::string Hash
Definition: Types.h:45
#define end
Definition: vmac.h:37
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
static std::string fullyQualifiedName()
Definition: IOVSchema.h:121
static std::string tableName()
Definition: IOVSchema.h:89
static std::string tableName()
Definition: IOVSchema.h:102
TAG_LOG::Table m_tagLogTable
Definition: IOVSchema.h:185
static std::string fullyQualifiedName()
Definition: IOVSchema.h:90
static unsigned int PAYLOAD_HASH_SIZE
Definition: IOVSchema.h:50
static std::string fullyQualifiedName()
Definition: IOVSchema.h:103
Definition: plugin.cc:24
#define begin
Definition: vmac.h:30
#define update(a, b)
SynchronizationType
Definition: Types.h:29
#define conddb_table(NAME)
Definition: DbCore.h:48
static std::string fullyQualifiedName()
Definition: IOVSchema.h:112