Skip to content

Commit 13a352d

Browse files
committed
[ntuple] factor out common code in LoadSealedPage()
1 parent 3e6186d commit 13a352d

9 files changed

Lines changed: 44 additions & 69 deletions

tree/ntuple/inc/ROOT/RPageStorage.hxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,9 @@ protected:
731731
virtual void UnzipClusterImpl(ROOT::Internal::RCluster *cluster);
732732
// Returns a page from storage if not found in the page pool. Will never receive requests for zero pages.
733733
virtual ROOT::Internal::RPageRef LoadPageImpl(ColumnHandle_t columnHandle, const RPageSummary &pageSummary) = 0;
734+
// Returns a sealed page from storage without adding it to the page pool. The sealed pages buffer and buffer size
735+
// is already initialized.
736+
virtual void LoadSealedPageImpl(const RNTupleLocator &locator, RSealedPage &sealedPage) = 0;
734737

735738
/// Prepare a page range read for the column set in `clusterKey`. Specifically, pages referencing the
736739
/// `kTypePageZero` locator are filled in `pageZeroMap`; otherwise, `perPageFunc` is called for each page. This is
@@ -818,8 +821,7 @@ public:
818821
/// The `fSize` and `fNElements` member of the sealedPage parameters are always set. If `sealedPage.fBuffer` is
819822
/// `nullptr`, no data will be copied but the returned size information can be used by the caller to allocate a large
820823
/// enough buffer and call `LoadSealedPage` again.
821-
virtual void
822-
LoadSealedPage(ROOT::DescriptorId_t physicalColumnId, RNTupleLocalIndex localIndex, RSealedPage &sealedPage) = 0;
824+
void LoadSealedPage(ROOT::DescriptorId_t physicalColumnId, RNTupleLocalIndex localIndex, RSealedPage &sealedPage);
823825

824826
/// Populates all the pages of the given cluster ids and columns; it is possible that some columns do not
825827
/// contain any pages. The page source may load more columns than the minimal necessary set from `columns`.

tree/ntuple/inc/ROOT/RPageStorageDaos.hxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ private:
160160
ROOT::Internal::RNTupleDescriptorBuilder fDescriptorBuilder;
161161

162162
ROOT::Internal::RPageRef LoadPageImpl(ColumnHandle_t columnHandle, const RPageSummary &pageSummary) final;
163+
void LoadSealedPageImpl(const RNTupleLocator &locator, RSealedPage &sealedPage) final;
163164

164165
protected:
165166
void LoadStructureImpl() final {}
@@ -171,9 +172,6 @@ public:
171172
RPageSourceDaos(std::string_view ntupleName, std::string_view uri, const ROOT::RNTupleReadOptions &options);
172173
~RPageSourceDaos() override;
173174

174-
void
175-
LoadSealedPage(ROOT::DescriptorId_t physicalColumnId, RNTupleLocalIndex localIndex, RSealedPage &sealedPage) final;
176-
177175
std::vector<std::unique_ptr<ROOT::Internal::RCluster>>
178176
LoadClusters(std::span<ROOT::Internal::RCluster::RKey> clusterKeys) final;
179177

tree/ntuple/inc/ROOT/RPageStorageFile.hxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ protected:
181181
std::unique_ptr<RPageSource> CloneImpl() const final;
182182

183183
RPageRef LoadPageImpl(ColumnHandle_t columnHandle, const RPageSummary &pageSummary) final;
184+
void LoadSealedPageImpl(const RNTupleLocator &locator, RSealedPage &sealedPage) final;
184185

185186
public:
186187
RPageSourceFile(std::string_view ntupleName, std::string_view path, const ROOT::RNTupleReadOptions &options);
@@ -200,9 +201,6 @@ public:
200201
std::unique_ptr<RPageSource> OpenWithDifferentAnchor(const ROOT::Internal::RNTupleLink &anchorLink,
201202
const ROOT::RNTupleReadOptions &options = {}) final;
202203

203-
void
204-
LoadSealedPage(ROOT::DescriptorId_t physicalColumnId, RNTupleLocalIndex localIndex, RSealedPage &sealedPage) final;
205-
206204
std::vector<std::unique_ptr<ROOT::Internal::RCluster>>
207205
LoadClusters(std::span<ROOT::Internal::RCluster::RKey> clusterKeys) final;
208206

tree/ntuple/src/RPageStorage.cxx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,36 @@ void ROOT::Internal::RPageSource::UpdateLastUsedCluster(ROOT::DescriptorId_t clu
392392
fLastUsedCluster = clusterId;
393393
}
394394

395+
void ROOT::Internal::RPageSource::LoadSealedPage(ROOT::DescriptorId_t physicalColumnId, RNTupleLocalIndex localIndex,
396+
RSealedPage &sealedPage)
397+
{
398+
const auto clusterId = localIndex.GetClusterId();
399+
400+
ROOT::RClusterDescriptor::RPageInfo pageInfo;
401+
{
402+
auto descriptorGuard = GetSharedDescriptorGuard();
403+
const auto &clusterDescriptor = descriptorGuard->GetClusterDescriptor(clusterId);
404+
pageInfo = clusterDescriptor.GetPageRange(physicalColumnId).Find(localIndex.GetIndexInCluster());
405+
}
406+
407+
sealedPage.SetBufferSize(pageInfo.GetLocator().GetNBytesOnStorage() + pageInfo.HasChecksum() * kNBytesPageChecksum);
408+
sealedPage.SetNElements(pageInfo.GetNElements());
409+
sealedPage.SetHasChecksum(pageInfo.HasChecksum());
410+
411+
if (!sealedPage.GetBuffer())
412+
return;
413+
414+
if (pageInfo.GetLocator().GetType() == RNTupleLocator::kTypePageZero) {
415+
assert(!pageInfo.HasChecksum());
416+
memcpy(const_cast<void *>(sealedPage.GetBuffer()), ROOT::Internal::RPage::GetPageZeroBuffer(),
417+
sealedPage.GetBufferSize());
418+
return;
419+
}
420+
421+
LoadSealedPageImpl(pageInfo.GetLocator(), sealedPage);
422+
sealedPage.VerifyChecksumIfEnabled().ThrowOnError();
423+
}
424+
395425
ROOT::Internal::RPageRef
396426
ROOT::Internal::RPageSource::LoadZeroPage(ColumnHandle_t columnHandle, const RPageSummary &pageSummary)
397427
{

tree/ntuple/src/RPageStorageDaos.cxx

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -515,39 +515,9 @@ std::string ROOT::Experimental::Internal::RPageSourceDaos::GetObjectClass() cons
515515
return fDaosContainer->GetDefaultObjectClass().ToString();
516516
}
517517

518-
void ROOT::Experimental::Internal::RPageSourceDaos::LoadSealedPage(ROOT::DescriptorId_t physicalColumnId,
519-
RNTupleLocalIndex localIndex,
520-
RSealedPage &sealedPage)
518+
void ROOT::Experimental::Internal::RPageSourceDaos::LoadSealedPageImpl(const RNTupleLocator &, RSealedPage &)
521519
{
522-
const auto clusterId = localIndex.GetClusterId();
523-
524-
ROOT::RClusterDescriptor::RPageInfo pageInfo;
525-
{
526-
auto descriptorGuard = GetSharedDescriptorGuard();
527-
const auto &clusterDescriptor = descriptorGuard->GetClusterDescriptor(clusterId);
528-
pageInfo = clusterDescriptor.GetPageRange(physicalColumnId).Find(localIndex.GetIndexInCluster());
529-
}
530-
531-
sealedPage.SetBufferSize(pageInfo.GetLocator().GetNBytesOnStorage() + pageInfo.HasChecksum() * kNBytesPageChecksum);
532-
sealedPage.SetNElements(pageInfo.GetNElements());
533-
sealedPage.SetHasChecksum(pageInfo.HasChecksum());
534-
if (!sealedPage.GetBuffer())
535-
return;
536-
537-
if (pageInfo.GetLocator().GetType() == RNTupleLocator::kTypePageZero) {
538-
assert(!pageInfo.HasChecksum());
539-
memcpy(const_cast<void *>(sealedPage.GetBuffer()), ROOT::Internal::RPage::GetPageZeroBuffer(),
540-
sealedPage.GetBufferSize());
541-
return;
542-
}
543-
544-
RDaosKey daosKey =
545-
GetPageDaosKey<kDefaultDaosMapping>(fNTupleIndex, clusterId, physicalColumnId,
546-
pageInfo.GetLocator().GetPosition<RNTupleLocatorObject64>().GetLocation());
547-
fDaosContainer->ReadSingleAkey(const_cast<void *>(sealedPage.GetBuffer()), sealedPage.GetBufferSize(), daosKey.fOid,
548-
daosKey.fDkey, daosKey.fAkey);
549-
550-
sealedPage.VerifyChecksumIfEnabled().ThrowOnError();
520+
throw ROOT::RException(R__FAIL("temporarily not implemented"));
551521
}
552522

553523
ROOT::Internal::RPageRef ROOT::Experimental::Internal::RPageSourceDaos::LoadPageImpl(ColumnHandle_t columnHandle,

tree/ntuple/src/RPageStorageFile.cxx

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -518,33 +518,10 @@ ROOT::RNTupleDescriptor ROOT::Internal::RPageSourceFile::AttachImpl(RNTupleSeria
518518
return desc;
519519
}
520520

521-
void ROOT::Internal::RPageSourceFile::LoadSealedPage(ROOT::DescriptorId_t physicalColumnId,
522-
RNTupleLocalIndex localIndex, RSealedPage &sealedPage)
521+
void ROOT::Internal::RPageSourceFile::LoadSealedPageImpl(const RNTupleLocator &locator, RSealedPage &sealedPage)
523522
{
524-
const auto clusterId = localIndex.GetClusterId();
525-
526-
ROOT::RClusterDescriptor::RPageInfo pageInfo;
527-
{
528-
auto descriptorGuard = GetSharedDescriptorGuard();
529-
const auto &clusterDescriptor = descriptorGuard->GetClusterDescriptor(clusterId);
530-
pageInfo = clusterDescriptor.GetPageRange(physicalColumnId).Find(localIndex.GetIndexInCluster());
531-
}
532-
533-
sealedPage.SetBufferSize(pageInfo.GetLocator().GetNBytesOnStorage() + pageInfo.HasChecksum() * kNBytesPageChecksum);
534-
sealedPage.SetNElements(pageInfo.GetNElements());
535-
sealedPage.SetHasChecksum(pageInfo.HasChecksum());
536-
if (!sealedPage.GetBuffer())
537-
return;
538-
if (pageInfo.GetLocator().GetType() != RNTupleLocator::kTypePageZero) {
539-
fReader.ReadBuffer(const_cast<void *>(sealedPage.GetBuffer()), sealedPage.GetBufferSize(),
540-
pageInfo.GetLocator().GetPosition<std::uint64_t>());
541-
} else {
542-
assert(!pageInfo.HasChecksum());
543-
memcpy(const_cast<void *>(sealedPage.GetBuffer()), ROOT::Internal::RPage::GetPageZeroBuffer(),
544-
sealedPage.GetBufferSize());
545-
}
546-
547-
sealedPage.VerifyChecksumIfEnabled().ThrowOnError();
523+
fReader.ReadBuffer(const_cast<void *>(sealedPage.GetBuffer()), sealedPage.GetBufferSize(),
524+
locator.GetPosition<std::uint64_t>());
548525
}
549526

550527
ROOT::Internal::RPageRef

tree/ntuple/test/ntuple_cluster.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class RPageSourceMock : public RPageSource {
4242
RNTupleDescriptor AttachImpl(RNTupleSerializer::EDescriptorDeserializeMode) final { return RNTupleDescriptor(); }
4343
std::unique_ptr<RPageSource> CloneImpl() const final { return nullptr; }
4444
RPageRef LoadPageImpl(ColumnHandle_t, const RPageSummary &) final { return RPageRef(); }
45+
void LoadSealedPageImpl(const ROOT::RNTupleLocator &, RSealedPage &) final {}
4546
void LoadStreamerInfo() final {}
4647
std::unique_ptr<ROOT::Internal::RPageSource>
4748
OpenWithDifferentAnchor(const ROOT::Internal::RNTupleLink &, const ROOT::RNTupleReadOptions &) final
@@ -75,7 +76,6 @@ class RPageSourceMock : public RPageSource {
7576
auto descriptorGuard = GetExclDescriptorGuard();
7677
descriptorGuard.MoveIn(descBuilder.MoveDescriptor());
7778
}
78-
void LoadSealedPage(ROOT::DescriptorId_t, ROOT::RNTupleLocalIndex, RSealedPage &) final {}
7979
std::vector<std::unique_ptr<RCluster>> LoadClusters(std::span<RCluster::RKey> clusterKeys) final
8080
{
8181
std::vector<std::unique_ptr<RCluster>> result;

tree/ntuple/test/ntuple_endian.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class RPageSourceMock : public RPageSource {
9494
}
9595
std::unique_ptr<RPageSource> CloneImpl() const final { return nullptr; }
9696
RPageRef LoadPageImpl(ColumnHandle_t, const RPageSummary &) final { return RPageRef(); }
97+
void LoadSealedPageImpl(const ROOT::RNTupleLocator &, RSealedPage &) final {}
9798
void LoadStreamerInfo() final {}
9899

99100
std::unique_ptr<ROOT::Internal::RPageSource>
@@ -115,7 +116,6 @@ class RPageSourceMock : public RPageSource {
115116
return fPagePool.RegisterPage(std::move(page), key);
116117
}
117118
RPageRef LoadPage(ColumnHandle_t, ROOT::RNTupleLocalIndex) final { return RPageRef(); }
118-
void LoadSealedPage(ROOT::DescriptorId_t, ROOT::RNTupleLocalIndex, RSealedPage &) final {}
119119
std::vector<std::unique_ptr<RCluster>> LoadClusters(std::span<RCluster::RKey>) final { return {}; }
120120
};
121121
} // anonymous namespace

tree/ntuple/test/ntuple_pages.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class RPageSourceMock : public RPageSource {
1212
RNTupleDescriptor AttachImpl(RNTupleSerializer::EDescriptorDeserializeMode) final { return RNTupleDescriptor(); }
1313
std::unique_ptr<RPageSource> CloneImpl() const final { return nullptr; }
1414
RPageRef LoadPageImpl(ColumnHandle_t, const RPageSummary &) final { return RPageRef(); }
15+
void LoadSealedPageImpl(const ROOT::RNTupleLocator &, RSealedPage &) final {}
1516
void LoadStreamerInfo() final {}
1617
std::unique_ptr<ROOT::Internal::RPageSource>
1718
OpenWithDifferentAnchor(const ROOT::Internal::RNTupleLink &, const ROOT::RNTupleReadOptions &) final
@@ -21,7 +22,6 @@ class RPageSourceMock : public RPageSource {
2122

2223
public:
2324
RPageSourceMock() : RPageSource("test", RNTupleReadOptions()) {}
24-
void LoadSealedPage(ROOT::DescriptorId_t, ROOT::RNTupleLocalIndex, RSealedPage &) final {}
2525
std::vector<std::unique_ptr<RCluster>> LoadClusters(std::span<RCluster::RKey>) final
2626
{
2727
return std::vector<std::unique_ptr<RCluster>>();

0 commit comments

Comments
 (0)