ATLAS Offline Software
Loading...
Searching...
No Matches
RNTupleContainer.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4//====================================================================
5// Root Database Container RNTuple implementation
6//--------------------------------------------------------------------
7// Author : M.Nowak
8//====================================================================
9#ifndef POOL_RNTUPLECONTAINER_H
10#define POOL_RNTUPLECONTAINER_H 1
11
12// Framework include files
13#include "StorageSvc/DbColumn.h"
16
18
19#include "ROOT/RNTupleView.hxx"
20
21#include <memory>
22#include <optional>
23#include <string>
24#include <vector>
25
26// Forward declarations
27class TClass;
30namespace ROOT { class RNTupleReader; }
31
32// Forward declaration
33namespace pool {
34 class RootDatabase;
35}
36
42
44{
46 struct FieldDesc : public pool::DbColumn
47 {
48 std::string fieldname;
49 std::optional< ROOT::RNTupleView<void> > view;
50 std::string sgkey;
51 TClass* clazz = nullptr;
52 void* object = nullptr;
53
54 // if writing char* keep a copy here as an std::string
55 std::string str;
56
57 // ---- extra variables used for AuxDyn attributes
58 // number of rows written to this branch so far
59 size_t rows_written = 0;
60
61 // AuxDyn RNTuple reader (managed by the Database)
62 std::unique_ptr<RootAuxDynIO::IRootAuxDynReader> auxdyn_reader;
63
64 // AuxDyn RNTuple writer
65 std::unique_ptr<RootAuxDynIO::IRNTupleAuxDynWriter> auxdyn_writer;
66
67 explicit FieldDesc(const DbColumn& c);
68 FieldDesc(FieldDesc const& other) = delete;
69 FieldDesc(FieldDesc&& other) = default;
70 ~FieldDesc() = default;
71
72 FieldDesc& operator=(FieldDesc const& other) = delete;
73 FieldDesc& operator=(FieldDesc&& other) = default;
74
75 const std::string typeName();
76 };
77
78 private:
82 std::vector<FieldDesc> m_fieldDescs;
91
92 uint64_t m_index;
93 uint64_t m_indexSize;
94 int64_t m_indexBump;
95 const uint32_t m_indexMulti;
96
99
101 ROOT::RNTupleReader* m_ntupleReader{};
102
104 std::unique_ptr<RootAuxDynIO::IFactoryTool> m_auxDynTool;
105
106 public:
107 explicit RNTupleContainer(const std::string& name);
109
111 virtual pool::DbStatus close() override final;
112
114 virtual pool::DbStatus open(pool::DbDatabase& dbH, const std::string& nam,
115 const pool::DbTypeInfo* info,
116 pool::DbAccessMode mod) override final;
117
119 virtual pool::DbStatus checkAccess(pool::DbDatabase& dbH,
120 const std::string& nam) const override final;
121
123
127 virtual pool::DbStatus getOption(pool::DbOption& opt) override final;
128
130
134 virtual pool::DbStatus setOption(const pool::DbOption& opt) override final;
135
137 virtual uint64_t size() override final;
138
140 const std::string& getName() const { return m_name; }
141
144 bool isDirty() const { return m_isDirty; }
145
147 void clearDirty() { m_isDirty = false; }
148
150
156 virtual pool::DbStatus loadObject(void** ptr, pool::ShapeH shape,
157 Token::OID_t& oid) override final;
158
160 virtual pool::DbStatus writeObject(ActionList::value_type&) override final;
161
162 virtual uint64_t nextRecordId() override final;
163
164 virtual void useNextRecordId(uint64_t nextID) override final;
165
167 virtual pool::DbStatus select(pool::DbSelect& sel) override final;
168
170 using pool::DbContainerImp::fetch;
171 virtual pool::DbStatus fetch(pool::DbSelect& sel) override final;
172
174 virtual pool::DbStatus transAct(pool::Transaction::Action action) override final;
175
177 virtual pool::DbStatus store(const void* object,
178 pool::DbContainer& cntH,
179 pool::ShapeH shape) override final;
180
181 private:
184};
185
186#endif
virtual uint64_t nextRecordId() override final
Number of next record in the container (=size if no delete is allowed)
std::unique_ptr< RootAuxDynIO::IFactoryTool > m_auxDynTool
Factory object from AuxDynIO plugin that creates AuxDyn readers and writers.
pool::DbStatus initObjectFieldDesc(FieldDesc &dsc)
Init a field description for an object (i.e. find TClass etc.)
pool::DbDatabase m_dbH
Parent Database handle.
const pool::DbTypeInfo * m_type
reference to exact type description
RootStorageSvc::RNTupleWriterHelper * m_ntupleWriter
Internal cache of the RNTupleWriterHelper.
ROOT::RNTupleReader * m_ntupleReader
Internal cache of the native RNTupleReader.
virtual pool::DbStatus writeObject(ActionList::value_type &) override final
Commit single entry to container.
bool m_isDirty
flag set on writing to prevent double writes in the same commit
RNTupleContainer(const std::string &name)
virtual pool::DbStatus store(const void *object, pool::DbContainer &cntH, pool::ShapeH shape) override final
Store object in location.
std::vector< FieldDesc > m_fieldDescs
List of field descriptors.
virtual pool::DbStatus loadObject(void **ptr, pool::ShapeH shape, Token::OID_t &oid) override final
Find object by object identifier and load it into memory.
virtual pool::DbStatus getOption(pool::DbOption &opt) override final
Access options.
virtual uint64_t size() override final
Number of entries within the container.
virtual pool::DbStatus open(pool::DbDatabase &dbH, const std::string &nam, const pool::DbTypeInfo *info, pool::DbAccessMode mod) override final
Open the container for object access.
virtual pool::DbStatus fetch(pool::DbSelect &sel) override final
Fetch next object address of the selection to set token.
virtual pool::DbStatus checkAccess(pool::DbDatabase &dbH, const std::string &nam) const override final
Check if we can access the container for reading with the given type.
void clearDirty()
Clear the dirty status (used after containing TTree was Filled)
virtual pool::DbStatus select(pool::DbSelect &sel) override final
Define selection.
pool::RootDatabase * m_rootDb
Root database file reference.
virtual ~RNTupleContainer()
const std::string & getName() const
Return the name of the container.
int m_ioBytes
Number of bytes written/read during last operation. Set to -1 if it failed.
virtual void useNextRecordId(uint64_t nextID) override final
Suggest next Record ID for tbe next object written - used only with synced indexes.
bool isDirty() const
Return true if this branch container was updated and it's TTree needs to be Filled.
virtual pool::DbStatus close() override final
Close the container and deallocate resources.
virtual pool::DbStatus transAct(pool::Transaction::Action action) override final
Execute transaction action.
const uint32_t m_indexMulti
virtual pool::DbStatus setOption(const pool::DbOption &opt) override final
Set options.
Interface for a RNTuple-based Writer that handles AuxDyn attributes Works in conjuction with the gene...
Description: Definition of the generic column in a (relational) Database.
Definition DbColumn.h:35
DbColumn()
Cache class information (if available) Do not allow unwanted instantiations by users.
Definition DbColumn.h:72
"Generic" Container implementation
std::string m_name
Container name.
virtual std::string name() const override
Get container name.
DbContainerImp(const std::string &name)
Description: Handle managing a DbDatabaseObj, a generic Database object.
Definition DbDatabase.h:53
This class is highly inspired by the error code distribution system as it is used in DEC/VMS or MS/WN...
Definition DbStatus.h:64
Definition of class DbTypeInfo.
Definition DbTypeInfo.h:47
Description: ROOT specific implementation of Database file.
Selection rules: declare transient members.
Definition DataVector.h:581
Specialization of RootAuxDynStore for reading Aux Dynamic attributes from RNTuple.
pool namespace
Definition libname.h:15
const class Shape * ShapeH
STL namespace.
Definition of a field info structure.
FieldDesc & operator=(FieldDesc const &other)=delete
FieldDesc(const DbColumn &c)
std::unique_ptr< RootAuxDynIO::IRootAuxDynReader > auxdyn_reader
FieldDesc(FieldDesc const &other)=delete
FieldDesc(FieldDesc &&other)=default
std::optional< ROOT::RNTupleView< void > > view
std::unique_ptr< RootAuxDynIO::IRNTupleAuxDynWriter > auxdyn_writer
const std::string typeName()
FieldDesc & operator=(FieldDesc &&other)=default
#define private