Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
RPageStorageDaos.hxx
Go to the documentation of this file.
1/// \file ROOT/RPageStorageDaos.hxx
2/// \author Javier Lopez-Gomez <j.lopez@cern.ch>
3/// \date 2020-11-03
4/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
5/// is welcome!
6
7/*************************************************************************
8 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
9 * All rights reserved. *
10 * *
11 * For the licensing terms see $ROOTSYS/LICENSE. *
12 * For the list of contributors see $ROOTSYS/README/CREDITS. *
13 *************************************************************************/
14
15#ifndef ROOT_RPageStorageDaos
16#define ROOT_RPageStorageDaos
17
18#include <ROOT/RError.hxx>
19#include <ROOT/RPageStorage.hxx>
20#include <ROOT/RNTuple.hxx>
22#include <ROOT/RNTupleZip.hxx>
23#include <string_view>
24
25#include <array>
26#include <atomic>
27#include <cstdio>
28#include <memory>
29#include <string>
30#include <optional>
31
32namespace ROOT {
33
34namespace Internal {
35class RCluster;
36} // namespace Internal
37
38namespace Experimental {
39namespace Internal {
40using ntuple_index_t = std::uint32_t;
41class RDaosPool;
42class RDaosContainer;
44
45// clang-format off
46/**
47\class ROOT::Experimental::Internal::RDaosNTupleAnchor
48\ingroup NTuple
49\brief Entry point for an RNTuple in a DAOS container. It encodes essential
50information to read the ntuple; currently, it contains (un)compressed size of
51the header/footer blobs and the object class for user data OIDs.
52The length of a serialized anchor cannot be greater than the value returned by the `GetSize` function.
53*/
54// clang-format on
56 /// Allows for evolving the struct in future versions
57 std::uint64_t fVersionAnchor = 1;
58 /// Version of the binary format supported by the writer
63 /// The size of the compressed ntuple header
64 std::uint32_t fNBytesHeader = 0;
65 /// The size of the uncompressed ntuple header
66 std::uint32_t fLenHeader = 0;
67 /// The size of the compressed ntuple footer
68 std::uint32_t fNBytesFooter = 0;
69 /// The size of the uncompressed ntuple footer
70 std::uint32_t fLenFooter = 0;
71 /// The object class for user data OIDs, e.g. `SX`
72 std::string fObjClass{};
73
74 bool operator==(const RDaosNTupleAnchor &other) const
75 {
76 return fVersionAnchor == other.fVersionAnchor && fVersionEpoch == other.fVersionEpoch &&
79 fLenHeader == other.fLenHeader && fNBytesFooter == other.fNBytesFooter && fLenFooter == other.fLenFooter &&
80 fObjClass == other.fObjClass;
81 }
82
83 std::uint32_t Serialize(void *buffer) const;
84 RResult<std::uint32_t> Deserialize(const void *buffer, std::uint32_t bufSize);
85
86 static std::uint32_t GetSize();
87}; // struct RDaosNTupleAnchor
88
89// clang-format off
90/**
91\class ROOT::Experimental::Internal::RPageSinkDaos
92\ingroup NTuple
93\brief Storage provider that writes ntuple pages to into a DAOS container
94
95Currently, an object is allocated for ntuple metadata (anchor/header/footer).
96Objects can correspond to pages or clusters of pages depending on the RNTuple-DAOS mapping strategy.
97*/
98// clang-format on
100private:
101 /// \brief Underlying DAOS container. An internal `std::shared_ptr` keep the pool connection alive.
102 /// ISO C++ ensures the correct destruction order, i.e., `~RDaosContainer` is invoked first
103 /// (which calls `daos_cont_close()`; the destructor for the `std::shared_ptr<RDaosPool>` is invoked
104 /// after (which calls `daos_pool_disconect()`).
105 std::unique_ptr<RDaosContainer> fDaosContainer;
106 /// Page identifier for the next committed page; it is automatically incremented in `CommitSealedPageImpl()`
107 std::atomic<std::uint64_t> fPageId{0};
108 /// Cluster group counter for the next committed cluster pagelist; incremented in `CommitClusterGroupImpl()`
109 std::atomic<std::uint64_t> fClusterGroupId{0};
110 /// \brief A URI to a DAOS pool of the form 'daos://pool-label/container-label'
111 std::string fURI;
112 /// Tracks the number of bytes committed to the current cluster
113 std::uint64_t fNBytesCurrentCluster{0};
114
117
118protected:
120 void InitImpl(unsigned char *serializedHeader, std::uint32_t length) final;
121 RNTupleLocator CommitPageImpl(ColumnHandle_t columnHandle, const ROOT::Internal::RPage &page) final;
123 CommitSealedPageImpl(ROOT::DescriptorId_t physicalColumnId, const RPageStorage::RSealedPage &sealedPage) final;
124 std::vector<RNTupleLocator>
125 CommitSealedPageVImpl(std::span<RPageStorage::RSealedPageGroup> ranges, const std::vector<bool> &mask) final;
126 std::uint64_t StageClusterImpl() final;
127 RNTupleLocator CommitClusterGroupImpl(unsigned char *serializedPageList, std::uint32_t length) final;
129 ROOT::Internal::RNTupleLink CommitDatasetImpl(unsigned char *serializedFooter, std::uint32_t length) final;
130 void WriteNTupleHeader(const void *data, size_t nbytes, size_t lenHeader);
131 void WriteNTupleFooter(const void *data, size_t nbytes, size_t lenFooter);
132 void WriteNTupleAnchor();
133
134public:
135 RPageSinkDaos(std::string_view ntupleName, std::string_view uri, const ROOT::RNTupleWriteOptions &options);
136 ~RPageSinkDaos() override;
137
139 CloneAsHidden(std::string_view name, const ROOT::RNTupleWriteOptions &opts) const final;
140}; // class RPageSinkDaos
141
142// clang-format off
143/**
144\class ROOT::Experimental::Internal::RPageSourceDaos
145\ingroup NTuple
146\brief Storage provider that reads ntuple pages from a DAOS container
147*/
148// clang-format on
150private:
152
153 /// The last cluster from which a page got loaded. Points into fClusterPool->fPool
155 /// A container that stores object data (header/footer, pages, etc.)
156 std::unique_ptr<RDaosContainer> fDaosContainer;
157 /// A URI to a DAOS pool of the form 'daos://pool-label/container-label'
158 std::string fURI;
159
161
163 LoadPageImpl(ColumnHandle_t columnHandle, const RClusterInfo &clusterInfo, ROOT::NTupleSize_t idxInCluster) final;
164
165protected:
166 void LoadStructureImpl() final {}
168 /// The cloned page source creates a new connection to the pool/container.
169 std::unique_ptr<RPageSource> CloneImpl() const final;
170
171public:
172 RPageSourceDaos(std::string_view ntupleName, std::string_view uri, const ROOT::RNTupleReadOptions &options);
173 ~RPageSourceDaos() override;
174
175 void
176 LoadSealedPage(ROOT::DescriptorId_t physicalColumnId, RNTupleLocalIndex localIndex, RSealedPage &sealedPage) final;
177
179 LoadClusters(std::span<ROOT::Internal::RCluster::RKey> clusterKeys) final;
180
181 /// Return the object class used for user data OIDs in this ntuple.
182 std::string GetObjectClass() const;
183
184 void LoadStreamerInfo() final;
185
186 std::unique_ptr<RPageSource> OpenWithDifferentAnchor(const ROOT::Internal::RNTupleLink &anchorLink,
187 const ROOT::RNTupleReadOptions &options = {}) final;
188}; // class RPageSourceDaos
189
190} // namespace Internal
191
192} // namespace Experimental
193} // namespace ROOT
194
195#endif
char name[80]
Definition TGX11.cxx:148
A RDaosContainer provides read/write access to objects in a given container.
Definition RDaos.hxx:156
A RDaosPool provides access to containers in a specific DAOS pool.
Definition RDaos.hxx:65
Storage provider that writes ntuple pages to into a DAOS container.
std::unique_ptr< ROOT::Internal::RPageSink > CloneAsHidden(std::string_view name, const ROOT::RNTupleWriteOptions &opts) const final
Creates a new sink with the same underlying storage as this but writing to a different RNTuple named ...
std::unique_ptr< RDaosContainer > fDaosContainer
Underlying DAOS container.
RNTupleLocator CommitPageImpl(ColumnHandle_t columnHandle, const ROOT::Internal::RPage &page) final
std::uint64_t fNBytesCurrentCluster
Tracks the number of bytes committed to the current cluster.
std::vector< RNTupleLocator > CommitSealedPageVImpl(std::span< RPageStorage::RSealedPageGroup > ranges, const std::vector< bool > &mask) final
Vector commit of preprocessed pages.
std::string fURI
A URI to a DAOS pool of the form 'daos://pool-label/container-label'.
void WriteNTupleFooter(const void *data, size_t nbytes, size_t lenFooter)
std::uint64_t StageClusterImpl() final
Returns the number of bytes written to storage (excluding metadata).
RNTupleLocator CommitClusterGroupImpl(unsigned char *serializedPageList, std::uint32_t length) final
Returns the locator of the page list envelope of the given buffer that contains the serialized page l...
void WriteNTupleHeader(const void *data, size_t nbytes, size_t lenHeader)
void InitImpl(unsigned char *serializedHeader, std::uint32_t length) final
std::atomic< std::uint64_t > fPageId
Page identifier for the next committed page; it is automatically incremented in CommitSealedPageImpl(...
std::atomic< std::uint64_t > fClusterGroupId
Cluster group counter for the next committed cluster pagelist; incremented in CommitClusterGroupImpl(...
RPageSinkDaos(std::string_view ntupleName, std::string_view uri, const ROOT::RNTupleWriteOptions &options)
RNTupleLocator CommitSealedPageImpl(ROOT::DescriptorId_t physicalColumnId, const RPageStorage::RSealedPage &sealedPage) final
Storage provider that reads ntuple pages from a DAOS container.
ROOT::Internal::RPageRef LoadPageImpl(ColumnHandle_t columnHandle, const RClusterInfo &clusterInfo, ROOT::NTupleSize_t idxInCluster) final
std::string fURI
A URI to a DAOS pool of the form 'daos://pool-label/container-label'.
ROOT::Internal::RNTupleDescriptorBuilder fDescriptorBuilder
std::unique_ptr< RDaosContainer > fDaosContainer
A container that stores object data (header/footer, pages, etc.).
ROOT::Internal::RCluster * fCurrentCluster
The last cluster from which a page got loaded. Points into fClusterPool->fPool.
RPageSourceDaos(std::string_view ntupleName, std::string_view uri, const ROOT::RNTupleReadOptions &options)
An in-memory subset of the packed and compressed pages of a cluster.
Definition RCluster.hxx:147
A helper class for piece-wise construction of an RNTupleDescriptor.
Uses standard C++ memory allocation for the column data pages.
Base class for a sink with a physical storage backend.
virtual void InitImpl(unsigned char *serializedHeader, std::uint32_t length)=0
Reference to a page stored in the page pool.
RPageSink(std::string_view ntupleName, const ROOT::RNTupleWriteOptions &options)
Abstract interface to read data from an ntuple.
RPageSource(std::string_view ntupleName, const ROOT::RNTupleReadOptions &fOptions)
RColumnHandle ColumnHandle_t
The column handle identifies a column with the current open page storage.
A page is a slice of a column that is mapped into memory.
Definition RPage.hxx:43
The on-storage metadata of an RNTuple.
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
Generic information about the physical location of data.
Common user-tunable settings for reading RNTuples.
Common user-tunable settings for storing RNTuples.
static constexpr std::uint16_t kVersionPatch
Definition RNTuple.hxx:81
static constexpr std::uint16_t kVersionMajor
Definition RNTuple.hxx:79
static constexpr std::uint16_t kVersionEpoch
Definition RNTuple.hxx:78
static constexpr std::uint16_t kVersionMinor
Definition RNTuple.hxx:80
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
Definition RError.hxx:197
STL class.
STL class.
STL class.
Namespace for ROOT features in testing.
Definition TROOT.h:100
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
Entry point for an RNTuple in a DAOS container.
std::uint32_t fNBytesFooter
The size of the compressed ntuple footer.
std::uint64_t fVersionAnchor
Allows for evolving the struct in future versions.
bool operator==(const RDaosNTupleAnchor &other) const
std::string fObjClass
The object class for user data OIDs, e.g. SX.
std::uint16_t fVersionEpoch
Version of the binary format supported by the writer.
RResult< std::uint32_t > Deserialize(const void *buffer, std::uint32_t bufSize)
std::uint32_t fLenHeader
The size of the uncompressed ntuple header.
std::uint32_t fLenFooter
The size of the uncompressed ntuple footer.
std::uint32_t fNBytesHeader
The size of the compressed ntuple header.
Summarizes cluster-level information that are necessary to load a certain page.
A sealed page contains the bytes of a page as written to storage (packed & compressed).