CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
cond::persistency::IOV::Table Class Reference

#include <IOVSchema.h>

Inheritance diagram for cond::persistency::IOV::Table:
cond::persistency::IIOVTable

Public Member Functions

void create () override
 
void erase (const std::string &tag) override
 
bool exists () override
 
size_t getGroups (const std::string &tag, const boost::posix_time::ptime &snapshotTime, unsigned long long groupSize, std::vector< cond::Time_t > &groups) override
 
bool getLastIov (const std::string &tag, const boost::posix_time::ptime &snapshotTime, cond::Time_t &since, cond::Hash &hash) override
 
bool getRange (const std::string &tag, cond::Time_t begin, cond::Time_t end, const boost::posix_time::ptime &snapshotTime, std::vector< std::tuple< cond::Time_t, cond::Hash > > &iovs) override
 
bool getSize (const std::string &tag, const boost::posix_time::ptime &snapshotTime, size_t &size) override
 
void insertMany (const std::string &tag, const std::vector< std::tuple< cond::Time_t, cond::Hash, boost::posix_time::ptime > > &iovs) override
 
void insertOne (const std::string &tag, cond::Time_t since, cond::Hash payloadHash, const boost::posix_time::ptime &insertTime) override
 
size_t select (const std::string &tag, cond::Time_t lowerGroup, cond::Time_t upperGroup, const boost::posix_time::ptime &snapshotTime, std::vector< std::tuple< cond::Time_t, cond::Hash > > &iovs) override
 
 Table (coral::ISchema &schema)
 
 ~Table () override
 
- Public Member Functions inherited from cond::persistency::IIOVTable
virtual ~IIOVTable ()
 

Private Attributes

coral::ISchema & m_schema
 

Detailed Description

Definition at line 126 of file IOVSchema.h.

Constructor & Destructor Documentation

Table::Table ( coral::ISchema &  schema)
explicit

Definition at line 123 of file IOVSchema.cc.

123  :
124  m_schema( schema ){
125  }
coral::ISchema & m_schema
Definition: IOVSchema.h:145
cond::persistency::IOV::Table::~Table ( )
inlineoverride

Member Function Documentation

void Table::create ( )
overridevirtual

Implements cond::persistency::IIOVTable.

Definition at line 131 of file IOVSchema.cc.

References exists(), cond::persistency::TableDescription< Types >::get(), m_schema, cond::persistency::TableDescription< Types >::setForeignKey(), cond::persistency::TableDescription< Types >::setPrimaryKey(), cond::persistency::throwException(), and cond::persistency::IOV::tname.

Referenced by cond::persistency::IOVSchema::create(), and o2olib.O2OTool::execute().

131  {
132  if( exists()){
133  throwException( "IOV table already exists in this schema.",
134  "IOV::Schema::create");
135  }
136 
137  TableDescription< TAG_NAME, SINCE, PAYLOAD_HASH, INSERTION_TIME > descr( tname );
138  descr.setPrimaryKey< TAG_NAME, SINCE, INSERTION_TIME >();
139  descr.setForeignKey< TAG_NAME, TAG::NAME >( "TAG_NAME_FK" );
140  descr.setForeignKey< PAYLOAD_HASH, PAYLOAD::HASH >( "PAYLOAD_HASH_FK" );
141  createTable( m_schema, descr.get() );
142  }
coral::ISchema & m_schema
Definition: IOVSchema.h:145
static constexpr TimeType HASH
Definition: Time.h:37
static char const * tname
Definition: IOVSchema.h:79
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
void Table::erase ( const std::string &  tag)
overridevirtual

Implements cond::persistency::IIOVTable.

Definition at line 259 of file IOVSchema.cc.

References cond::persistency::DeleteBuffer::addWhereCondition(), edmScanValgrind::buffer, m_schema, GlobalPosition_Frontier_DevDB_cff::tag, and cond::persistency::IOV::tname.

259  {
260  DeleteBuffer buffer;
261  buffer.addWhereCondition<TAG_NAME>( tag );
262  deleteFromTable( m_schema, tname, buffer );
263  }
coral::ISchema & m_schema
Definition: IOVSchema.h:145
static char const * tname
Definition: IOVSchema.h:79
bool Table::exists ( )
overridevirtual

Implements cond::persistency::IIOVTable.

Definition at line 127 of file IOVSchema.cc.

References m_schema, and cond::persistency::IOV::tname.

Referenced by create(), and cond::persistency::IOVSchema::exists().

127  {
128  return existsTable( m_schema, tname );
129  }
coral::ISchema & m_schema
Definition: IOVSchema.h:145
static char const * tname
Definition: IOVSchema.h:79
size_t Table::getGroups ( const std::string &  tag,
const boost::posix_time::ptime &  snapshotTime,
unsigned long long  groupSize,
std::vector< cond::Time_t > &  groups 
)
overridevirtual

Implements cond::persistency::IIOVTable.

Definition at line 144 of file IOVSchema.cc.

References cond::persistency::Query< Types >::addCondition(), cond::persistency::Query< Types >::addOrderClause(), cond::persistency::IOV::SINCE_GROUP::group(), cond::persistency::Query< Types >::groupBy(), m_schema, lumiQueryAPI::q, loadRecoTauTagMVAsFromPrepDB_cfi::snapshotTime, and GlobalPosition_Frontier_DevDB_cff::tag.

147  {
148  Query< SINCE_GROUP > q( m_schema, true );
149  q.addCondition<TAG_NAME>( tag );
150  if( !snapshotTime.is_not_a_date_time() ){
151  q.addCondition<INSERTION_TIME>( snapshotTime,"<=" );
152  }
153  q.groupBy(SINCE_GROUP::group(gSize));
154  q.addOrderClause<SINCE_GROUP>();
155  for( auto row : q ){
156  groups.push_back(std::get<0>(row));
157  }
158  return q.retrievedRows();
159  }
static std::string group(unsigned long long groupSize)
Definition: IOVSchema.h:93
coral::ISchema & m_schema
Definition: IOVSchema.h:145
bool Table::getLastIov ( const std::string &  tag,
const boost::posix_time::ptime &  snapshotTime,
cond::Time_t since,
cond::Hash hash 
)
overridevirtual

Implements cond::persistency::IIOVTable.

Definition at line 182 of file IOVSchema.cc.

References cond::persistency::Query< Types >::addCondition(), cond::persistency::Query< Types >::addOrderClause(), funct::false, m_schema, lumiQueryAPI::q, loadRecoTauTagMVAsFromPrepDB_cfi::snapshotTime, and GlobalPosition_Frontier_DevDB_cff::tag.

182  {
183  Query< SINCE, PAYLOAD_HASH > q( m_schema );
184  q.addCondition<TAG_NAME>( tag );
185  if( !snapshotTime.is_not_a_date_time() ){
186  q.addCondition<INSERTION_TIME>( snapshotTime,"<=" );
187  }
188  q.addOrderClause<SINCE>( false );
189  q.addOrderClause<INSERTION_TIME>( false );
190  for ( auto row : q ) {
191  since = std::get<0>(row);
192  hash = std::get<1>(row);
193  return true;
194  }
195  return false;
196  }
coral::ISchema & m_schema
Definition: IOVSchema.h:145
bool Table::getRange ( const std::string &  tag,
cond::Time_t  begin,
cond::Time_t  end,
const boost::posix_time::ptime &  snapshotTime,
std::vector< std::tuple< cond::Time_t, cond::Hash > > &  iovs 
)
overridevirtual

Implements cond::persistency::IIOVTable.

Definition at line 211 of file IOVSchema.cc.

References cond::persistency::Query< Types >::addCondition(), cond::persistency::Query< Types >::addOrderClause(), begin, end, funct::false, m_schema, q1, cond::persistency::IOV::INSERTION_TIME::size, loadRecoTauTagMVAsFromPrepDB_cfi::snapshotTime, and GlobalPosition_Frontier_DevDB_cff::tag.

213  {
214  Query< MAX_SINCE > q0( m_schema );
215  q0.addCondition<TAG_NAME>( tag );
216  q0.addCondition<SINCE>( begin, "<=");
217  if( !snapshotTime.is_not_a_date_time() ){
218  q0.addCondition<INSERTION_TIME>( snapshotTime,"<=" );
219  }
220  cond::Time_t lower_since = 0;
221  for( auto row: q0 ){
222  lower_since = std::get<0>( row );
223  }
224  if ( !lower_since ) return false;
225  Query< SINCE, PAYLOAD_HASH > q1( m_schema );
226  q1.addCondition<TAG_NAME>( tag );
227  q1.addCondition<SINCE>( lower_since, ">=");
228  if( !snapshotTime.is_not_a_date_time() ){
229  q1.addCondition<INSERTION_TIME>( snapshotTime,"<=" );
230  }
231  q1.addCondition<SINCE>( end, "<=");
232  q1.addOrderClause<SINCE>();
233  q1.addOrderClause<INSERTION_TIME>( false );
234  size_t initialSize = iovs.size();
235  for( auto row: q1 ){
236  // starting from the second iov in the array, skip the rows with older timestamp
237  if( iovs.size()-initialSize && std::get<0>(iovs.back()) == std::get<0>(row) ) continue;
238  iovs.push_back( row );
239  }
240  return iovs.size()-initialSize;
241  }
coral::ISchema & m_schema
Definition: IOVSchema.h:145
unsigned long long Time_t
Definition: Time.h:16
#define end
Definition: vmac.h:39
double q1[4]
Definition: TauolaWrapper.h:87
#define begin
Definition: vmac.h:32
bool Table::getSize ( const std::string &  tag,
const boost::posix_time::ptime &  snapshotTime,
size_t &  size 
)
overridevirtual

Implements cond::persistency::IIOVTable.

Definition at line 198 of file IOVSchema.cc.

References cond::persistency::Query< Types >::addCondition(), m_schema, lumiQueryAPI::q, loadRecoTauTagMVAsFromPrepDB_cfi::snapshotTime, and GlobalPosition_Frontier_DevDB_cff::tag.

198  {
199  Query< SEQUENCE_SIZE > q( m_schema );
200  q.addCondition<TAG_NAME>( tag );
201  if( !snapshotTime.is_not_a_date_time() ){
202  q.addCondition<INSERTION_TIME>( snapshotTime,"<=" );
203  }
204  for ( auto row : q ) {
205  size = std::get<0>(row);
206  return true;
207  }
208  return false;
209  }
size
Write out results.
coral::ISchema & m_schema
Definition: IOVSchema.h:145
void Table::insertMany ( const std::string &  tag,
const std::vector< std::tuple< cond::Time_t, cond::Hash, boost::posix_time::ptime > > &  iovs 
)
overridevirtual

Implements cond::persistency::IIOVTable.

Definition at line 251 of file IOVSchema.cc.

References cond::persistency::BulkInserter< Types >::flush(), cond::persistency::BulkInserter< Types >::insert(), m_schema, and cond::persistency::IOV::tname.

252  {
253  BulkInserter< TAG_NAME, SINCE, PAYLOAD_HASH, INSERTION_TIME > inserter( m_schema, tname );
254  for( auto row : iovs ) inserter.insert( std::tuple_cat( std::tie(tag),row ) );
255 
256  inserter.flush();
257  }
coral::ISchema & m_schema
Definition: IOVSchema.h:145
static char const * tname
Definition: IOVSchema.h:79
void Table::insertOne ( const std::string &  tag,
cond::Time_t  since,
cond::Hash  payloadHash,
const boost::posix_time::ptime &  insertTime 
)
overridevirtual

Implements cond::persistency::IIOVTable.

Definition at line 243 of file IOVSchema.cc.

References cond::persistency::RowBuffer< Columns >::get(), m_schema, and cond::persistency::IOV::tname.

246  {
247  RowBuffer< TAG_NAME, SINCE, PAYLOAD_HASH, INSERTION_TIME > dataToInsert( std::tie( tag, since, payloadHash, insertTimeStamp ) );
248  insertInTable( m_schema, tname, dataToInsert.get() );
249  }
coral::ISchema & m_schema
Definition: IOVSchema.h:145
static char const * tname
Definition: IOVSchema.h:79
size_t Table::select ( const std::string &  tag,
cond::Time_t  lowerGroup,
cond::Time_t  upperGroup,
const boost::posix_time::ptime &  snapshotTime,
std::vector< std::tuple< cond::Time_t, cond::Hash > > &  iovs 
)
overridevirtual

Implements cond::persistency::IIOVTable.

Definition at line 161 of file IOVSchema.cc.

References cond::persistency::Query< Types >::addCondition(), cond::persistency::Query< Types >::addOrderClause(), funct::false, m_schema, cond::time::MAX_VAL(), lumiQueryAPI::q, cond::persistency::IOV::INSERTION_TIME::size, loadRecoTauTagMVAsFromPrepDB_cfi::snapshotTime, and GlobalPosition_Frontier_DevDB_cff::tag.

Referenced by Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Views.LineDecayView.LineDecayContainer::mousePressEvent(), Vispa.Gui.PortConnection.PointToPointConnection::mousePressEvent(), Vispa.Gui.VispaWidget.VispaWidget::mousePressEvent(), and Vispa.Views.AbstractView.AbstractView::restoreSelection().

163  {
164  Query< SINCE, PAYLOAD_HASH > q( m_schema );
165  q.addCondition<TAG_NAME>( tag );
166  if( lowerSinceGroup > 0 ) q.addCondition<SINCE>( lowerSinceGroup, ">=" );
167  if( upperSinceGroup < cond::time::MAX_VAL ) q.addCondition<SINCE>( upperSinceGroup, "<" );
168  if( !snapshotTime.is_not_a_date_time() ){
169  q.addCondition<INSERTION_TIME>( snapshotTime,"<=" );
170  }
171  q.addOrderClause<SINCE>();
172  q.addOrderClause<INSERTION_TIME>( false );
173  size_t initialSize = iovs.size();
174  for ( auto row : q ) {
175  // starting from the second iov in the array, skip the rows with older timestamp
176  if( iovs.size()-initialSize && std::get<0>(iovs.back()) == std::get<0>(row) ) continue;
177  iovs.push_back( row );
178  }
179  return iovs.size()-initialSize;
180  }
coral::ISchema & m_schema
Definition: IOVSchema.h:145
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())

Member Data Documentation

coral::ISchema& cond::persistency::IOV::Table::m_schema
private