54 DistributionKey_t fDkey;
62static constexpr DistributionKey_t kDistributionKeyDefault = 0x5a3c69f0cafe4a11;
63static constexpr AttributeKey_t kAttributeKeyDefault = 0x4243544b53444229;
64static constexpr AttributeKey_t kAttributeKeyAnchor = 0x4243544b5344422a;
65static constexpr AttributeKey_t kAttributeKeyHeader = 0x4243544b5344422b;
66static constexpr AttributeKey_t kAttributeKeyFooter = 0x4243544b5344422c;
78 kDistributionKeyDefault, kAttributeKeyDefault};
83 std::string fPoolLabel;
85 std::string fContainerLabel;
91RDaosURI ParseDaosURI(std::string_view uri)
93 std::regex re(
"daos://([^/]+)/(.+)");
95 if (!std::regex_match(uri.data(),
m, re))
107struct RDaosContainerNTupleLocator {
110 std::optional<ROOT::Experimental::Internal::RDaosNTupleAnchor> fAnchor;
113 RDaosContainerNTupleLocator() =
default;
114 explicit RDaosContainerNTupleLocator(
const std::string &ntupleName) : fName(ntupleName), fIndex(
Hash(ntupleName)) {}
116 bool IsValid() {
return fAnchor.has_value() && fAnchor->fNBytesHeader; }
121 uint64_t
h = std::hash<std::string>{}(ntupleName);
123 auto seed =
static_cast<uint32_t
>(
h >> 32);
124 seed ^=
static_cast<uint32_t
>(
h & 0xffffffff) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
126 return (hash == kReservedIndex) ? kReservedIndex + 1 : hash;
129 int InitNTupleDescriptorBuilder(ROOT::Experimental::Internal::RDaosContainer &cont,
130 ROOT::Internal::RNTupleDescriptorBuilder &builder)
132 std::unique_ptr<unsigned char[]> buffer, zipBuffer;
133 auto &anchor = fAnchor.emplace();
137 daos_obj_id_t oidMetadata{kOidLowMetadata,
static_cast<decltype(
daos_obj_id_t::hi)
>(this->GetIndex())};
140 if ((err = cont.
ReadSingleAkey(buffer.get(), anchorSize, oidMetadata, kDistributionKeyDefault,
141 kAttributeKeyAnchor, kCidMetadata))) {
145 anchor.Deserialize(buffer.get(), anchorSize).Unwrap();
147 builder.
SetVersion(anchor.fVersionEpoch, anchor.fVersionMajor, anchor.fVersionMinor, anchor.fVersionPatch);
151 if ((err = cont.
ReadSingleAkey(zipBuffer.get(), anchor.fNBytesHeader, oidMetadata, kDistributionKeyDefault,
152 kAttributeKeyHeader, kCidMetadata)))
160 if ((err = cont.
ReadSingleAkey(zipBuffer.get(), anchor.fNBytesFooter, oidMetadata, kDistributionKeyDefault,
161 kAttributeKeyFooter, kCidMetadata)))
169 static std::pair<RDaosContainerNTupleLocator, ROOT::Internal::RNTupleDescriptorBuilder>
170 LocateNTuple(ROOT::Experimental::Internal::RDaosContainer &cont,
const std::string &ntupleName)
172 auto result = std::make_pair(RDaosContainerNTupleLocator(ntupleName), ROOT::Internal::RNTupleDescriptorBuilder());
175 auto &builder =
result.second;
177 if (
int err = loc.InitNTupleDescriptorBuilder(cont, builder); !err) {
180 throw ROOT::RException(
181 R__FAIL(
"LocateNTuple: ntuple name '" + ntupleName +
"' unavailable in this container."));
194 if (buffer !=
nullptr) {
195 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
214 return R__FAIL(
"DAOS anchor too short");
216 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
233 return result.Unwrap() + 32;
247 static std::once_flag once;
248 std::call_once(once, []() {
250 <<
"Do not store real data with this version of RNTuple!";
262 if (oclass.IsUnknown())
265 auto args = ParseDaosURI(
fURI);
266 auto pool = std::make_shared<RDaosPool>(args.fPoolLabel);
268 fDaosContainer = std::make_unique<RDaosContainer>(pool, args.fContainerLabel,
true);
287 sealedPage =
SealPage(page, *element);
298 auto pageId =
fPageId.fetch_add(1);
302 RDaosKey daosKey = GetPageDaosKey(
fNTupleIndex, pageId);
317std::vector<ROOT::RNTupleLocator>
319 const std::vector<bool> &
mask)
322 std::vector<RNTupleLocator> locators;
323 auto nPages =
mask.size();
324 locators.reserve(nPages);
326 int64_t payloadSz = 0;
329 for (
auto &range : ranges) {
330 for (
auto sealedPageIt = range.fFirst; sealedPageIt != range.fLast; ++sealedPageIt) {
333 const auto pageId =
fPageId.fetch_add(1);
338 RDaosKey daosKey = GetPageDaosKey(
fNTupleIndex, pageId);
341 it->second.Insert(daosKey.fAkey, pageIov);
347 locators.push_back(locator);
361 fCounters->fSzWritePayload.Add(payloadSz);
381 bufPageListZip.get(), szPageListZip,
382 daos_obj_id_t{kOidLowPageList, static_cast<decltype(daos_obj_id_t::hi)>(fNTupleIndex)}, kDistributionKeyDefault,
383 offsetData, kCidMetadata);
386 result.SetNBytesOnStorage(szPageListZip);
388 fCounters->fSzWritePayload.Add(
static_cast<int64_t
>(szPageListZip));
409 kDistributionKeyDefault, kAttributeKeyHeader, kCidMetadata);
418 kDistributionKeyDefault, kAttributeKeyFooter, kCidMetadata);
429 buffer.get(), ntplSize,
daos_obj_id_t{kOidLowMetadata, static_cast<decltype(daos_obj_id_t::hi)>(fNTupleIndex)},
430 kDistributionKeyDefault, kAttributeKeyAnchor, kCidMetadata);
433std::unique_ptr<ROOT::Internal::RPageSink>
448 auto args = ParseDaosURI(uri);
449 auto pool = std::make_shared<RDaosPool>(args.fPoolLabel);
450 fDaosContainer = std::make_unique<RDaosContainer>(pool, args.fContainerLabel);
462 std::unique_ptr<unsigned char[]> buffer, zipBuffer;
465 if (!locator.IsValid())
467 R__FAIL(
"Attach: requested ntuple '" +
fNTupleName +
"' is not present in DAOS container."));
470 if (oclass.IsUnknown())
477 auto desc = descBuilder.MoveDescriptor();
479 for (
const auto &cgDesc : desc.GetClusterGroupIterable()) {
483 zipBuffer.get(), cgDesc.GetPageListLocator().GetNBytesOnStorage(), oidPageList, kDistributionKeyDefault,
486 cgDesc.GetPageListLength(), buffer.get());
504 daosKey.fDkey, daosKey.fAkey);
510 return std::unique_ptr<RPageSourceDaos>(clone);
513std::vector<std::unique_ptr<RCluster>>
516 struct RDaosSealedPageLocator {
520 std::uint64_t fPageId = 0;
521 std::uint64_t fDataSize = 0;
522 std::uint64_t fBufferSize = 0;
529 auto fnPrepareSingleCluster = [&](
const RCluster::RKey &clusterKey,
532 std::vector<RDaosSealedPageLocator> onDiskPages;
534 unsigned clusterBufSz = 0, nPages = 0;
535 auto pageZeroMap = std::make_unique<ROOT::Internal::ROnDiskPageMap>();
537 clusterKey, *pageZeroMap,
540 const auto &pageLocator = pageInfo.
GetLocator();
543 onDiskPages.emplace_back(RDaosSealedPageLocator{clusterId, physicalColumnId, pageNo, pageId,
544 pageLocator.GetNBytesOnStorage(), pageBufferSize});
547 clusterBufSz += pageBufferSize;
550 auto clusterBuffer =
new unsigned char[clusterBufSz];
552 std::make_unique<ROOT::Internal::ROnDiskPageMapHeap>(std::unique_ptr<
unsigned char[]>(clusterBuffer));
555 for (
const auto &sealedLoc : onDiskPages) {
561 d_iov_set(&iov, clusterBuffer, sealedLoc.fBufferSize);
563 RDaosKey daosKey = GetPageDaosKey(
fNTupleIndex, sealedLoc.fPageId);
566 itReq->second.Insert(daosKey.fAkey, iov);
568 clusterBuffer += sealedLoc.fBufferSize;
571 fCounters->fSzReadPayload.Add(clusterBufSz);
573 auto cluster = std::make_unique<RCluster>(clusterId);
574 cluster->Adopt(std::move(pageMap));
575 cluster->Adopt(std::move(pageZeroMap));
577 cluster->SetColumnAvailable(colId);
581 fCounters->fNClusterLoaded.Add(clusterKeys.size());
583 std::vector<std::unique_ptr<ROOT::Internal::RCluster>> clusters;
585 for (
auto key : clusterKeys) {
586 clusters.emplace_back(fnPrepareSingleCluster(key, readRequests));
595 fCounters->fNRead.Add(readRequests.size());
605std::unique_ptr<ROOT::Internal::RPageSource>
#define R__FORWARD_ERROR(res)
Short-hand to return an RResult<T> in an error state (i.e. after checking)
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
#define R__LOG_WARNING(...)
std::unique_ptr< T[]> MakeUninitArray(std::size_t size)
Make an array of default-initialized elements.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t bytes
UInt_t Hash(const TString &s)
static void Unzip(const void *from, size_t nbytes, size_t dataLen, void *to)
The nbytes parameter provides the size ls of the from buffer.
static RResult< void > DeserializeFooter(const void *buffer, std::uint64_t bufSize, ROOT::Internal::RNTupleDescriptorBuilder &descBuilder)
static RResult< void > DeserializeHeader(const void *buffer, std::uint64_t bufSize, ROOT::Internal::RNTupleDescriptorBuilder &descBuilder)
RDaosObject::DistributionKey_t DistributionKey_t
std::unordered_map< ROidDkeyPair, RWOperation, ROidDkeyPair::Hash > MultiObjectRWOperation_t
int ReadSingleAkey(void *buffer, std::size_t length, daos_obj_id_t oid, DistributionKey_t dkey, AttributeKey_t akey, ObjClassId_t cid)
Read data from a single object attribute key to the given buffer.
RDaosObject::AttributeKey_t AttributeKey_t
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
ntuple_index_t fNTupleIndex
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'.
RDaosNTupleAnchor fNTupleAnchor
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() override
RNTupleLink CommitDatasetImpl() final
RPageSinkDaos(std::string_view ntupleName, std::string_view uri, const ROOT::RNTupleWriteOptions &options)
RNTupleLocator CommitSealedPageImpl(ROOT::DescriptorId_t physicalColumnId, const RPageStorage::RSealedPage &sealedPage) final
void LoadStreamerInfo() final
Forces the loading of ROOT StreamerInfo from the underlying file. This currently only has an effect f...
std::string GetObjectClass() const
Return the object class used for user data OIDs in this ntuple.
std::unique_ptr< RPageSource > CloneImpl() const final
The cloned page source creates a new connection to the pool/container.
void LoadSealedPageImpl(const RNTupleLocator &locator, RSealedPage &sealedPage) final
std::vector< std::unique_ptr< ROOT::Internal::RCluster > > LoadClusters(std::span< ROOT::Internal::RCluster::RKey > clusterKeys) final
Populates all the pages of the given cluster ids and columns; it is possible that some columns do not...
std::string fURI
A URI to a DAOS pool of the form 'daos://pool-label/container-label'.
ntuple_index_t fNTupleIndex
~RPageSourceDaos() override
std::unique_ptr< RPageSource > OpenWithDifferentAnchor(const ROOT::Internal::RNTupleLink &anchorLink, const ROOT::RNTupleReadOptions &options={}) final
Creates a new PageSource using the same underlying file as this but referring to a different RNTuple,...
std::unique_ptr< RDaosContainer > fDaosContainer
A container that stores object data (header/footer, pages, etc.)
RPageSourceDaos(std::string_view ntupleName, std::string_view uri, const ROOT::RNTupleReadOptions &options)
ROOT::RNTupleDescriptor AttachImpl(ROOT::Internal::RNTupleSerializer::EDescriptorDeserializeMode mode) final
LoadStructureImpl() has been called before AttachImpl() is called
DAOS-specific user-tunable settings for storing ntuples.
const std::string & GetObjectClass() const
An in-memory subset of the packed and compressed pages of a cluster.
ROOT::Internal::RColumnElementBase * GetElement() const
Helper class to compress data blocks in the ROOT compression frame format.
static std::size_t Zip(const void *from, std::size_t nbytes, int compression, void *to)
Returns the size of the compressed data, written into the provided output buffer.
Helper class to uncompress data blocks in the ROOT compression frame format.
static void Unzip(const void *from, size_t nbytes, size_t dataLen, void *to)
The nbytes parameter provides the size ls of the from buffer.
void SetVersion(std::uint16_t versionEpoch, std::uint16_t versionMajor, std::uint16_t versionMinor, std::uint16_t versionPatch)
const RNTupleDescriptor & GetDescriptor() const
void SetOnDiskHeaderSize(std::uint64_t size)
void AddToOnDiskFooterSize(std::uint64_t size)
The real footer size also include the page list envelopes.
A helper class for serializing and deserialization of the RNTuple binary format.
static RResult< std::uint32_t > DeserializeString(const void *buffer, std::uint64_t bufSize, std::string &val)
static std::uint32_t SerializeUInt32(std::uint32_t val, void *buffer)
static std::uint32_t DeserializeUInt32(const void *buffer, std::uint32_t &val)
static std::uint32_t SerializeUInt16(std::uint16_t val, void *buffer)
static RResult< void > DeserializePageList(const void *buffer, std::uint64_t bufSize, ROOT::DescriptorId_t clusterGroupId, RNTupleDescriptor &desc, EDescriptorDeserializeMode mode)
static std::uint32_t SerializeString(const std::string &val, void *buffer)
static std::uint32_t DeserializeUInt16(const void *buffer, std::uint16_t &val)
EDescriptorDeserializeMode
static std::uint32_t DeserializeUInt64(const void *buffer, std::uint64_t &val)
static std::uint32_t SerializeUInt64(std::uint64_t val, void *buffer)
A page as being stored on disk, that is packed and compressed.
RPagePersistentSink(std::string_view ntupleName, const ROOT::RNTupleWriteOptions &options)
std::unique_ptr< RCounters > fCounters
void EnableDefaultMetrics(const std::string &prefix)
Enables the default set of metrics provided by RPageSink.
std::unique_ptr< ROOT::RNTupleWriteOptions > fOptions
const ROOT::RNTupleWriteOptions & GetWriteOptions() const
Returns the sink's write options.
RSealedPage SealPage(const ROOT::Internal::RPage &page, const ROOT::Internal::RColumnElementBase &element)
Helper for streaming a page.
ROOT::RNTupleReadOptions fOptions
void StopClusterPoolBackgroundThread()
void PrepareLoadCluster(const ROOT::Internal::RCluster::RKey &clusterKey, ROOT::Internal::ROnDiskPageMap &pageZeroMap, std::function< void(ROOT::DescriptorId_t, ROOT::NTupleSize_t, const ROOT::RClusterDescriptor::RPageInfo &)> perPageFunc)
Prepare a page range read for the column set in clusterKey. Specifically, pages referencing the kType...
void EnableDefaultMetrics(const std::string &prefix)
Enables the default set of metrics provided by RPageSource. prefix will be used as the prefix for the...
std::unique_ptr< RCounters > fCounters
RPageSource(std::string_view ntupleName, const ROOT::RNTupleReadOptions &fOptions)
static constexpr std::size_t kNBytesPageChecksum
The page checksum is a 64bit xxhash3.
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.
std::size_t GetNBytes() const
The space taken by column elements in the buffer.
Base class for all ROOT issued exceptions.
The on-storage metadata of an RNTuple.
const std::string & GetName() const
RNTupleLocator payload that is common for object stores using 64bit location information.
std::uint64_t GetLocation() const
Generic information about the physical location of data.
T GetPosition() const
Note that for GetPosition() / SetPosition(), the locator type must correspond (kTypeFile,...
void SetType(ELocatorType type)
void SetPosition(std::uint64_t position)
void SetNBytesOnStorage(std::uint64_t nBytesOnStorage)
Common user-tunable settings for reading RNTuples.
Common user-tunable settings for storing RNTuples.
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
const char * d_errstr(int rc)
static void d_iov_set(d_iov_t *iov, void *buf, size_t size)
uint16_t daos_oclass_id_t
RNTupleTimer< RNTupleAtomicCounter, RNTupleTickCounter< RNTupleAtomicCounter > > RNTupleAtomicTimer
std::uint32_t ntuple_index_t
ROOT::RLogChannel & NTupleLog()
Log channel for RNTuple diagnostics.
std::unique_ptr< T[]> MakeUninitArray(std::size_t size)
Make an array of default-initialized elements.
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.
A pair of <object ID, distribution key> that can be used to issue a fetch/update request for multiple...
Describes a read/write operation on multiple attribute keys under the same object ID and distribution...
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.
std::string fObjClass
The object class for user data OIDs, e.g. SX
std::uint16_t fVersionPatch
std::uint32_t Serialize(void *buffer) const
std::uint16_t fVersionEpoch
Version of the binary format supported by the writer.
std::uint16_t fVersionMinor
RResult< std::uint32_t > Deserialize(const void *buffer, std::uint32_t bufSize)
std::uint32_t fLenHeader
The size of the uncompressed ntuple header.
static std::uint32_t GetSize()
std::uint32_t fLenFooter
The size of the uncompressed ntuple footer.
std::uint16_t fVersionMajor
std::uint32_t fNBytesHeader
The size of the compressed ntuple header.
Wrap around a daos_oclass_id_t.
static constexpr std::size_t kOCNameMaxLength
This limit is currently not defined in any header and any call to daos_oclass_id2name() within DAOS u...
The identifiers that specifies the content of a (partial) cluster.
ROOT::DescriptorId_t fClusterId
ColumnSet_t fPhysicalColumnSet
On-disk pages within a page source are identified by the column and page number.
ROOT::Internal::RColumn * fColumn
ROOT::DescriptorId_t fPhysicalId
A sealed page contains the bytes of a page as written to storage (packed & compressed).
const void * GetBuffer() const
std::size_t GetBufferSize() const
std::size_t GetDataSize() const
Information about a single page in the context of a cluster's page range.
const RNTupleLocator & GetLocator() const