Skip to content

Commit e9d61c7

Browse files
committed
[ntuple] some renaming and cleanup in RNTupleMerger
1 parent e166302 commit e9d61c7

File tree

3 files changed

+33
-34
lines changed

3 files changed

+33
-34
lines changed

tree/ntuple/v7/inc/ROOT/RNTupleMerger.hxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ namespace Experimental {
3232
namespace Internal {
3333

3434
struct RNTupleMergeOptions {
35-
/// If `fCompressionSettings == -1` (the default), the merger will not change the compression
36-
/// of any of its sources (fast merging). Otherwise, all sources will be converted to the specified
35+
/// If `fCompressionSettings == kUnknownCompressionSettings` (the default), the merger will not change the
36+
/// compression of any of its sources (fast merging). Otherwise, all sources will be converted to the specified
3737
/// compression algorithm and level.
38-
int fCompressionSettings = -1;
38+
int fCompressionSettings = kUnknownCompressionSettings;
3939
};
4040

4141
// clang-format off

tree/ntuple/v7/inc/ROOT/RPageStorage.hxx

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ public:
472472
bool IntersectsWith(const RClusterDescriptor &clusterDesc) const;
473473
};
474474

475-
/// An RAII wrapper used for the read-only access to RPageSource::fDescriptor. See GetExclDescriptorGuard().
475+
/// An RAII wrapper used for the read-only access to `RPageSource::fDescriptor`. See `GetExclDescriptorGuard()``.
476476
class RSharedDescriptorGuard {
477477
const RNTupleDescriptor &fDescriptor;
478478
std::shared_mutex &fLock;
@@ -491,7 +491,7 @@ public:
491491
const RNTupleDescriptor &GetRef() const { return fDescriptor; }
492492
};
493493

494-
/// An RAII wrapper used for the writable access to RPageSource::fDescriptor. See GetSharedDescriptorGuard().
494+
/// An RAII wrapper used for the writable access to `RPageSource::fDescriptor`. See `GetSharedDescriptorGuard()`.
495495
class RExclDescriptorGuard {
496496
RNTupleDescriptor &fDescriptor;
497497
std::shared_mutex &fLock;
@@ -518,11 +518,11 @@ private:
518518
RNTupleDescriptor fDescriptor;
519519
mutable std::shared_mutex fDescriptorLock;
520520
REntryRange fEntryRange; ///< Used by the cluster pool to prevent reading beyond the given range
521-
bool fHasStructure = false; ///< Set to true once LoadStructure() is called
522-
bool fIsAttached = false; ///< Set to true once Attach() is called
521+
bool fHasStructure = false; ///< Set to true once `LoadStructure()` is called
522+
bool fIsAttached = false; ///< Set to true once `Attach()` is called
523523

524524
protected:
525-
/// Default I/O performance counters that get registered in fMetrics
525+
/// Default I/O performance counters that get registered in `fMetrics`
526526
struct RCounters {
527527
Detail::RNTupleAtomicCounter &fNReadV;
528528
Detail::RNTupleAtomicCounter &fNRead;
@@ -562,15 +562,15 @@ protected:
562562
/// The active columns are implicitly defined by the model fields or views
563563
RActivePhysicalColumns fActivePhysicalColumns;
564564

565-
/// Helper to unzip pages and header/footer; comprises a 16MB (kMAXZIPBUF) unzip buffer.
565+
/// Helper to unzip pages and header/footer; comprises a 16MB (`kMAXZIPBUF`) unzip buffer.
566566
/// Not all page sources need a decompressor (e.g. virtual ones for chains and friends don't), thus we
567567
/// leave it up to the derived class whether or not the decompressor gets constructed.
568568
std::unique_ptr<RNTupleDecompressor> fDecompressor;
569569
/// Populated pages might be shared; the page pool might, at some point, be used by multiple page sources
570570
std::shared_ptr<RPagePool> fPagePool;
571571

572572
virtual void LoadStructureImpl() = 0;
573-
/// LoadStructureImpl() has been called before AttachImpl() is called
573+
/// `LoadStructureImpl()` has been called before `AttachImpl()` is called
574574
virtual RNTupleDescriptor AttachImpl() = 0;
575575
/// Returns a new, unattached page source for the same data set
576576
virtual std::unique_ptr<RPageSource> CloneImpl() const = 0;
@@ -589,10 +589,10 @@ protected:
589589
/// A subclass using the default set of metrics is responsible for updating the counters
590590
/// appropriately, e.g. `fCounters->fNRead.Inc()`
591591
/// Alternatively, a subclass might provide its own RNTupleMetrics object by overriding the
592-
/// GetMetrics() member function.
592+
/// `GetMetrics()` member function.
593593
void EnableDefaultMetrics(const std::string &prefix);
594594

595-
/// Note that the underlying lock is not recursive. See GetSharedDescriptorGuard() for further information.
595+
/// Note that the underlying lock is not recursive. See `GetSharedDescriptorGuard()` for further information.
596596
RExclDescriptorGuard GetExclDescriptorGuard() { return RExclDescriptorGuard(fDescriptor, fDescriptorLock); }
597597

598598
public:
@@ -614,12 +614,11 @@ public:
614614
const RNTupleReadOptions &GetReadOptions() const { return fOptions; }
615615

616616
/// Takes the read lock for the descriptor. Multiple threads can take the lock concurrently.
617-
/// The underlying std::shared_mutex, however, is neither read nor write recursive:
617+
/// The underlying `std::shared_mutex`, however, is neither read nor write recursive:
618618
/// within one thread, only one lock (shared or exclusive) must be acquired at the same time. This requires special
619-
/// care in sections protected by GetSharedDescriptorGuard() and GetExclDescriptorGuard() especially to avoid that
620-
/// the locks are acquired indirectly (e.g. by a call to GetNEntries()).
621-
/// As a general guideline, no other method of the page source should be called (directly or indirectly) in a
622-
/// guarded section.
619+
/// care in sections protected by `GetSharedDescriptorGuard()` and `GetExclDescriptorGuard()` especially to avoid
620+
/// that the locks are acquired indirectly (e.g. by a call to `GetNEntries()`). As a general guideline, no other
621+
/// method of the page source should be called (directly or indirectly) in a guarded section.
623622
const RSharedDescriptorGuard GetSharedDescriptorGuard() const
624623
{
625624
return RSharedDescriptorGuard(fDescriptor, fDescriptorLock);
@@ -629,9 +628,9 @@ public:
629628
void DropColumn(ColumnHandle_t columnHandle) override;
630629

631630
/// Loads header and footer without decompressing or deserializing them. This can be used to asynchronously open
632-
/// a file in the background. The method is idempotent and it is called as a first step in Attach().
631+
/// a file in the background. The method is idempotent and it is called as a first step in `Attach()`.
633632
/// Pages sources may or may not make use of splitting loading and processing meta-data.
634-
/// Therefore, LoadStructure() may do nothing and defer loading the meta-data to Attach().
633+
/// Therefore, `LoadStructure()` may do nothing and defer loading the meta-data to `Attach()`.
635634
void LoadStructure();
636635
/// Open the physical storage container and deserialize header and footer
637636
void Attach();
@@ -640,13 +639,13 @@ public:
640639
ColumnId_t GetColumnId(ColumnHandle_t columnHandle);
641640

642641
/// Promise to only read from the given entry range. If set, prevents the cluster pool from reading-ahead beyond
643-
/// the given range. The range needs to be within [0, GetNEntries()).
642+
/// the given range. The range needs to be within `[0, GetNEntries())`.
644643
void SetEntryRange(const REntryRange &range);
645644
REntryRange GetEntryRange() const { return fEntryRange; }
646645

647646
/// Allocates and fills a page that contains the index-th element
648647
virtual RPage PopulatePage(ColumnHandle_t columnHandle, NTupleSize_t globalIndex) = 0;
649-
/// Another version of PopulatePage that allows to specify cluster-relative indexes
648+
/// Another version of `PopulatePage` that allows to specify cluster-relative indexes
650649
virtual RPage PopulatePage(ColumnHandle_t columnHandle, RClusterIndex clusterIndex) = 0;
651650

652651
/// Read the packed and compressed bytes of a page into the memory buffer provided by `sealedPage`. The sealed page
@@ -667,10 +666,10 @@ public:
667666

668667
/// Populates all the pages of the given cluster ids and columns; it is possible that some columns do not
669668
/// contain any pages. The page source may load more columns than the minimal necessary set from `columns`.
670-
/// To indicate which columns have been loaded, LoadClusters() must mark them with SetColumnAvailable().
669+
/// To indicate which columns have been loaded, `LoadClusters()`` must mark them with `SetColumnAvailable()`.
671670
/// That includes the ones from the `columns` that don't have pages; otherwise subsequent requests
672671
/// for the cluster would assume an incomplete cluster and trigger loading again.
673-
/// LoadClusters() is typically called from the I/O thread of a cluster pool, i.e. the method runs
672+
/// `LoadClusters()` is typically called from the I/O thread of a cluster pool, i.e. the method runs
674673
/// concurrently to other methods of the page source.
675674
virtual std::vector<std::unique_ptr<RCluster>> LoadClusters(std::span<RCluster::RKey> clusterKeys) = 0;
676675

tree/ntuple/v7/src/RNTupleMerger.cxx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ void ROOT::Experimental::Internal::RNTupleMerger::Merge(std::span<RPageSource *>
255255
sealedPages.resize(pages.fPageInfos.size());
256256

257257
const auto colRangeCompressionSettings = clusterDesc.GetColumnRange(columnId).fCompressionSettings;
258-
const bool needsCompressionChange =
259-
options.fCompressionSettings != -1 && colRangeCompressionSettings != options.fCompressionSettings;
258+
const bool needsCompressionChange = options.fCompressionSettings != kUnknownCompressionSettings &&
259+
colRangeCompressionSettings != options.fCompressionSettings;
260260

261261
// If the column range is already uncompressed we don't need to allocate any new buffer, so we don't
262262
// bother reserving memory for them.
@@ -266,24 +266,24 @@ void ROOT::Experimental::Internal::RNTupleMerger::Merge(std::span<RPageSource *>
266266

267267
sealedPageGroups.reserve(sealedPageGroups.size() + pages.fPageInfos.size());
268268

269-
std::uint64_t pageNo = 0;
269+
std::uint64_t pageIdx = 0;
270270

271271
// Loop over the pages
272272
for (const auto &pageInfo : pages.fPageInfos) {
273273
auto taskFunc = [ // values in
274-
columnId, pageNo, cluster, needsCompressionChange, colRangeCompressionSettings,
274+
columnId, pageIdx, cluster, needsCompressionChange, colRangeCompressionSettings,
275275
pageBufferBaseIdx,
276276
// const refs in
277277
&colElement, &pageInfo, &options,
278278
// refs out
279279
&sealedPages, &sealedPageBuffers]() {
280-
assert(pageNo < sealedPages.size());
281-
assert(sealedPageBuffers.size() == 0 || pageNo < sealedPageBuffers.size());
280+
assert(pageIdx < sealedPages.size());
281+
assert(sealedPageBuffers.size() == 0 || pageIdx < sealedPageBuffers.size());
282282

283-
ROnDiskPage::Key key{columnId, pageNo};
283+
ROnDiskPage::Key key{columnId, pageIdx};
284284
auto onDiskPage = cluster->GetOnDiskPage(key);
285285

286-
RPageStorage::RSealedPage &sealedPage = sealedPages[pageNo];
286+
RPageStorage::RSealedPage &sealedPage = sealedPages[pageIdx];
287287
sealedPage.SetNElements(pageInfo.fNElements);
288288
sealedPage.SetHasChecksum(pageInfo.fHasChecksum);
289289
sealedPage.SetBufferSize(pageInfo.fLocator.fBytesOnStorage +
@@ -312,9 +312,9 @@ void ROOT::Experimental::Internal::RNTupleMerger::Merge(std::span<RPageSource *>
312312
// only safe bet is to allocate a buffer big enough to hold as many bytes as the uncompressed
313313
// data.
314314
R__ASSERT(sealedPage.GetBufferSize() < uncompressedSize);
315-
sealedPageBuffers[pageBufferBaseIdx + pageNo] =
315+
sealedPageBuffers[pageBufferBaseIdx + pageIdx] =
316316
std::make_unique<unsigned char[]>(uncompressedSize);
317-
sealedPage.SetBuffer(sealedPageBuffers[pageNo].get());
317+
sealedPage.SetBuffer(sealedPageBuffers[pageIdx].get());
318318
} else {
319319
// source column range is uncompressed. We can reuse the sealedPage's buffer since it's big
320320
// enough.
@@ -333,7 +333,7 @@ void ROOT::Experimental::Internal::RNTupleMerger::Merge(std::span<RPageSource *>
333333
else
334334
taskFunc();
335335

336-
++pageNo;
336+
++pageIdx;
337337

338338
} // end of loop over pages
339339

0 commit comments

Comments
 (0)