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 
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 );
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 );
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 
84  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  // temporary... to be removed after the changeover.
139  table( TAG_MIGRATION ) {
140 
145  column( INSERTION_TIME, boost::posix_time::ptime );
146 
147  class Table : public ITagMigrationTable {
148  public:
149  explicit Table( coral::ISchema& schema );
150  virtual ~Table(){}
151  bool exists();
152  void create();
153  bool select( const std::string& sourceAccount, const std::string& sourceTag, std::string& tagName, int& statusCode);
154  void insert( const std::string& sourceAccount, const std::string& sourceTag, const std::string& tagName,
155  int statusCode, const boost::posix_time::ptime& insertionTime);
156  void updateValidationCode( const std::string& sourceAccount, const std::string& sourceTag, int statusCode );
157  private:
158  coral::ISchema& m_schema;
159  };
160  }
161 
162  // temporary... to be removed after the changeover.
163  table( PAYLOAD_MIGRATION ) {
164 
168  column( INSERTION_TIME, boost::posix_time::ptime );
169 
170  class Table : public IPayloadMigrationTable {
171  public:
172  explicit Table( coral::ISchema& schema );
173  virtual ~Table(){}
174  bool exists();
175  void create();
176  bool select( const std::string& sourceAccount, const std::string& sourceToken, std::string& payloadId );
177  void insert( const std::string& sourceAccount, const std::string& sourceToken, const std::string& payloadId,
178  const boost::posix_time::ptime& insertionTime);
179  void update( const std::string& sourceAccount, const std::string& sourceToken, const std::string& payloadId,
180  const boost::posix_time::ptime& insertionTime);
181  private:
182  coral::ISchema& m_schema;
183  };
184  }
185 
186  class IOVSchema : public IIOVSchema {
187  public:
188  explicit IOVSchema( coral::ISchema& schema );
189  virtual ~IOVSchema(){}
190  bool exists();
191  bool create();
192  ITagTable& tagTable();
193  IIOVTable& iovTable();
198  private:
204  };
205  }
206 }
207 #endif
static constexpr unsigned int SINCE_GROUP_SIZE
Definition: Time.h:37
static std::string group()
Definition: IOVSchema.h:93
#define constexpr
PAYLOAD::Table m_payloadTable
Definition: IOVSchema.h:201
coral::ISchema & m_schema
Definition: IOVSchema.h:44
TimeType
Definition: Time.h:21
std::string parsePoolToken(const std::string &)
Definition: IOVSchema.cc:512
coral::ISchema & m_schema
Definition: IOVSchema.h:134
unsigned long long Time_t
Definition: Time.h:16
TAG_MIGRATION::Table m_tagMigrationTable
Definition: IOVSchema.h:202
std::string Hash
Definition: Types.h:43
IPayloadTable & payloadTable()
Definition: IOVSchema.cc:500
PAYLOAD_MIGRATION::Table m_payloadMigrationTable
Definition: IOVSchema.h:203
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
ITagMigrationTable & tagMigrationTable()
Definition: IOVSchema.cc:504
static std::string tableName()
Definition: IOVSchema.h:89
static std::string tableName()
Definition: IOVSchema.h:102
tuple description
Definition: idDealer.py:66
#define table(NAME)
Definition: DbCore.h:49
static std::string fullyQualifiedName()
Definition: IOVSchema.h:90
IOVSchema(coral::ISchema &schema)
Definition: IOVSchema.cc:466
#define column(...)
Definition: DbCore.h:74
static unsigned int PAYLOAD_HASH_SIZE
Definition: IOVSchema.h:50
static unsigned int PAYLOAD_HASH_SIZE
Definition: GTSchema.h:43
static std::string fullyQualifiedName()
Definition: IOVSchema.h:103
#define update(a, b)
SynchronizationType
Definition: Types.h:31
IPayloadMigrationTable & payloadMigrationTable()
Definition: IOVSchema.cc:508
SurfaceDeformation * create(int type, const std::vector< double > &params)
tuple size
Write out results.