ATLAS Offline Software
Loading...
Searching...
No Matches
AthenaPoolCnvSvc.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
9
10#include "AthenaPoolCnvSvc.h"
11
12#include "GaudiKernel/AttribStringParser.h"
13#include "GaudiKernel/ClassID.h"
14#include "GaudiKernel/FileIncident.h"
15#include "GaudiKernel/IIncidentSvc.h"
16#include "GaudiKernel/IIoComponentMgr.h"
17#include "GaudiKernel/IOpaqueAddress.h"
18
23
24#include "StorageSvc/DbReflex.h"
26
27#include <algorithm>
28#include <charconv>
29#include <format>
30#include <iomanip>
31#include <sstream>
32
33//______________________________________________________________________________
34// Initialize the service.
36 // Retrieve PoolSvc
37 ATH_CHECK(m_poolSvc.retrieve());
38 // Retrieve ClassIDSvc
39 ATH_CHECK(m_clidSvc.retrieve());
40 // Register this service for 'I/O' events
41 ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", name());
42 ATH_CHECK(iomgr.retrieve());
43 if (!iomgr->io_register(this).isSuccess()) {
44 ATH_MSG_FATAL("Could not register myself with the IoComponentMgr !");
45 return(StatusCode::FAILURE);
46 }
47 // Global POOL container naming scheme
50 } else {
51 ATH_MSG_ERROR(std::format("Invalid PoolContainerNamingScheme: {}, see APRDefaults.h for the full list.", m_containerNamingSchemeProp.value()));
52 return StatusCode::FAILURE;
53 }
54 // Extracting INPUT POOL ItechnologySpecificAttributes for Domain, Database and Container.
56 // Extracting the INPUT POOL ItechnologySpecificAttributes which are to be printed for each event
58 // Setup incident for EndEvent to print out attributes each event
59 ServiceHandle<IIncidentSvc> incSvc("IncidentSvc", name());
60 long int pri = 1000;
61 if (!m_inputPoolAttrPerEvent.value().empty()) {
62 // Set to be listener for EndEvent
63 incSvc->addListener(this, "EndEvent", pri);
64 ATH_MSG_DEBUG("Subscribed to EndEvent for printing out input file attributes.");
65 }
66 if (!processPoolAttributes(m_inputAttr, "", IPoolSvc::kInputStream, false, true, true).isSuccess()) {
67 ATH_MSG_DEBUG("setInputAttribute failed setting POOL domain attributes.");
68 }
69
70 // Load these dictionaries now, so we don't need to try to do so
71 // while multiple threads are running.
72 TClass::GetClass ("TLeafI");
73 TClass::GetClass ("TLeafL");
74 TClass::GetClass ("TLeafD");
75 TClass::GetClass ("TLeafF");
76
77 return(StatusCode::SUCCESS);
78}
79//______________________________________________________________________________
81 ATH_MSG_DEBUG("I/O reinitialization...");
83 return(StatusCode::SUCCESS);
84}
85//______________________________________________________________________________
86void AthenaPoolCnvSvc::flushDataHeaderForms(const std::string& streamName) {
87 // Write remaining DataHeaderForms for a given streamName, "*"" means all
88 auto DHCnvListener = dynamic_cast<IIncidentListener*>( converter( ClassID_traits<DataHeader>::ID() ) );
89 FileIncident incident(name(), "WriteDataHeaderForms", streamName);
90 if( DHCnvListener ) DHCnvListener->handle(incident);
91}
92//______________________________________________________________________________
94 ATH_MSG_VERBOSE("stop()");
95 // In case of direct writing without an OutputStream, this should be a good time to flush DHForms
97 return StatusCode::SUCCESS;
98}
99//______________________________________________________________________________
101 ATH_MSG_VERBOSE("Finalizing...");
102 // Some algorithms write in finalize(), flush DHForms if any are left
104 // Release ClassIDSvc
105 if (!m_clidSvc.release().isSuccess()) {
106 ATH_MSG_WARNING("Cannot release ClassIDSvc.");
107 }
108 // Release PoolSvc
109 if (!m_poolSvc.release().isSuccess()) {
110 ATH_MSG_WARNING("Cannot release PoolSvc.");
111 }
112 // Print Performance Statistics
113 // The pattern AthenaPoolCnvSvc.*PerfStats is ignored in AtlasTest/TestTools/share/post.sh
114 const std::string msgPrefix{"PerfStats "};
115 ATH_MSG_INFO(msgPrefix << std::string(40, '-'));
116 ATH_MSG_INFO(msgPrefix << "Timing Measurements for AthenaPoolCnvSvc");
117 ATH_MSG_INFO(msgPrefix << std::string(40, '-'));
118 for(const auto& [key, value] : m_chronoMap) {
119 ATH_MSG_INFO(msgPrefix << "| " << std::left << std::setw(15) << key << " | "
120 << std::right << std::setw(15) << std::fixed << std::setprecision(0) << value << " ms |");
121 }
122 ATH_MSG_INFO(msgPrefix << std::string(40, '-'));
123
124 m_cnvs.clear();
125 m_cnvs.shrink_to_fit();
126 return(StatusCode::SUCCESS);
127}
128//______________________________________________________________________________
130 ATH_MSG_DEBUG("I/O finalization...");
131 return(StatusCode::SUCCESS);
132}
133//______________________________________________________________________________
134StatusCode AthenaPoolCnvSvc::createObj(IOpaqueAddress* pAddress, DataObject*& refpObject) {
135 assert(pAddress);
136 std::string objName = "ALL";
137 if (m_useDetailChronoStat.value()) {
138 if (m_clidSvc->getTypeNameOfID(pAddress->clID(), objName).isFailure()) {
139 objName = std::to_string(pAddress->clID());
140 }
141 objName += '#';
142 objName += *(pAddress->par() + 1);
143 }
144 // StopWatch listens from here until the end of this current scope
145 PMonUtils::BasicStopWatch stopWatch("cObj_" + objName, m_chronoMap);
146 if (!m_persSvcPerInputType.value().empty()) { // Use separate PersistencySvc for each input data type
147 TokenAddress* tokAddr = dynamic_cast<TokenAddress*>(pAddress);
148 if (tokAddr != nullptr && tokAddr->getToken() != nullptr && (tokAddr->getToken()->contID().starts_with(m_persSvcPerInputType.value() + "(") || tokAddr->getToken()->contID().starts_with(m_persSvcPerInputType.value() + "_"))) {
149 const unsigned int maxContext = m_poolSvc->getInputContextMapSize();
150 const unsigned int auxContext = m_poolSvc->getInputContext(tokAddr->getToken()->classID().toString() + tokAddr->getToken()->dbID().toString(), 1);
151 if (m_poolSvc->getInputContextMapSize() > maxContext) {
152 if (!processPoolAttributes(m_inputAttr, m_lastInputFileName, auxContext, false, true, false).isSuccess()) {
153 ATH_MSG_DEBUG("setInputAttribute failed setting POOL database/container attributes.");
154 }
155 }
156 char text[32];
157 const std::string contextStr = std::format("[CTXT={:08X}]", auxContext);
158 std::strncpy(text, contextStr.c_str(), sizeof(text) - 1);
159 text[sizeof(text) - 1] = '\0';
160 tokAddr->getToken()->setAuxString(text);
161 }
162 }
163 // Forward to base class createObj
164 StatusCode status = ::AthCnvSvc::createObj(pAddress, refpObject);
165 return(status);
166}
167//______________________________________________________________________________
168StatusCode AthenaPoolCnvSvc::createRep(DataObject* pObject, IOpaqueAddress*& refpAddress) {
169 assert(pObject);
170 std::string objName = "ALL";
171 if (m_useDetailChronoStat.value()) {
172 if (m_clidSvc->getTypeNameOfID(pObject->clID(), objName).isFailure()) {
173 objName = std::to_string(pObject->clID());
174 }
175 objName += '#';
176 objName += pObject->registry()->name();
177 }
178 // StopWatch listens from here until the end of this current scope
179 PMonUtils::BasicStopWatch stopWatch("cRep_" + objName, m_chronoMap);
180 StatusCode status = StatusCode::FAILURE;
181 if (pObject->clID() == 1) {
182 // No transient object was found use cnv to write default persistent object
183 SG::DataProxy* proxy = dynamic_cast<SG::DataProxy*>(pObject->registry());
184 if (proxy != nullptr) {
185 IConverter* cnv = converter(proxy->clID());
186 status = cnv->createRep(pObject, refpAddress);
187 }
188 } else {
189 // Forward to base class createRep
190 try {
191 status = ::AthCnvSvc::createRep(pObject, refpAddress);
192 } catch(std::runtime_error& e) {
193 ATH_MSG_FATAL(e.what());
194 }
195 }
196 return(status);
197}
198//______________________________________________________________________________
199StatusCode AthenaPoolCnvSvc::fillRepRefs(IOpaqueAddress* pAddress, DataObject* pObject) {
200 assert(pObject);
201 std::string objName = "ALL";
202 if (m_useDetailChronoStat.value()) {
203 if (m_clidSvc->getTypeNameOfID(pObject->clID(), objName).isFailure()) {
204 objName = std::to_string(pObject->clID());
205 }
206 objName += '#';
207 objName += pObject->registry()->name();
208 }
209 // StopWatch listens from here until the end of this current scope
210 PMonUtils::BasicStopWatch stopWatch("fRep_" + objName, m_chronoMap);
211 StatusCode status = StatusCode::FAILURE;
212 if (pObject->clID() == 1) {
213 // No transient object was found use cnv to write default persistent object
214 SG::DataProxy* proxy = dynamic_cast<SG::DataProxy*>(pObject->registry());
215 if (proxy != nullptr) {
216 IConverter* cnv = converter(proxy->clID());
217 status = cnv->fillRepRefs(pAddress, pObject);
218 }
219 } else {
220 // Forward to base class fillRepRefs
221 try {
222 status = ::AthCnvSvc::fillRepRefs(pAddress, pObject);
223 } catch(std::runtime_error& e) {
224 ATH_MSG_FATAL(e.what());
225 }
226 }
227 return(status);
228}
229//______________________________________________________________________________
230StatusCode AthenaPoolCnvSvc::connectOutput(const std::string& outputConnectionSpec,
231 const std::string& openMode) {
232 std::string outputConnection = outputConnectionSpec.substr(0, outputConnectionSpec.find('['));
233 unsigned int contextId = outputContextId(outputConnection);
234 Io::IoFlag mode = openMode == "APPEND" ? Io::APPEND : Io::WRITE;
235 try {
236 if (!m_poolSvc->connect(mode, contextId).isSuccess()) {
237 ATH_MSG_ERROR("connectOutput FAILED to open an " << openMode << " transaction.");
238 return(StatusCode::FAILURE);
239 }
240 } catch (std::exception& e) {
241 ATH_MSG_ERROR("connectOutput - caught exception: " << e.what());
242 return(StatusCode::FAILURE);
243 }
244 std::unique_lock<std::mutex> lock(m_mutex);
245 if (m_processedContextIds.insert(contextId).second) {
246 // Extracting OUTPUT POOL ItechnologySpecificAttributes for Domain, Database and Container.
248 }
249 if (!processPoolAttributes(m_domainAttr, outputConnection, contextId).isSuccess()) {
250 ATH_MSG_DEBUG("connectOutput failed process POOL domain attributes.");
251 }
252 if (!processPoolAttributes(m_databaseAttr, outputConnection, contextId).isSuccess()) {
253 ATH_MSG_DEBUG("connectOutput failed process POOL database attributes.");
254 }
255 return(StatusCode::SUCCESS);
256}
257//______________________________________________________________________________
258StatusCode AthenaPoolCnvSvc::connectOutput(const std::string& outputConnectionSpec) {
259// This is called before DataObjects are being converted.
260 return(connectOutput(outputConnectionSpec, "UPDATE"));
261}
262
263//______________________________________________________________________________
264StatusCode AthenaPoolCnvSvc::commitOutput(const std::string& outputConnectionSpec, bool doCommit) {
265 // This is called after all DataObjects are converted.
266 std::string outputConnection = outputConnectionSpec.substr(0, outputConnectionSpec.find('['));
267 // StopWatch listens from here until the end of this current scope
268 PMonUtils::BasicStopWatch stopWatch("commitOutput", m_chronoMap);
269 std::unique_lock<std::mutex> lock(m_mutex);
270 unsigned int contextId = outputContextId(outputConnection);
271 if (!processPoolAttributes(m_domainAttr, outputConnection, contextId).isSuccess()) {
272 ATH_MSG_DEBUG("commitOutput failed process POOL domain attributes.");
273 }
274 if (!processPoolAttributes(m_databaseAttr, outputConnection, contextId).isSuccess()) {
275 ATH_MSG_DEBUG("commitOutput failed process POOL database attributes.");
276 }
277 if (!processPoolAttributes(m_containerAttr, outputConnection, contextId).isSuccess()) {
278 ATH_MSG_DEBUG("commitOutput failed process POOL container attributes.");
279 }
280
281 // lock.unlock(); //MN: first need to make commitCache slot-specific
282 try {
283 if (doCommit) {
284 if (!m_poolSvc->commit(contextId).isSuccess()) {
285 ATH_MSG_ERROR("commitOutput FAILED to commit OutputStream.");
286 return(StatusCode::FAILURE);
287 }
288 } else {
289 if (!m_poolSvc->commitAndHold(contextId).isSuccess()) {
290 ATH_MSG_ERROR("commitOutput FAILED to commitAndHold OutputStream.");
291 return(StatusCode::FAILURE);
292 }
293 }
294 } catch (std::exception& e) {
295 ATH_MSG_ERROR("commitOutput - caught exception: " << e.what());
296 return(StatusCode::FAILURE);
297 }
298 if (!this->cleanUp(outputConnection).isSuccess()) {
299 ATH_MSG_ERROR("commitOutput FAILED to cleanup converters.");
300 return(StatusCode::FAILURE);
301 }
302
303 return(StatusCode::SUCCESS);
304}
305
306//______________________________________________________________________________
307StatusCode AthenaPoolCnvSvc::disconnectOutput(const std::string& outputConnectionSpec) {
308 std::string outputConnection = outputConnectionSpec.substr(0, outputConnectionSpec.find('['));
309 unsigned int contextId = outputContextId(outputConnection);
310 StatusCode sc = m_poolSvc->disconnect(contextId);
311 return sc;
312}
313
314//______________________________________________________________________________
315unsigned int AthenaPoolCnvSvc::outputContextId(const std::string& outputConnection) {
316 return m_persSvcPerOutput?
317 m_poolSvc->getOutputContext(outputConnection) : (unsigned int)IPoolSvc::kOutputStream;
318}
319
320//______________________________________________________________________________
324//______________________________________________________________________________
325Token* AthenaPoolCnvSvc::registerForWrite(Placement* placement, const void* obj, const RootType& classDesc) {
326 // StopWatch listens from here until the end of this current scope
327 PMonUtils::BasicStopWatch stopWatch("cRepR_ALL", m_chronoMap);
328 Token* token = nullptr;
329 if (m_persSvcPerOutput) { // Use separate PersistencySvc for each output stream/file
330 char text[32];
331 const std::string contextStr = std::format("[CTXT={:08X}]", m_poolSvc->getOutputContext(placement->fileName()));
332 std::strncpy(text, contextStr.c_str(), sizeof(text) - 1);
333 text[sizeof(text) - 1] = '\0';
334 placement->setAuxString(text);
335 }
336 token = m_poolSvc->registerForWrite(placement, obj, classDesc);
337 return(token);
338}
339//______________________________________________________________________________
340void AthenaPoolCnvSvc::setObjPtr(void*& obj, const Token* token) {
341 ATH_MSG_VERBOSE("Requesting object for: " << token->toString());
342 // StopWatch listens from here until the end of this current scope
343 PMonUtils::BasicStopWatch stopWatch("cObjR_ALL", m_chronoMap);
344 if (token->dbID() != Guid::null()) {
345 ATH_MSG_VERBOSE("Requesting object for: " << token->toString());
346 m_poolSvc->setObjPtr(obj, token);
347 }
348}
349//______________________________________________________________________________
351 return(m_useDetailChronoStat.value());
352}
353//______________________________________________________________________________
354StatusCode AthenaPoolCnvSvc::createAddress(long svcType,
355 const CLID& clid,
356 const std::string* par,
357 const unsigned long* ip,
358 IOpaqueAddress*& refpAddress) {
359 if( svcType != repSvcType() ) {
360 ATH_MSG_ERROR("createAddress: svcType != POOL_StorageType " << svcType << " " << repSvcType());
361 return(StatusCode::FAILURE);
362 }
363 std::unique_ptr<Token> token;
364 if (par[0].compare(0, 3, "SHM") == 0) {
365 token = std::make_unique<Token>();
366 token->setOid(Token::OID_t(ip[0], ip[1]));
367 token->setAuxString("[PNAME=" + par[2] + "]");
368 RootType classDesc = RootType::ByNameNoQuiet(par[2]);
369 token->setClassID(pool::DbReflex::guid(classDesc));
370 } else {
371 Token *t = m_poolSvc->getToken(par[0], par[1], ip[0]);
372 if( t ) {
373 token = std::make_unique<Token>(t);
374 t->release();
375 }
376 }
377 if (token == nullptr) {
378 return(StatusCode::RECOVERABLE);
379 }
380 refpAddress = new TokenAddress(repSvcType(), clid, "", par[1], IPoolSvc::kInputStream, std::move(token));
381 return(StatusCode::SUCCESS);
382}
383//______________________________________________________________________________
384StatusCode AthenaPoolCnvSvc::createAddress(long svcType,
385 const CLID& clid,
386 const std::string& refAddress,
387 IOpaqueAddress*& refpAddress) {
388 if (svcType != repSvcType()) {
389 ATH_MSG_ERROR("createAddress: svcType != POOL_StorageType " << svcType << " " << repSvcType());
390 return(StatusCode::FAILURE);
391 }
392 refpAddress = new GenericAddress(repSvcType(), clid, refAddress);
393 return(StatusCode::SUCCESS);
394}
395//______________________________________________________________________________
396StatusCode AthenaPoolCnvSvc::convertAddress(const IOpaqueAddress* pAddress,
397 std::string& refAddress) {
398 assert(pAddress);
399 const TokenAddress* tokAddr = dynamic_cast<const TokenAddress*>(pAddress);
400 if (tokAddr != nullptr && tokAddr->getToken() != nullptr) {
401 refAddress = tokAddr->getToken()->toString();
402 } else {
403 refAddress = *pAddress->par();
404 }
405 return(StatusCode::SUCCESS);
406}
407//______________________________________________________________________________
409 m_cnvs.push_back(cnv);
410 return(StatusCode::SUCCESS);
411}
412//______________________________________________________________________________
413StatusCode AthenaPoolCnvSvc::cleanUp(const std::string& connection) {
414 bool retError = false;
415 std::size_t cpos = connection.find(':');
416 std::size_t bpos = connection.find('[');
417 if (cpos == std::string::npos) {
418 cpos = 0;
419 } else {
420 cpos++;
421 }
422 if (bpos != std::string::npos) bpos = bpos - cpos;
423 const std::string conn = connection.substr(cpos, bpos);
424 ATH_MSG_VERBOSE("Cleanup for Connection='"<< conn <<"'");
425 for (auto converter : m_cnvs) {
426 if (!converter->cleanUp(conn).isSuccess()) {
427 ATH_MSG_WARNING("AthenaPoolConverter cleanUp failed.");
428 retError = true;
429 }
430 }
431 return(retError ? StatusCode::FAILURE : StatusCode::SUCCESS);
432}
433//______________________________________________________________________________
434StatusCode AthenaPoolCnvSvc::setInputAttributes(const std::string& fileName) {
435 // Set attributes for input file
436 m_lastInputFileName = fileName; // Save file name for printing attributes per event
437 if (!m_persSvcPerInputType.empty()) {
438// Loop over all extra event input contexts
439 const auto& extraInputContextMap = m_poolSvc->getInputContextMap();
440 for (const auto& [label, id]: extraInputContextMap) {
441 if (!processPoolAttributes(m_inputAttr, m_lastInputFileName, id, false, true, false).isSuccess()) {
442 ATH_MSG_DEBUG("setInputAttribute failed setting POOL database/container attributes.");
443 }
444 }
445 }
446 if (!processPoolAttributes(m_inputAttr, m_lastInputFileName, IPoolSvc::kInputStream, false, true, false).isSuccess()) {
447 ATH_MSG_DEBUG("setInputAttribute failed setting POOL database/container attributes.");
448 }
450 ATH_MSG_DEBUG("setInputAttribute failed getting POOL database/container attributes.");
451 }
452 return(StatusCode::SUCCESS);
453}
454
455//______________________________________________________________________________
456void AthenaPoolCnvSvc::handle(const Incident& incident) {
457 if (incident.type() == "EndEvent") {
459 ATH_MSG_DEBUG("handle EndEvent failed process POOL database attributes.");
460 }
461 }
462}
463//______________________________________________________________________________
464AthenaPoolCnvSvc::AthenaPoolCnvSvc(const std::string& name, ISvcLocator* pSvcLocator) :
465 base_class(name, pSvcLocator, pool::POOL_StorageType.type()) {
466}
467//__________________________________________________________________________
468void AthenaPoolCnvSvc::extractPoolAttributes(const StringArrayProperty& property,
469 std::vector<std::vector<std::string> >* contAttr,
470 std::vector<std::vector<std::string> >* dbAttr,
471 std::vector<std::vector<std::string> >* domAttr) const {
472 std::vector<std::string> opt;
473 std::string attributeName, containerName, databaseName, valueString;
474 for (const auto& propertyValue : property.value()) {
475 opt.clear();
476 attributeName.clear();
477 containerName.clear();
478 databaseName.clear();
479 valueString.clear();
480 using Gaudi::Utils::AttribStringParser;
481 for (const AttribStringParser::Attrib& attrib : AttribStringParser (propertyValue)) {
482 if (attrib.tag == "DatabaseName") {
483 databaseName = attrib.value;
484 } else if (attrib.tag == "ContainerName") {
485 if (databaseName.empty()) {
486 databaseName = "*";
487 }
488 containerName = attrib.value;
489 } else {
490 attributeName = attrib.tag;
491 valueString = attrib.value;
492 }
493 }
494 if (!attributeName.empty() && !valueString.empty()) {
495 opt.push_back(attributeName);
496 opt.push_back(valueString);
497 if (!databaseName.empty()) {
498 opt.push_back(databaseName);
499 if (!containerName.empty()) {
500 opt.push_back(containerName);
501 if (containerName.compare(0, 6, "TTree=") == 0) {
502 dbAttr->push_back(opt);
503 } else {
504 contAttr->push_back(opt);
505 }
506 } else {
507 opt.push_back("");
508 dbAttr->push_back(opt);
509 }
510 } else if (domAttr != 0) {
511 domAttr->push_back(opt);
512 } else {
513 opt.push_back("*");
514 opt.push_back("");
515 dbAttr->push_back(opt);
516 }
517 }
518 }
519}
520//__________________________________________________________________________
521StatusCode AthenaPoolCnvSvc::processPoolAttributes(std::vector<std::vector<std::string> >& attr,
522 const std::string& fileName,
523 unsigned long contextId,
524 bool doGet,
525 bool doSet,
526 bool doClear) const {
527 bool retError = false;
528 for (auto& attrEntry : attr) {
529 if (attrEntry.size() == 2) {
530 const std::string& opt = attrEntry[0];
531 std::string data = attrEntry[1];
532 if (data == "int" || data == "DbLonglong" || data == "double" || data == "string") {
533 if (doGet) {
534 if (!m_poolSvc->getAttribute(opt, data, pool::DbType(pool::ROOTTREE_StorageType).type(), contextId).isSuccess()) {
535 ATH_MSG_DEBUG("getAttribute failed for domain attr " << opt);
536 retError = true;
537 }
538 }
539 } else if (doSet) {
540 if (m_poolSvc->setAttribute(opt, data, pool::DbType(pool::ROOTTREE_StorageType).type(), contextId).isSuccess()) {
541 ATH_MSG_DEBUG("setAttribute " << opt << " to " << data);
542 if (doClear) {
543 attrEntry.clear();
544 }
545 } else {
546 ATH_MSG_DEBUG("setAttribute failed for domain attr " << opt << " to " << data);
547 retError = true;
548 }
549 }
550 }
551 if (attrEntry.size() == 4) {
552 const std::string& opt = attrEntry[0];
553 std::string data = attrEntry[1];
554 const std::string& file = attrEntry[2];
555 const std::string& cont = attrEntry[3];
556 if (!fileName.empty() && (0 == fileName.compare(0, fileName.find('?'), file)
557 || (file[0] == '*' && file.find("," + fileName + ",") == std::string::npos))) {
558 if (data == "int" || data == "DbLonglong" || data == "double" || data == "string") {
559 if (doGet) {
560 if (!m_poolSvc->getAttribute(opt, data, pool::DbType(pool::ROOTTREE_StorageType).type(), fileName, cont, contextId).isSuccess()) {
561 ATH_MSG_DEBUG("getAttribute failed for database/container attr " << opt);
562 retError = true;
563 }
564 }
565 } else if (doSet) {
566 if (m_poolSvc->setAttribute(opt, data, pool::DbType(pool::ROOTTREE_StorageType).type(), fileName, cont, contextId).isSuccess()) {
567 ATH_MSG_DEBUG("setAttribute " << opt << " to " << data << " for db: " << fileName << " and cont: " << cont);
568 if (doClear) {
569 if (file[0] == '*' && !m_persSvcPerOutput) {
570 attrEntry[2] += "," + fileName + ",";
571 } else {
572 attrEntry.clear();
573 }
574 }
575 } else {
576 ATH_MSG_DEBUG("setAttribute failed for " << opt << " to " << data << " for db: " << fileName << " and cont: " << cont);
577 retError = true;
578 }
579 }
580 }
581 }
582 }
583 std::erase_if(attr, [](const auto& entry) { return entry.empty(); });
584 return(retError ? StatusCode::FAILURE : StatusCode::SUCCESS);
585}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This file contains the class definition for the AthenaPoolCnvSvc class.
This file contains the class definition for the DataHeader and DataHeaderElement classes.
uint32_t CLID
The Class ID type.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
static Double_t sc
This file contains the class definition for the Placement class (migrated from POOL).
TTypeAdapter RootType
Definition RootType.h:211
This file contains the class definition for the TokenAddress class.
This file contains the class definition for the Token class (migrated from POOL).
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Implementation of IConverter: Convert the transient object to the requested representation.
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Implementation of IConverter: Create the transient representation of an object.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Resolve the references of the converted object.
ServiceHandle< IClassIDSvc > m_clidSvc
virtual IPoolSvc * getPoolSvc() override
StatusCode createAddress(long svcType, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress) override
Create a Generic address using explicit arguments to identify a single object.
virtual void handle(const Incident &incident) override
Implementation of IIncidentListener: Handle for EndEvent incidence.
Gaudi::Property< bool > m_useDetailChronoStat
UseDetailChronoStat, enable detailed output for time and size statistics for AthenaPOOL: default = fa...
StatusCode processPoolAttributes(std::vector< std::vector< std::string > > &attr, const std::string &fileName, unsigned long contextId, bool doGet=true, bool doSet=true, bool doClear=true) const
Set/get technology dependent POOL attributes.
std::vector< std::vector< std::string > > m_inputAttrPerEvent
virtual StatusCode io_finalize() override
virtual StatusCode initialize() override
Required of all Gaudi Services.
virtual StatusCode stop() override
virtual StatusCode io_reinit() override
virtual StatusCode registerCleanUp(IAthenaPoolCleanUp *cnv) override
Implement registerCleanUp to register a IAthenaPoolCleanUp to be called during cleanUp.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConversionSvc: Resolve the references of the converted object.
std::vector< std::vector< std::string > > m_databaseAttr
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Implementation of IConversionSvc: Create the transient representation of an object from persistent st...
void extractPoolAttributes(const Gaudi::Property< std::vector< std::string > > &property, std::vector< std::vector< std::string > > *contAttr, std::vector< std::vector< std::string > > *dbAttr, std::vector< std::vector< std::string > > *domAttr=0) const
Extract POOL ItechnologySpecificAttributes for Domain, Database and Container from property.
virtual bool useDetailChronoStat() const override
std::vector< std::vector< std::string > > m_containerAttr
virtual Token * registerForWrite(Placement *placement, const void *obj, const RootType &classDesc) override
virtual StatusCode disconnectOutput(const std::string &outputConnectionSpec) override
Disconnect to the output connection.
Gaudi::Property< std::string > m_persSvcPerInputType
PersSvcPerInputType, string property, tree name to use multiple persistency services,...
Gaudi::Property< std::vector< std::string > > m_inputPoolAttr
Input PoolAttributes, vector with names and values of technology specific attributes for POOL.
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Implementation of IConversionSvc: Convert the transient object to the requested representation.
PMonUtils::BasicStopWatchResultMap_t m_chronoMap
Map that holds chrono information.
virtual StatusCode connectOutput(const std::string &outputConnectionSpec, const std::string &openMode) override
Implementation of IConversionSvc: Connect to the output connection specification with open mode.
AthenaPoolCnvSvc(const std::string &name, ISvcLocator *pSvcLocator)
Standard Service Constructor.
Gaudi::Property< bool > m_persSvcPerOutput
PersSvcPerOutput, boolean property to use multiple persistency services, one per output stream.
std::string m_lastInputFileName
decoded storage tech requested in "StorageTechnology" property
Gaudi::Property< std::string > m_containerNamingSchemeProp
POOL container naming scheme selection.
virtual StatusCode finalize() override
Required of all Gaudi Services.
virtual StatusCode commitOutput(const std::string &outputConnectionSpec, bool doCommit) override
Implementation of IConversionSvc: Commit pending output.
void flushDataHeaderForms(const std::string &streamName="*")
Tell DataHeaderCnv to write out all DataHeaderForms for a given streamName (default is all).
unsigned outputContextId(const std::string &outputConnection)
ServiceHandle< IPoolSvc > m_poolSvc
std::set< unsigned int > m_processedContextIds
Track context IDs for which extractPoolAttributes has been called.
virtual StatusCode cleanUp(const std::string &connection) override
Implement cleanUp to call all registered IAthenaPoolCleanUp cleanUp() function.
std::vector< std::vector< std::string > > m_inputAttr
virtual StatusCode convertAddress(const IOpaqueAddress *pAddress, std::string &refAddress) override
Convert address to string form.
virtual void setObjPtr(void *&obj, const Token *token) override
std::vector< std::vector< std::string > > m_domainAttr
Gaudi::Property< std::vector< std::string > > m_poolAttr
Output PoolAttributes, vector with names and values of technology specific attributes for POOL.
virtual StatusCode setInputAttributes(const std::string &fileName) override
Set the input file attributes, if any are requested from jobOpts.
Gaudi::Property< std::vector< std::string > > m_inputPoolAttrPerEvent
Print input PoolAttributes per event, vector with names of technology specific attributes for POOL to...
static const Guid & null() noexcept
NULL-Guid: static class method.
Definition Guid.cxx:14
constexpr void toString(std::span< char, StrLen > buf, bool uppercase=true) const noexcept
Automatic conversion to string representation.
This class provides the interface for the AthenaPoolCleanUp which is used to clean up AthenaPoolConve...
This class provides the interface to the APR persistency software.
Definition IPoolSvc.h:37
@ kOutputStream
Definition IPoolSvc.h:41
@ kInputStream
Definition IPoolSvc.h:41
This class holds all the necessary information to guide the writing of an object in a physical place.
Definition Placement.h:19
Placement & setAuxString(const std::string &auxString)
Set auxiliary string.
Definition Placement.h:42
const std::string & fileName() const
Access file name.
Definition Placement.h:28
static TScopeAdapter ByNameNoQuiet(const std::string &name, Bool_t load=kTRUE)
Definition RootType.cxx:586
This class provides a Generic Transient Address for POOL tokens.
Token * getToken()
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition Token.h:21
Token & setAuxString(const std::string &auxString)
Set auxiliary string.
Definition Token.h:93
const std::string & contID() const
Access container identifier.
Definition Token.h:69
const Guid & classID() const
Access database identifier.
Definition Token.h:73
virtual const std::string toString() const
Retrieve the string representation of the token.
Definition Token.cxx:134
const Guid & dbID() const
Access database identifier.
Definition Token.h:64
static Guid guid(const TypeH &id)
Determine Guid (normalized string form) from reflection type.
int type() const
Access to full type.
Definition DbType.h:65
std::string label(const std::string &format, int i)
Definition label.h:19
std::optional< NamingScheme > parseNamingScheme(std::string_view name)
Definition APRDefaults.h:89
void setNamingScheme(NamingScheme scheme)
Definition APRDefaults.h:79
Framework include files.
Definition libname.h:15
static const DbType ROOTTREE_StorageType
Definition DbType.h:87
std::size_t erase_if(T_container &container, T_Func pred)
TFile * file