ATLAS Offline Software
Loading...
Searching...
No Matches
pool::RootDatabase Class Reference

Description: ROOT specific implementation of Database file. More...

#include <src/RootDatabase.h>

Inheritance diagram for pool::RootDatabase:

Public Types

enum  { READ_COUNTER = 0 , WRITE_COUNTER = 1 , OTHER_COUNTER = 2 }

Public Member Functions

 RootDatabase ()
 Standard Constructor.
virtual ~RootDatabase ()
 Standard destructor.
TFile * file ()
 Access to the actual implemented file.
std::string name () const
 Get the DB name (here it is the TFile name)
TTree * getTree (const std::string &name)
 Get TTree by name from the TFile.
const std::string & fmtVersion () const
 Access to the version string.
virtual long long int size () const
 Access the size of the database: May be undefined for some technologies.
void addByteCount (int which, long long int num_bytes)
 Do some statistics: add number of bytes read/written/other.
long long int byteCount (int which) const
 Do some statistics: retrieve number of bytes read/written/other.
DbStatus markBranchContainerForFill (RootTreeContainer *)
void registerBranchContainer (RootTreeContainer *)
uint64_t currentIndexMasterID () const
uint64_t indexSize (TBranch *branch)
 get index size for indexed containers
uint64_t indexSizeInc (TBranch *branch)
 increase index size counter for indexed containers (by 1)
bool wasIndexRebuilt (const std::string &treeName)
 Check if a given TTree had its index rebuilt.
void markIndexRebuilt (const std::string &treeName)
 Mark that a given TTree had its index rebuilt.
std::recursive_mutex & ioMutex ()
 provide access to the I/O mutex for AuxDynReader and Containers
virtual DbStatus getOption (DbOption &opt)
 Access options.
virtual DbStatus setOption (const DbOption &opt)
 Set options.
virtual DbStatus setAutoFlush (const DbOption &opt)
 implementation of TREE_AUTO_FLUSH option - called from setOption()
virtual DbStatus open (const DbDomain &domH, const std::string &nam, DbAccessMode mode)
 Open Database object.
virtual DbStatus reopen (DbAccessMode mode)
 Re-open database with changing access permissions.
virtual DbStatus onOpen (DbDatabase &dbH, DbAccessMode mode)
 Callback after successful open of a database object.
virtual DbStatus close (DbAccessMode mode)
 Close database access.
virtual DbStatus transAct (Transaction::Action action)
 Execute Database Transaction action.
ROOT::RNTupleReader * getNTupleReader (const std::string &ntuple_name)
 return RNTupleReader for a given ntuple_name
uint64_t indexLookup (ROOT::RNTupleReader *ps, uint64_t idx_val)
RootStorageSvc::RNTupleWriterHelpergetNTupleWriter (const std::string &ntuple_name, bool create=false)
 Return RNTupleWriterHelper for a given ntuple_name create a new one if needed when create==true.
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Static Public Member Functions

static bool exists (const std::string &nam)
 Check for file-existence.

Protected Member Functions

DbStatus fillBranchContainerTrees ()
void reduceBasketsSize (TTree *tree)
void increaseBasketsSize (TTree *tree)
DbStatus close ()
void printErrno (const char *nam, int err)

Private Types

typedef std::set< RootTreeContainer * > ContainerSet_t
using indexLookup_t = std::unordered_map<uint64_t, uint64_t>

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

DbDatabase m_dbH
 Parent Database handle.
TFile * m_file
 Reference to the actual implemented file.
std::string m_version
 Persistency format version.
long long int m_counters [3]
 Counter statistics.
int m_defCompression
 Default compression level.
int m_defCompressionAlg
 Default compression algorithm.
int m_defSplitLevel
 Default split level.
int m_defAutoSave
 Default Autosave parameter for trees.
int m_defBufferSize
 Default buffer size parameter for Branches.
int m_maxBufferSize
 Maximum buffer size parameter for Branches.
int m_minBufferEntries
 Minimum buffer entries parameter for Branches.
int m_defWritePolicy
 Default policy mode for keyed objects.
int m_branchOffsetTabLen
 Offset table length for branches.
std::string m_treeNameWithCache
 Name of tree with cache.
int m_defTreeCacheLearnEvents
 Default tree cache learn events.
int m_rntBufferedWriteEnabled
 Flag to enable/disable buffered RNTuple writing.
int m_rntReaderMetricsEnabled
 Flag to enable/disable RNTupleReader metrics.
int m_rntWriterMetricsEnabled
 Flag to enable/disable RNTupleWriter metrics.
std::string m_indexMaster
 name of the container with master index ('*' means use the biggest)
uint64_t m_indexMasterID
 nextID of the master index
std::map< TBranch *, uint64_t > m_indexSizeMap
 Keep index sizes here, because Branches are emptied when fast merged by SharedWriter.
std::set< std::string > m_indexRebuilt
 marks if the index (for index Containers) was rebuilt for given TTree
std::map< std::string, int > m_autoFlushTrees
std::map< TTree *, ContainerSet_tm_containersInTree
std::map< std::string, int > m_customSplitLevel
SmartIF< IFileMgr > m_fileMgr
std::recursive_mutex m_iomutex
std::map< std::string, std::unique_ptr< RootStorageSvc::RNTupleWriterHelper > > m_ntupleWriterMap
std::map< std::string, std::unique_ptr< ROOT::RNTupleReader > > m_ntupleReaderMap
std::map< void *, indexLookup_tm_ntupleIndexMap
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

Description: ROOT specific implementation of Database file.

Author
M.Frank
Date
1/8/2002
Version
1.0

Definition at line 54 of file RootDatabase.h.

Member Typedef Documentation

◆ ContainerSet_t

Definition at line 115 of file RootDatabase.h.

◆ indexLookup_t

using pool::RootDatabase::indexLookup_t = std::unordered_map<uint64_t, uint64_t>
private

Definition at line 128 of file RootDatabase.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
READ_COUNTER 
WRITE_COUNTER 
OTHER_COUNTER 

Definition at line 57 of file RootDatabase.h.

Constructor & Destructor Documentation

◆ RootDatabase()

pool::RootDatabase::RootDatabase ( )

Standard Constructor.

◆ ~RootDatabase()

virtual pool::RootDatabase::~RootDatabase ( )
virtual

Standard destructor.

Member Function Documentation

◆ addByteCount()

void pool::RootDatabase::addByteCount ( int which,
long long int num_bytes )

Do some statistics: add number of bytes read/written/other.

◆ byteCount()

long long int pool::RootDatabase::byteCount ( int which) const

Do some statistics: retrieve number of bytes read/written/other.

◆ close() [1/2]

DbStatus pool::RootDatabase::close ( )
protected

◆ close() [2/2]

virtual DbStatus pool::RootDatabase::close ( DbAccessMode mode)
virtual

Close database access.

Parameters
mode[IN] Desired session access mode.
Returns
DbStatus code indicating success or failure.

Implements pool::IDbDatabase.

◆ currentIndexMasterID()

uint64_t pool::RootDatabase::currentIndexMasterID ( ) const
inline

Definition at line 170 of file RootDatabase.h.

170{ return m_indexMasterID; }
uint64_t m_indexMasterID
nextID of the master index

◆ exists()

bool pool::RootDatabase::exists ( const std::string & nam)
static

Check for file-existence.

Parameters
nam[IN] Name of the database to be checked.
Returns
Boolean value indicating the database existence.

◆ file()

TFile * pool::RootDatabase::file ( )
inline

Access to the actual implemented file.

Definition at line 139 of file RootDatabase.h.

139{ return m_file; }
TFile * m_file
Reference to the actual implemented file.

◆ fillBranchContainerTrees()

DbStatus pool::RootDatabase::fillBranchContainerTrees ( )
protected

◆ fmtVersion()

const std::string & pool::RootDatabase::fmtVersion ( ) const
inline

Access to the version string.

Definition at line 147 of file RootDatabase.h.

147{ return m_version; }
std::string m_version
Persistency format version.

◆ getNTupleReader()

ROOT::RNTupleReader * pool::RootDatabase::getNTupleReader ( const std::string & ntuple_name)

return RNTupleReader for a given ntuple_name

◆ getNTupleWriter()

RootStorageSvc::RNTupleWriterHelper * pool::RootDatabase::getNTupleWriter ( const std::string & ntuple_name,
bool create = false )

Return RNTupleWriterHelper for a given ntuple_name create a new one if needed when create==true.

◆ getOption()

virtual DbStatus pool::RootDatabase::getOption ( DbOption & opt)
virtual

Access options.

Parameters
opt[IN] Reference to option object.
Returns
DbStatus code indicating success or failure.

Implements pool::IDbDatabase.

◆ getTree()

TTree * pool::RootDatabase::getTree ( const std::string & name)

Get TTree by name from the TFile.

◆ increaseBasketsSize()

void pool::RootDatabase::increaseBasketsSize ( TTree * tree)
protected

◆ indexLookup()

uint64_t pool::RootDatabase::indexLookup ( ROOT::RNTupleReader * ps,
uint64_t idx_val )

◆ indexSize()

uint64_t pool::RootDatabase::indexSize ( TBranch * branch)
inline

get index size for indexed containers

Definition at line 173 of file RootDatabase.h.

173{ return m_indexSizeMap[branch]; }
std::map< TBranch *, uint64_t > m_indexSizeMap
Keep index sizes here, because Branches are emptied when fast merged by SharedWriter.

◆ indexSizeInc()

uint64_t pool::RootDatabase::indexSizeInc ( TBranch * branch)
inline

increase index size counter for indexed containers (by 1)

Definition at line 176 of file RootDatabase.h.

176{ return ++m_indexSizeMap[branch]; }

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ ioMutex()

std::recursive_mutex & pool::RootDatabase::ioMutex ( )
inline

provide access to the I/O mutex for AuxDynReader and Containers

Definition at line 185 of file RootDatabase.h.

185{ return m_iomutex; }
std::recursive_mutex m_iomutex

◆ markBranchContainerForFill()

DbStatus pool::RootDatabase::markBranchContainerForFill ( RootTreeContainer * )

◆ markIndexRebuilt()

void pool::RootDatabase::markIndexRebuilt ( const std::string & treeName)
inline

Mark that a given TTree had its index rebuilt.

Definition at line 182 of file RootDatabase.h.

182{ m_indexRebuilt.insert(treeName); };
std::set< std::string > m_indexRebuilt
marks if the index (for index Containers) was rebuilt for given TTree

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 if (m_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ name()

std::string pool::RootDatabase::name ( ) const

Get the DB name (here it is the TFile name)

◆ onOpen()

virtual DbStatus pool::RootDatabase::onOpen ( DbDatabase & dbH,
DbAccessMode mode )
virtual

Callback after successful open of a database object.

Parameters
dbH[IN] Handle to valid database object
mode[IN] Desired session access mode.
Returns
DbStatus code indicating success or failure.

Implements pool::IDbDatabase.

◆ open()

virtual DbStatus pool::RootDatabase::open ( const DbDomain & domH,
const std::string & nam,
DbAccessMode mode )
virtual

Open Database object.

Parameters
domH[IN] Handle to valid domain object (validity ensured by upper levels).
nam[IN] Name of the database to be opened.
mode[IN] Desired session access mode.
Returns
DbStatus code indicating success or failure.

Implements pool::IDbDatabase.

◆ printErrno()

void pool::RootDatabase::printErrno ( const char * nam,
int err )
protected

◆ reduceBasketsSize()

void pool::RootDatabase::reduceBasketsSize ( TTree * tree)
protected

◆ registerBranchContainer()

void pool::RootDatabase::registerBranchContainer ( RootTreeContainer * )

◆ reopen()

virtual DbStatus pool::RootDatabase::reopen ( DbAccessMode mode)
virtual

Re-open database with changing access permissions.

Parameters
mode[IN] Desired session access mode.
Returns
DbStatus code indicating success or failure.

Implements pool::IDbDatabase.

◆ setAutoFlush()

virtual DbStatus pool::RootDatabase::setAutoFlush ( const DbOption & opt)
virtual

implementation of TREE_AUTO_FLUSH option - called from setOption()

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ setOption()

virtual DbStatus pool::RootDatabase::setOption ( const DbOption & opt)
virtual

Set options.

Parameters
opt[IN] Reference to option object.
Returns
DbStatus code indicating success or failure.

Implements pool::IDbDatabase.

◆ size()

virtual long long int pool::RootDatabase::size ( ) const
virtual

Access the size of the database: May be undefined for some technologies.

Implements pool::IDbDatabase.

◆ transAct()

virtual DbStatus pool::RootDatabase::transAct ( Transaction::Action action)
virtual

Execute Database Transaction action.

Implements pool::IDbDatabase.

◆ wasIndexRebuilt()

bool pool::RootDatabase::wasIndexRebuilt ( const std::string & treeName)
inline

Check if a given TTree had its index rebuilt.

Definition at line 180 of file RootDatabase.h.

180{ return m_indexRebuilt.count(treeName)!=0; }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_autoFlushTrees

std::map< std::string, int > pool::RootDatabase::m_autoFlushTrees
private

Definition at line 112 of file RootDatabase.h.

◆ m_branchOffsetTabLen

int pool::RootDatabase::m_branchOffsetTabLen
private

Offset table length for branches.

Definition at line 85 of file RootDatabase.h.

◆ m_containersInTree

std::map< TTree*, ContainerSet_t > pool::RootDatabase::m_containersInTree
private

Definition at line 116 of file RootDatabase.h.

◆ m_counters

long long int pool::RootDatabase::m_counters[3]
private

Counter statistics.

Definition at line 67 of file RootDatabase.h.

◆ m_customSplitLevel

std::map< std::string, int > pool::RootDatabase::m_customSplitLevel
private

Definition at line 118 of file RootDatabase.h.

◆ m_dbH

DbDatabase pool::RootDatabase::m_dbH
private

Parent Database handle.

Definition at line 61 of file RootDatabase.h.

◆ m_defAutoSave

int pool::RootDatabase::m_defAutoSave
private

Default Autosave parameter for trees.

Definition at line 75 of file RootDatabase.h.

◆ m_defBufferSize

int pool::RootDatabase::m_defBufferSize
private

Default buffer size parameter for Branches.

Definition at line 77 of file RootDatabase.h.

◆ m_defCompression

int pool::RootDatabase::m_defCompression
private

Default compression level.

Definition at line 69 of file RootDatabase.h.

◆ m_defCompressionAlg

int pool::RootDatabase::m_defCompressionAlg
private

Default compression algorithm.

Definition at line 71 of file RootDatabase.h.

◆ m_defSplitLevel

int pool::RootDatabase::m_defSplitLevel
private

Default split level.

Definition at line 73 of file RootDatabase.h.

◆ m_defTreeCacheLearnEvents

int pool::RootDatabase::m_defTreeCacheLearnEvents
private

Default tree cache learn events.

Definition at line 89 of file RootDatabase.h.

◆ m_defWritePolicy

int pool::RootDatabase::m_defWritePolicy
private

Default policy mode for keyed objects.

Definition at line 83 of file RootDatabase.h.

◆ m_file

TFile* pool::RootDatabase::m_file
private

Reference to the actual implemented file.

Definition at line 63 of file RootDatabase.h.

◆ m_fileMgr

SmartIF<IFileMgr> pool::RootDatabase::m_fileMgr
private

Definition at line 120 of file RootDatabase.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_indexMaster

std::string pool::RootDatabase::m_indexMaster
private

name of the container with master index ('*' means use the biggest)

Definition at line 98 of file RootDatabase.h.

◆ m_indexMasterID

uint64_t pool::RootDatabase::m_indexMasterID
private

nextID of the master index

Definition at line 100 of file RootDatabase.h.

◆ m_indexRebuilt

std::set< std::string > pool::RootDatabase::m_indexRebuilt
private

marks if the index (for index Containers) was rebuilt for given TTree

Definition at line 106 of file RootDatabase.h.

◆ m_indexSizeMap

std::map<TBranch*, uint64_t> pool::RootDatabase::m_indexSizeMap
private

Keep index sizes here, because Branches are emptied when fast merged by SharedWriter.

Definition at line 103 of file RootDatabase.h.

◆ m_iomutex

std::recursive_mutex pool::RootDatabase::m_iomutex
private

Definition at line 123 of file RootDatabase.h.

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_maxBufferSize

int pool::RootDatabase::m_maxBufferSize
private

Maximum buffer size parameter for Branches.

Definition at line 79 of file RootDatabase.h.

◆ m_minBufferEntries

int pool::RootDatabase::m_minBufferEntries
private

Minimum buffer entries parameter for Branches.

Definition at line 81 of file RootDatabase.h.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_ntupleIndexMap

std::map<void*, indexLookup_t> pool::RootDatabase::m_ntupleIndexMap
private

Definition at line 129 of file RootDatabase.h.

◆ m_ntupleReaderMap

std::map<std::string, std::unique_ptr<ROOT::RNTupleReader> > pool::RootDatabase::m_ntupleReaderMap
private

Definition at line 126 of file RootDatabase.h.

◆ m_ntupleWriterMap

std::map<std::string, std::unique_ptr<RootStorageSvc::RNTupleWriterHelper> > pool::RootDatabase::m_ntupleWriterMap
private

Definition at line 125 of file RootDatabase.h.

◆ m_rntBufferedWriteEnabled

int pool::RootDatabase::m_rntBufferedWriteEnabled
private

Flag to enable/disable buffered RNTuple writing.

Definition at line 91 of file RootDatabase.h.

◆ m_rntReaderMetricsEnabled

int pool::RootDatabase::m_rntReaderMetricsEnabled
private

Flag to enable/disable RNTupleReader metrics.

Definition at line 93 of file RootDatabase.h.

◆ m_rntWriterMetricsEnabled

int pool::RootDatabase::m_rntWriterMetricsEnabled
private

Flag to enable/disable RNTupleWriter metrics.

Definition at line 95 of file RootDatabase.h.

◆ m_treeNameWithCache

std::string pool::RootDatabase::m_treeNameWithCache
private

Name of tree with cache.

Definition at line 87 of file RootDatabase.h.

◆ m_version

std::string pool::RootDatabase::m_version
private

Persistency format version.

Definition at line 65 of file RootDatabase.h.


The documentation for this class was generated from the following file: