diff --git a/Database/APR/RootStorageSvc/src/RootTreeIndexContainer.cpp b/Database/APR/RootStorageSvc/src/RootTreeIndexContainer.cpp index e8ddfc328571736faf26dbbc0aaeb92874877ff8..735dc7c4e3c63f1aa44b4bc7147283ade57fdf53 100644 --- a/Database/APR/RootStorageSvc/src/RootTreeIndexContainer.cpp +++ b/Database/APR/RootStorageSvc/src/RootTreeIndexContainer.cpp @@ -47,12 +47,19 @@ long long int RootTreeIndexContainer::nextRecordId() { DbStatus RootTreeIndexContainer::writeObject(TransactionStack::value_type& ent) { long long int s = 0; - if( m_tree != nullptr && isBranchContainer() ) { + if( isBranchContainer() ) { TBranch * pBranch = m_tree->GetBranch(m_branchName.c_str()); if (pBranch != nullptr) s = pBranch->GetEntries(); } else { s = m_tree->GetEntries(); } + if (m_index_ref == nullptr && m_index_foreign == nullptr) { + if (m_tree->GetBranch("index_ref") == nullptr) { + m_index_ref = (TBranch*)m_tree->Branch("index_ref", m_index); + } else { + m_index_foreign = (TBranch*)m_tree->GetBranch("index_ref"); + } + } if (m_index_ref != nullptr && s >= m_index_ref->GetEntries()) { *m_index = this->nextRecordId(); m_index_ref->SetAddress(m_index); @@ -65,27 +72,11 @@ DbStatus RootTreeIndexContainer::writeObject(TransactionStack::value_type& ent) } DbStatus RootTreeIndexContainer::transAct(Transaction::Action action) { - if (action == Transaction::TRANSACT_COMMIT) { - if (m_tree == nullptr) return Error; - if (m_tree->GetName()[0] != '#') { - if (m_index_foreign == nullptr && m_tree->GetBranch("index_ref") == nullptr) { - m_index_ref = (TBranch*)m_tree->Branch("index_ref", m_index); - } -/* - if (m_index_ref != nullptr && RootTreeContainer::size() > m_index_ref->GetEntries()) { - *m_index = this->nextRecordId(); - m_index_ref->SetAddress(m_index); - if (!m_treeFillMode) m_index_ref->Fill(); - } -*/ - } - } DbStatus status = RootTreeContainer::transAct(action); if (action == Transaction::TRANSACT_FLUSH) { - if (m_tree->GetName()[0] != '#') { - if (m_index_ref != nullptr && m_tree->GetEntryNumberWithIndex(nextRecordId()) == -1) { - m_tree->BuildIndex("index_ref"); - } + if (m_tree == nullptr) return Error; + if (m_index_ref != nullptr && m_tree->GetEntryNumberWithIndex(nextRecordId()) == -1) { + m_tree->BuildIndex("index_ref"); } } return status; diff --git a/Database/APR/StorageSvc/StorageSvc/IDbContainer.h b/Database/APR/StorageSvc/StorageSvc/IDbContainer.h index d8b3d7fd409df82b047fc7dca17ac3ce9a3dc593..216ee29776c3df1437de1c426ed317fc9f01211a 100644 --- a/Database/APR/StorageSvc/StorageSvc/IDbContainer.h +++ b/Database/APR/StorageSvc/StorageSvc/IDbContainer.h @@ -76,6 +76,10 @@ namespace pool { /// In place deletion of raw memory virtual DbStatus free( void* ptr, DbContainer& cntH) = 0; + + /// Number of next record in the container (=size if no delete is allowed) + virtual long long int nextRecordId() = 0; + /// Close the container virtual DbStatus close() = 0; /// Open the container diff --git a/Database/APR/StorageSvc/src/DbDatabaseObj.cpp b/Database/APR/StorageSvc/src/DbDatabaseObj.cpp index 4e61518d7a49aaa03f2348475a3afec5dc1ceec7..b5b63d1f9012ed7727f0aed0a805a04532745976 100644 --- a/Database/APR/StorageSvc/src/DbDatabaseObj.cpp +++ b/Database/APR/StorageSvc/src/DbDatabaseObj.cpp @@ -27,6 +27,7 @@ #include "StorageSvc/DbInstanceCount.h" #include "StorageSvc/IOODatabase.h" #include "StorageSvc/IDbDatabase.h" +#include "StorageSvc/IDbContainer.h" #include <memory> #include <cstdio> @@ -191,6 +192,8 @@ DbStatus DbDatabaseObj::makeLink(const Token* pTok, Token::OID_t& refLnk) { link->setDb(s_localDb); link->setLocal(true); } + // Update link to use persistent oid + link->oid().first = m_links->info()->nextRecordId() + 2; // Taking into account unsaved ##Container links DbHandle<DbString> persH = new(m_links, m_string_t) DbString(link->toString()); if ( !m_links.save(persH, m_string_t).isSuccess() ) { return Error; @@ -704,7 +707,7 @@ DbStatus DbDatabaseObj::getLink(const Token::OID_t& lnkH, Token* pTok, const DbS std::string DbDatabaseObj::cntName(const Token& token) { if ( 0 == m_info ) open(); if ( 0 != m_info ) { - int lnk = token.oid().first; + int lnk = token.oid().first; // Remove leading 32 bit, switch to index later if ( lnk >= 0 ) { Redirections::iterator i=m_redirects.find(token.dbID().toString()); Sections::const_iterator j=m_sections.find("##Links"); diff --git a/Database/APR/StorageSvc/src/DbType.cpp b/Database/APR/StorageSvc/src/DbType.cpp index 487106b615bd9adb1209ca6da3f649e3678f4699..65dc520770c9e498c8f8a1c163ec9cc035628daf 100644 --- a/Database/APR/StorageSvc/src/DbType.cpp +++ b/Database/APR/StorageSvc/src/DbType.cpp @@ -64,7 +64,7 @@ const std::string DbType::storageName() const { else if ( match(ROOTTREE_StorageType) ) return "ROOT_Tree"; else if ( match(ROOTTREEINDEX_StorageType) ) - return "ROOT_Tree"; + return "ROOT_TreeIndex"; else if ( *this == ROOT_StorageType ) return "ROOT_All"; else if ( match( POOL_RDBMS_HOMOGENEOUS_StorageType ) ) diff --git a/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/test/athenarun_test.sh.in b/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/test/athenarun_test.sh.in index 0af0b836838dce693371a199d62dbc8f28d305c7..277b7a8551cf2a4db67bbec240b930a06a34fe73 100755 --- a/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/test/athenarun_test.sh.in +++ b/Database/AthenaPOOL/AthenaPoolExample/AthenaPoolExampleAlgorithms/test/athenarun_test.sh.in @@ -14,12 +14,17 @@ s/0\\\\{8\\\\}-0\\\\{4\\\\}-0\\\\{4\\\\}-0\\\\{4\\\\}-0\\\\{12\\\\}/!!!!/g s/[0-9A-F]\\\\{8\\\\}-[0-9A-F]\\\\{4\\\\}-[0-9A-F]\\\\{4\\\\}-[0-9A-F]\\\\{4\\\\}-[0-9A-F]\\\\{12\\\\}/????/g s/TTree [0-9]\\\\{3\\\\}[0-9]*/TTree ????/g s/^.*Py:Athena /Athena /g -s/fffffffff/f/g -s/000000000/0/g s/-[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]0/-0/g +s/=[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]0/=0/g +s/[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]00*//g +s/\\\\[00000000/[/g +s/-000000000/-0/g +s/=00000000/=/g +s/ ffffffff/ /g s/20[23]/20?/g s/INFO CLID = 222376821, key = Stream[12]/INFO CLID = 222376821, key = StreamX/g s/0x[0-9a-f]\\\\{7,12\\\\}/0x????/g +s/ROOT_TreeIndex/ROOT_Tree/g EOF # Ordering sensitivities