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 
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::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 = boost::lexical_cast<std::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  class Table : public IIOVTable {
109  public:
110  explicit Table( coral::ISchema& schema );
111  virtual ~Table(){}
112  bool exists();
113  void create();
114  size_t selectGroups( const std::string& tag, std::vector<cond::Time_t>& groups );
115  size_t selectSnapshotGroups( const std::string& tag, const boost::posix_time::ptime& snapshotTime,
116  std::vector<cond::Time_t>& groups );
117  size_t selectLatestByGroup( const std::string& tag, cond::Time_t lowerGroup, cond::Time_t upperGroup,
118  std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs);
119  size_t selectSnapshotByGroup( const std::string& tag, cond::Time_t lowerGroup, cond::Time_t upperGroup,
120  const boost::posix_time::ptime& snapshotTime,
121  std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs);
122  size_t selectLatest( const std::string& tag, std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs);
123  size_t selectSnapshot( const std::string& tag,
124  const boost::posix_time::ptime& snapshotTime,
125  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 getSnapshotLastIov( const std::string& tag, const boost::posix_time::ptime& snapshotTime, cond::Time_t& since, cond::Hash& hash );
128  bool getSize( const std::string& tag, size_t& size );
129  bool getSnapshotSize( const std::string& tag, const boost::posix_time::ptime& snapshotTime, size_t& size );
130  void insertOne( const std::string& tag, cond::Time_t since, cond::Hash payloadHash, const boost::posix_time::ptime& insertTime);
131  void insertMany( const std::string& tag, const std::vector<std::tuple<cond::Time_t,cond::Hash,boost::posix_time::ptime> >& iovs );
132  void erase( const std::string& tag );
133  private:
134  coral::ISchema& m_schema;
135  };
136  }
137 
138  conddb_table( TAG_LOG ) {
139 
141  conddb_column( EVENT_TIME, boost::posix_time::ptime );
147 
148  class Table : public ITagLogTable {
149  public:
150  explicit Table( coral::ISchema& schema );
151  virtual ~Table(){}
152  bool exists();
153  void create();
154  void insert( const std::string& tag, const boost::posix_time::ptime& eventTime, const std::string& userName, const std::string& hostName,
155  const std::string& command, const std::string& action, const std::string& userText );
156  private:
157  coral::ISchema& m_schema;
158  };
159  }
160 
161  class IOVSchema : public IIOVSchema {
162  public:
163  explicit IOVSchema( coral::ISchema& schema );
164  virtual ~IOVSchema(){}
165  bool exists();
166  bool create();
167  ITagTable& tagTable();
168  IIOVTable& iovTable();
171  private:
176  };
177  }
178 }
179 #endif
static constexpr unsigned int SINCE_GROUP_SIZE
Definition: Time.h:37
static std::string group()
Definition: IOVSchema.h:93
ITagLogTable & tagLogTable()
Definition: IOVSchema.cc:439
tuple schema
Definition: dataDML.py:2334
#define conddb_column(...)
Definition: DbCore.h:74
#define constexpr
PAYLOAD::Table m_payloadTable
Definition: IOVSchema.h:175
coral::ISchema & m_schema
Definition: IOVSchema.h:44
TimeType
Definition: Time.h:21
coral::ISchema & m_schema
Definition: IOVSchema.h:134
unsigned long long Time_t
Definition: Time.h:16
std::string Hash
Definition: Types.h:45
IPayloadTable & payloadTable()
Definition: IOVSchema.cc:443
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
static std::string tableName()
Definition: IOVSchema.h:89
static std::string tableName()
Definition: IOVSchema.h:102
TAG_LOG::Table m_tagLogTable
Definition: IOVSchema.h:174
tuple description
Definition: idDealer.py:66
static std::string fullyQualifiedName()
Definition: IOVSchema.h:90
IOVSchema(coral::ISchema &schema)
Definition: IOVSchema.cc:405
static unsigned int PAYLOAD_HASH_SIZE
Definition: IOVSchema.h:50
static unsigned int PAYLOAD_HASH_SIZE
Definition: GTSchema.h:43
string command
Definition: mps_check.py:26
string action
Definition: mps_fire.py:28
static std::string fullyQualifiedName()
Definition: IOVSchema.h:103
#define update(a, b)
SynchronizationType
Definition: Types.h:29
tuple size
Write out results.
#define conddb_table(NAME)
Definition: DbCore.h:49