From 9142cbf64cf9528172349d29b39a5dc759c283c6 Mon Sep 17 00:00:00 2001 From: Frank Winklmeier <frank.winklmeier@cern.ch> Date: Wed, 20 Feb 2019 17:42:37 +0100 Subject: [PATCH] WriteCondHandle: Extend duplicate cond object range if possible When recording a conditions object that already exists, try to extend its range. This will only work for non-MIXED containers. This should allow IOV changes during the run without any special code on the client side (ATEAM-477). --- .../DataModelTestDataCommon/src/CondAlg1.cxx | 8 ++------ Control/StoreGate/StoreGate/WriteCondHandle.h | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Control/DataModelTest/DataModelTestDataCommon/src/CondAlg1.cxx b/Control/DataModelTest/DataModelTestDataCommon/src/CondAlg1.cxx index d6738c64ceb..f9558368f57 100644 --- a/Control/DataModelTest/DataModelTestDataCommon/src/CondAlg1.cxx +++ b/Control/DataModelTest/DataModelTestDataCommon/src/CondAlg1.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /* */ @@ -57,11 +57,7 @@ StatusCode CondAlg1::execute (const EventContext& ctx) const SG::WriteCondHandle<DMTest::S2> scond (m_scondKey, ctx); auto s2 = std::make_unique<DMTest::S2> (xint*100); - StatusCode sc = scond.record (range, std::move(s2)); - ATH_CHECK( sc ); - if (CondContBase::Category::isDuplicate (sc)) { - ATH_CHECK( scond.extendLastRange (range, ctx) ); - } + ATH_CHECK( scond.record (range, std::move(s2) ) ); return StatusCode::SUCCESS; } diff --git a/Control/StoreGate/StoreGate/WriteCondHandle.h b/Control/StoreGate/StoreGate/WriteCondHandle.h index 52ac4a0f7d5..530d1aace92 100644 --- a/Control/StoreGate/StoreGate/WriteCondHandle.h +++ b/Control/StoreGate/StoreGate/WriteCondHandle.h @@ -63,7 +63,7 @@ namespace SG { private: - const EventIDBase& m_eid; + const EventContext& m_ctx; CondCont<T>* m_cc {nullptr}; const SG::WriteCondHandleKey<T>& m_hkey; @@ -82,7 +82,7 @@ namespace SG { template <typename T> WriteCondHandle<T>::WriteCondHandle( const SG::WriteCondHandleKey<T>& key, const EventContext& ctx) : - m_eid(ctx.eventID()), + m_ctx(ctx), m_cc( key.getCC() ), m_hkey(key) { @@ -135,6 +135,17 @@ namespace SG { #endif sc = StatusCode::SUCCESS; } + // If the object exists already, try to extend it + else if (CondContBase::Category::isDuplicate (sc) && + m_cc->keyType() != CondContBase::KeyType::MIXED) { + sc = this->extendLastRange(r, m_ctx); + if (sc.isFailure()) { + msg << MSG::ERROR + << "WriteCondHandle::record() : cannot extend duplicate range" + << endmsg; + return StatusCode::FAILURE; + } + } return sc; } @@ -184,7 +195,7 @@ namespace SG { bool WriteCondHandle<T>::isValid() { - return (m_cc->valid(m_eid)); + return (m_cc->valid(m_ctx.eventID())); } } -- GitLab