Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RPageStorage.hxx
Go to the documentation of this file.
1/// \file ROOT/RPageStorage.hxx
2/// \ingroup NTuple
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2018-07-19
5
6/*************************************************************************
7 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
8 * All rights reserved. *
9 * *
10 * For the licensing terms see $ROOTSYS/LICENSE. *
11 * For the list of contributors see $ROOTSYS/README/CREDITS. *
12 *************************************************************************/
13
14#ifndef ROOT_RPageStorage
15#define ROOT_RPageStorage
16
17#include <ROOT/RError.hxx>
18#include <ROOT/RCluster.hxx>
19#include <ROOT/RClusterPool.hxx>
26#include <ROOT/RNTupleTypes.hxx>
27#include <ROOT/RPage.hxx>
28#include <ROOT/RPagePool.hxx>
29#include <ROOT/RSpan.hxx>
30#include <string_view>
31
32#include <atomic>
33#include <cassert>
34#include <cstddef>
35#include <deque>
36#include <functional>
37#include <map>
38#include <memory>
39#include <mutex>
40#include <set>
41#include <shared_mutex>
42#include <unordered_map>
43#include <unordered_set>
44#include <vector>
45
46namespace ROOT {
47
48class RNTupleModel;
49
50namespace Internal {
51
52class RPageAllocator;
53class RColumn;
54struct RNTupleModelChangeset;
55
56enum class EPageStorageType {
57 kSink,
58 kSource,
59};
60
61// clang-format off
62/**
63\class ROOT::Internal::RPageStorage
64\ingroup NTuple
65\brief Common functionality of an ntuple storage for both reading and writing
66
67The RPageStore provides access to a storage container that keeps the bits of pages and clusters comprising
68an ntuple. Concrete implementations can use a TFile, a raw file, an object store, and so on.
69*/
70// clang-format on
72public:
73 /// The page checksum is a 64bit xxhash3
74 static constexpr std::size_t kNBytesPageChecksum = sizeof(std::uint64_t);
75
76 /// The interface of a task scheduler to schedule page (de)compression tasks
78 public:
79 virtual ~RTaskScheduler() = default;
80 /// Take a callable that represents a task
81 virtual void AddTask(const std::function<void(void)> &taskFunc) = 0;
82 /// Blocks until all scheduled tasks finished
83 virtual void Wait() = 0;
84 };
85
86 /// A sealed page contains the bytes of a page as written to storage (packed & compressed). It is used
87 /// as an input to UnsealPages() as well as to transfer pages between different storage media.
88 /// RSealedPage does _not_ own the buffer it is pointing to in order to not interfere with the memory management
89 /// of concrete page sink and page source implementations.
90 struct RSealedPage {
91 private:
92 const void *fBuffer = nullptr;
93 std::size_t fBufferSize = 0; ///< Size of the page payload and the trailing checksum (if available)
94 std::uint32_t fNElements = 0;
95 bool fHasChecksum = false; ///< If set, the last 8 bytes of the buffer are the xxhash of the rest of the buffer
96
97 public:
98 RSealedPage() = default;
99 RSealedPage(const void *buffer, std::size_t bufferSize, std::uint32_t nElements, bool hasChecksum = false)
101 {
102 }
103 RSealedPage(const RSealedPage &other) = default;
107
108 const void *GetBuffer() const { return fBuffer; }
109 void SetBuffer(const void *buffer) { fBuffer = buffer; }
110
116 std::size_t GetBufferSize() const { return fBufferSize; }
117 void SetBufferSize(std::size_t bufferSize) { fBufferSize = bufferSize; }
118
119 std::uint32_t GetNElements() const { return fNElements; }
120 void SetNElements(std::uint32_t nElements) { fNElements = nElements; }
121
122 bool GetHasChecksum() const { return fHasChecksum; }
124
125 void ChecksumIfEnabled();
127 /// Returns a failure if the sealed page has no checksum
129 };
130
131 using SealedPageSequence_t = std::deque<RSealedPage>;
132 /// A range of sealed pages referring to the same column that can be used for vector commit
135 SealedPageSequence_t::const_iterator fFirst;
136 SealedPageSequence_t::const_iterator fLast;
137
138 RSealedPageGroup() = default;
139 RSealedPageGroup(ROOT::DescriptorId_t d, SealedPageSequence_t::const_iterator b,
140 SealedPageSequence_t::const_iterator e)
142 {
143 }
144 };
145
146protected:
148
149 /// For the time being, we will use the heap allocator for all sources and sinks. This may change in the future.
150 std::unique_ptr<ROOT::Internal::RPageAllocator> fPageAllocator;
151
152 std::string fNTupleName;
155 {
156 if (!fTaskScheduler)
157 return;
159 }
160
161public:
162 explicit RPageStorage(std::string_view name);
167 virtual ~RPageStorage();
168
169 /// Whether the concrete implementation is a sink or a source
171
175
176 /// Returns true for a valid column handle; fColumn and fPhysicalId should always either both
177 /// be valid or both be invalid.
178 explicit operator bool() const { return fPhysicalId != ROOT::kInvalidDescriptorId && fColumn; }
179 };
180 /// The column handle identifies a column with the current open page storage
182
183 /// Register a new column. When reading, the column must exist in the ntuple on disk corresponding to the metadata.
184 /// When writing, every column can only be attached once.
186 /// Unregisters a column. A page source decreases the reference counter for the corresponding active column.
187 /// For a page sink, dropping columns is currently a no-op.
190
191 /// Returns the default metrics object. Subclasses might alternatively provide their own metrics object by
192 /// overriding this.
194
195 /// Returns the NTuple name.
196 const std::string &GetNTupleName() const { return fNTupleName; }
197
199}; // class RPageStorage
200
201// clang-format off
202/**
203\class ROOT::Internal::RWritePageMemoryManager
204\ingroup NTuple
205\brief Helper to maintain a memory budget for the write pages of a set of columns
206
207The memory manager keeps track of the sum of bytes used by the write pages of a set of columns.
208It will flush (and shrink) large pages of other columns on the attempt to expand a page.
209*/
210// clang-format on
212private:
213 struct RColumnInfo {
215 std::size_t fCurrentPageSize = 0;
216 std::size_t fInitialPageSize = 0;
217
218 bool operator>(const RColumnInfo &other) const;
219 };
220
221 /// Sum of all the write page sizes (their capacity) of the columns in `fColumnsSortedByPageSize`
222 std::size_t fCurrentAllocatedBytes = 0;
223 /// Maximum allowed value for `fCurrentAllocatedBytes`, set from RNTupleWriteOptions::fPageBufferBudget
224 std::size_t fMaxAllocatedBytes = 0;
225 /// All columns that called `ReservePage()` (hence `TryUpdate()`) at least once,
226 /// sorted by their current write page size from large to small
227 std::set<RColumnInfo, std::greater<RColumnInfo>> fColumnsSortedByPageSize;
228
229 /// Flush columns in order of allocated write page size until the sum of all write page allocations
230 /// leaves space for at least targetAvailableSize bytes. Only use columns with a write page size larger
231 /// than pageSizeLimit.
232 bool TryEvict(std::size_t targetAvailableSize, std::size_t pageSizeLimit);
233
234public:
236
237 /// Try to register the new write page size for the given column. Flush large columns to make space, if necessary.
238 /// If not enough space is available after all (sum of write pages would be larger than fMaxAllocatedBytes),
239 /// return false.
240 bool TryUpdate(ROOT::Internal::RColumn &column, std::size_t newWritePageSize);
241};
242
243// clang-format off
244/**
245\class ROOT::Internal::RPageSink
246\ingroup NTuple
247\brief Abstract interface to write data into an ntuple
248
249The page sink takes the list of columns and afterwards a series of page commits and cluster commits.
250The user is responsible to commit clusters at a consistent point, i.e. when all pages corresponding to data
251up to the given entry number are committed.
252
253An object of this class may either be a wrapper (for example a RPageSinkBuf) or a "persistent" sink,
254inheriting from RPagePersistentSink.
255*/
256// clang-format on
257class RPageSink : public RPageStorage {
258public:
259 using Callback_t = std::function<void(RPageSink &)>;
260
261 /// Cluster that was staged, but not yet logically appended to the RNTuple
275
276protected:
277 std::unique_ptr<ROOT::RNTupleWriteOptions> fOptions;
278
279 /// Flag if sink was initialized
280 bool fIsInitialized = false;
281
282 /// Helper for streaming a page. This is commonly used in derived, concrete page sinks. Note that if
283 /// compressionSetting is 0 (uncompressed) and the page is mappable and not checksummed, the returned sealed page
284 /// will point directly to the input page buffer. Otherwise, the sealed page references fSealPageBuffer. Thus,
285 /// the buffer pointed to by the RSealedPage should never be freed.
287
288private:
289 std::vector<Callback_t> fOnDatasetCommitCallbacks;
290 std::vector<unsigned char> fSealPageBuffer; ///< Used as destination buffer in the simple SealPage overload
291
292 /// Used in ReservePage to maintain the page buffer budget
294
295public:
296 RPageSink(std::string_view ntupleName, const ROOT::RNTupleWriteOptions &options);
297
298 RPageSink(const RPageSink &) = delete;
299 RPageSink &operator=(const RPageSink &) = delete;
300 RPageSink(RPageSink &&) = default;
302 ~RPageSink() override;
303
305 /// Returns the sink's write options.
307
308 void DropColumn(ColumnHandle_t /*columnHandle*/) final {}
309
310 bool IsInitialized() const { return fIsInitialized; }
311
312 /// Return the RNTupleDescriptor being constructed.
313 virtual const ROOT::RNTupleDescriptor &GetDescriptor() const = 0;
314
315 virtual ROOT::NTupleSize_t GetNEntries() const = 0;
316
317 /// Physically creates the storage container to hold the ntuple (e.g., a keys a TFile or an S3 bucket)
318 /// Init() associates column handles to the columns referenced by the model
319 void Init(RNTupleModel &model)
320 {
321 if (fIsInitialized) {
322 throw RException(R__FAIL("already initialized"));
323 }
324 InitImpl(model);
325 fIsInitialized = true;
326 }
327
328protected:
329 virtual void InitImpl(RNTupleModel &model) = 0;
330 virtual void CommitDatasetImpl() = 0;
331
332public:
333 /// Parameters for the SealPage() method
335 const ROOT::Internal::RPage *fPage = nullptr; ///< Input page to be sealed
337 nullptr; ///< Corresponds to the page's elements, for size calculation etc.
338 std::uint32_t fCompressionSettings = 0; ///< Compression algorithm and level to apply
339 /// Adds a 8 byte little-endian xxhash3 checksum to the page payload. The buffer has to be large enough to
340 /// to store the additional 8 bytes.
341 bool fWriteChecksum = true;
342 /// If false, the output buffer must not point to the input page buffer, which would otherwise be an option
343 /// if the page is mappable and should not be compressed
344 bool fAllowAlias = false;
345 /// Location for sealed output. The memory buffer has to be large enough.
346 void *fBuffer = nullptr;
347 };
348
349 /// Seal a page using the provided info.
350 static RSealedPage SealPage(const RSealPageConfig &config);
351
352 /// Incorporate incremental changes to the model into the ntuple descriptor. This happens, e.g. if new fields were
353 /// added after the initial call to `RPageSink::Init(RNTupleModel &)`.
354 /// `firstEntry` specifies the global index for the first stored element in the added columns.
356 /// Adds an extra type information record to schema. The extra type information will be written to the
357 /// extension header. The information in the record will be merged with the existing information, e.g.
358 /// duplicate streamer info records will be removed. This method is called by the "on commit dataset" callback
359 /// registered by specific fields (e.g., streamer field) and during merging.
361
362 /// Commits a suppressed column for the current cluster. Can be called anytime before CommitCluster().
363 /// For any given column and cluster, there must be no calls to both CommitSuppressedColumn() and page commits.
365 /// Write a page to the storage. The column must have been added before.
367 /// Write a preprocessed page to storage. The column must have been added before.
368 virtual void
370 /// Write a vector of preprocessed pages to storage. The corresponding columns must have been added before.
371 virtual void CommitSealedPageV(std::span<RPageStorage::RSealedPageGroup> ranges) = 0;
372 /// Stage the current cluster and create a new one for the following data.
373 /// Returns the object that must be passed to CommitStagedClusters to logically append the staged cluster to the
374 /// ntuple descriptor.
376 /// Commit staged clusters, logically appending them to the ntuple descriptor.
377 virtual void CommitStagedClusters(std::span<RStagedCluster> clusters) = 0;
378 /// Finalize the current cluster and create a new one for the following data.
379 /// Returns the number of bytes written to storage (excluding metadata).
386 /// Write out the page locations (page list envelope) for all the committed clusters since the last call of
387 /// CommitClusterGroup (or the beginning of writing).
388 virtual void CommitClusterGroup() = 0;
389
390 /// The registered callback is executed at the beginning of CommitDataset();
392 /// Run the registered callbacks and finalize the current cluster and the entrire data set.
393 void CommitDataset();
394
395 /// Get a new, empty page for the given column that can be filled with up to nElements;
396 /// nElements must be larger than zero.
398
399 /// An RAII wrapper used to synchronize a page sink. See GetSinkGuard().
401 std::mutex *fLock;
402
403 public:
404 explicit RSinkGuard(std::mutex *lock) : fLock(lock)
405 {
406 if (fLock != nullptr) {
407 fLock->lock();
408 }
409 }
410 RSinkGuard(const RSinkGuard &) = delete;
411 RSinkGuard &operator=(const RSinkGuard &) = delete;
412 RSinkGuard(RSinkGuard &&) = delete;
415 {
416 if (fLock != nullptr) {
417 fLock->unlock();
418 }
419 }
420 };
421
423 {
424 // By default, there is no lock and the guard does nothing.
425 return RSinkGuard(nullptr);
426 }
427}; // class RPageSink
428
429// clang-format off
430/**
431\class ROOT::Internal::RPagePersistentSink
432\ingroup NTuple
433\brief Base class for a sink with a physical storage backend
434*/
435// clang-format on
437private:
438 /// Used to map the IDs of the descriptor to the physical IDs issued during header/footer serialization
440
441 /// Remembers the starting cluster id for the next cluster group
442 std::uint64_t fNextClusterInGroup = 0;
443 /// Used to calculate the number of entries in the current cluster
445 /// Keeps track of the number of elements in the currently open cluster. Indexed by column id.
446 std::vector<ROOT::RClusterDescriptor::RColumnRange> fOpenColumnRanges;
447 /// Keeps track of the written pages in the currently open cluster. Indexed by column id.
448 std::vector<ROOT::RClusterDescriptor::RPageRange> fOpenPageRanges;
449
450 /// Union of the streamer info records that are sent from streamer fields to the sink before committing the dataset.
452
453protected:
454 /// Set of optional features supported by the persistent sink
455 struct RFeatures {
456 bool fCanMergePages = false;
457 };
458
461
462 /// Default I/O performance counters that get registered in fMetrics
472 std::unique_ptr<RCounters> fCounters;
473
474 virtual void InitImpl(unsigned char *serializedHeader, std::uint32_t length) = 0;
475
477 virtual RNTupleLocator
479 /// Vector commit of preprocessed pages. The `ranges` array specifies a range of sealed pages to be
480 /// committed for each column. The returned vector contains, in order, the RNTupleLocator for each
481 /// page on each range in `ranges`, i.e. the first N entries refer to the N pages in `ranges[0]`,
482 /// followed by M entries that refer to the M pages in `ranges[1]`, etc.
483 /// The mask allows to skip writing out certain pages. The vector has the size of all the pages.
484 /// For every `false` value in the mask, the corresponding locator is skipped (missing) in the output vector.
485 /// The default is to call `CommitSealedPageImpl` for each page; derived classes may provide an
486 /// optimized implementation though.
487 virtual std::vector<RNTupleLocator>
488 CommitSealedPageVImpl(std::span<RPageStorage::RSealedPageGroup> ranges, const std::vector<bool> &mask);
489 /// Returns the number of bytes written to storage (excluding metadata)
490 virtual std::uint64_t StageClusterImpl() = 0;
491 /// Returns the locator of the page list envelope of the given buffer that contains the serialized page list.
492 /// Typically, the implementation takes care of compressing and writing the provided buffer.
493 virtual RNTupleLocator CommitClusterGroupImpl(unsigned char *serializedPageList, std::uint32_t length) = 0;
494 virtual void CommitDatasetImpl(unsigned char *serializedFooter, std::uint32_t length) = 0;
495
496 /// Enables the default set of metrics provided by RPageSink. `prefix` will be used as the prefix for
497 /// the counters registered in the internal RNTupleMetrics object.
498 /// This set of counters can be extended by a subclass by calling `fMetrics.MakeCounter<...>()`.
499 ///
500 /// A subclass using the default set of metrics is always responsible for updating the counters
501 /// appropriately, e.g. `fCounters->fNPageCommited.Inc()`
502 void EnableDefaultMetrics(const std::string &prefix);
503
504public:
505 RPagePersistentSink(std::string_view ntupleName, const ROOT::RNTupleWriteOptions &options);
506
511 ~RPagePersistentSink() override;
512
513 /// Guess the concrete derived page source from the location
514 static std::unique_ptr<RPageSink> Create(std::string_view ntupleName, std::string_view location,
516
518
520
522
523 /// Updates the descriptor and calls InitImpl() that handles the backend-specific details (file, DAOS, etc.)
524 void InitImpl(RNTupleModel &model) final;
527
528 /// Initialize sink based on an existing descriptor and fill into the descriptor builder, optionally copying over
529 /// the descriptor's clusters to this sink's descriptor.
530 /// \return The model created from the new sink's descriptor. This model should be kept alive
531 /// for at least as long as the sink.
532 [[nodiscard]] std::unique_ptr<RNTupleModel>
534
538 void CommitSealedPageV(std::span<RPageStorage::RSealedPageGroup> ranges) final;
539 RStagedCluster StageCluster(ROOT::NTupleSize_t nNewEntries) final;
540 void CommitStagedClusters(std::span<RStagedCluster> clusters) final;
543}; // class RPagePersistentSink
544
545// clang-format off
546/**
547\class ROOT::Internal::RPageSource
548\ingroup NTuple
549\brief Abstract interface to read data from an ntuple
550
551The page source is initialized with the columns of interest. Alias columns from projected fields are mapped to the
552corresponding physical columns. Pages from the columns of interest can then be mapped into memory.
553The page source also gives access to the ntuple's metadata.
554*/
555// clang-format on
557public:
558 /// Used in SetEntryRange / GetEntryRange
559 struct REntryRange {
561 ROOT::NTupleSize_t fNEntries = 0;
562
563 /// Returns true if the given cluster has entries within the entry range
564 bool IntersectsWith(const ROOT::RClusterDescriptor &clusterDesc) const;
565 };
566
567 /// An RAII wrapper used for the read-only access to `RPageSource::fDescriptor`. See `GetExclDescriptorGuard()``.
570 std::shared_mutex &fLock;
571
572 public:
573 RSharedDescriptorGuard(const ROOT::RNTupleDescriptor &desc, std::shared_mutex &lock)
574 : fDescriptor(desc), fLock(lock)
575 {
576 fLock.lock_shared();
577 }
582 ~RSharedDescriptorGuard() { fLock.unlock_shared(); }
583 const ROOT::RNTupleDescriptor *operator->() const { return &fDescriptor; }
584 const ROOT::RNTupleDescriptor &GetRef() const { return fDescriptor; }
585 };
586
587 /// An RAII wrapper used for the writable access to `RPageSource::fDescriptor`. See `GetSharedDescriptorGuard()`.
590 std::shared_mutex &fLock;
591
592 public:
593 RExclDescriptorGuard(ROOT::RNTupleDescriptor &desc, std::shared_mutex &lock) : fDescriptor(desc), fLock(lock)
594 {
595 fLock.lock();
596 }
602 {
603 fDescriptor.IncGeneration();
604 fLock.unlock();
605 }
606 ROOT::RNTupleDescriptor *operator->() const { return &fDescriptor; }
607 void MoveIn(ROOT::RNTupleDescriptor desc) { fDescriptor = std::move(desc); }
608 };
609
610private:
612 mutable std::shared_mutex fDescriptorLock;
613 REntryRange fEntryRange; ///< Used by the cluster pool to prevent reading beyond the given range
614 bool fHasStructure = false; ///< Set to true once `LoadStructure()` is called
615 bool fIsAttached = false; ///< Set to true once `Attach()` is called
616 bool fHasStreamerInfosRegistered = false; ///< Set to true when RegisterStreamerInfos() is called.
617
618 /// Remembers the last cluster id from which a page was requested
620 /// Clusters from where pages got preloaded in UnzipClusterImpl(), ordered by first entry number
621 /// of the clusters. If the last used cluster changes in LoadPage(), all unused pages from
622 /// previous clusters are evicted from the page pool. Pinned clusters won't be evicted.
623 std::map<ROOT::NTupleSize_t, ROOT::DescriptorId_t> fPreloadedClusters;
624
625 /// Does nothing if fLastUsedCluster == clusterId. Otherwise, updated fLastUsedCluster
626 /// and evict unused paged from the page pool of all previous clusters.
627 /// Must not be called when the descriptor guard is taken.
628 void UpdateLastUsedCluster(ROOT::DescriptorId_t clusterId);
629
630protected:
631 /// Default I/O performance counters that get registered in `fMetrics`
651
652 /// Keeps track of the requested physical column IDs and their in-memory target type via a column element identifier.
653 /// When using alias columns (projected fields), physical columns may be requested multiple times.
655 public:
660
661 private:
662 /// Maps physical column IDs to all the requested in-memory representations.
663 /// A pair of physical column ID and in-memory representation can be requested multiple times, which is
664 /// indicated by the reference counter.
665 /// We can only have a handful of possible in-memory representations for a given column,
666 /// so it is fine to search them linearly.
667 std::unordered_map<ROOT::DescriptorId_t, std::vector<RColumnInfo>> fColumnInfos;
668
669 public:
672 ROOT::Internal::RCluster::ColumnSet_t ToColumnSet() const;
674 {
675 return fColumnInfos.count(physicalColumnId) > 0;
676 }
677 const std::vector<RColumnInfo> &GetColumnInfos(ROOT::DescriptorId_t physicalColumnId) const
678 {
679 return fColumnInfos.at(physicalColumnId);
680 }
681 };
682
683 /// Summarizes cluster-level information that are necessary to load a certain page.
684 /// Used by LoadPageImpl().
686 ROOT::DescriptorId_t fClusterId = 0;
687 /// Location of the page on disk
689 /// The first element number of the page's column in the given cluster
690 std::uint64_t fColumnOffset = 0;
691 };
692
693 std::unique_ptr<RCounters> fCounters;
694
696 /// The active columns are implicitly defined by the model fields or views
698 /// Pinned clusters and their $2 * (cluster bunch size) - 1$ successors will not be evicted from the cluster pool.
699 /// Pages of pinned clusters won't be evicted from the page pool.
700 std::unordered_set<ROOT::DescriptorId_t> fPinnedClusters;
701
702 /// The cluster pool asynchronously preloads the next few clusters. Note that derived classes should call
703 /// fClusterPool.StopBackgroundThread() in their destructor so that the I/O background thread does not call
704 /// methods from the destructed derived class.
706 /// Pages that are unzipped with IMT are staged into the page pool
708
709 virtual void LoadStructureImpl() = 0;
710 /// `LoadStructureImpl()` has been called before `AttachImpl()` is called
712 /// Returns a new, unattached page source for the same data set
713 virtual std::unique_ptr<RPageSource> CloneImpl() const = 0;
714 // Only called if a task scheduler is set. No-op be default.
715 virtual void UnzipClusterImpl(ROOT::Internal::RCluster *cluster);
716 // Returns a page from storage if not found in the page pool. Should be able to handle zero page locators.
719
720 /// Prepare a page range read for the column set in `clusterKey`. Specifically, pages referencing the
721 /// `kTypePageZero` locator are filled in `pageZeroMap`; otherwise, `perPageFunc` is called for each page. This is
722 /// commonly used as part of `LoadClusters()` in derived classes.
723 void PrepareLoadCluster(
727
728 /// Enables the default set of metrics provided by RPageSource. `prefix` will be used as the prefix for
729 /// the counters registered in the internal RNTupleMetrics object.
730 /// A subclass using the default set of metrics is responsible for updating the counters
731 /// appropriately, e.g. `fCounters->fNRead.Inc()`
732 /// Alternatively, a subclass might provide its own RNTupleMetrics object by overriding the
733 /// `GetMetrics()` member function.
734 void EnableDefaultMetrics(const std::string &prefix);
735
736 /// Note that the underlying lock is not recursive. See `GetSharedDescriptorGuard()` for further information.
737 RExclDescriptorGuard GetExclDescriptorGuard() { return RExclDescriptorGuard(fDescriptor, fDescriptorLock); }
738
739public:
741 RPageSource(const RPageSource &) = delete;
745 ~RPageSource() override;
746 /// Guess the concrete derived page source from the file name (location)
747 static std::unique_ptr<RPageSource> Create(std::string_view ntupleName, std::string_view location,
749 /// Open the same storage multiple time, e.g. for reading in multiple threads.
750 /// If the source is already attached, the clone will be attached, too. The clone will use, however,
751 /// it's own connection to the underlying storage (e.g., file descriptor, XRootD handle, etc.)
752 std::unique_ptr<RPageSource> Clone() const;
753
754 /// Helper for unstreaming a page. This is commonly used in derived, concrete page sources. The implementation
755 /// currently always makes a memory copy, even if the sealed page is uncompressed and in the final memory layout.
756 /// The optimization of directly mapping pages is left to the concrete page source implementations.
760
763
764 /// Takes the read lock for the descriptor. Multiple threads can take the lock concurrently.
765 /// The underlying `std::shared_mutex`, however, is neither read nor write recursive:
766 /// within one thread, only one lock (shared or exclusive) must be acquired at the same time. This requires special
767 /// care in sections protected by `GetSharedDescriptorGuard()` and `GetExclDescriptorGuard()` especially to avoid
768 /// that the locks are acquired indirectly. As a general guideline, no other
769 /// method of the page source should be called (directly or indirectly) in a guarded section.
771 {
772 return RSharedDescriptorGuard(fDescriptor, fDescriptorLock);
773 }
774
777
778 /// Loads header and footer without decompressing or deserializing them. This can be used to asynchronously open
779 /// a file in the background. The method is idempotent and it is called as a first step in `Attach()`.
780 /// Pages sources may or may not make use of splitting loading and processing metadata.
781 /// Therefore, `LoadStructure()` may do nothing and defer loading the metadata to `Attach()`.
782 void LoadStructure();
783 /// Open the physical storage container and deserialize header and footer
788
789 /// Promise to only read from the given entry range. If set, prevents the cluster pool from reading-ahead beyond
790 /// the given range. The range needs to be within `[0, GetNEntries())`.
791 void SetEntryRange(const REntryRange &range);
792 REntryRange GetEntryRange() const { return fEntryRange; }
793
794 /// Allocates and fills a page that contains the index-th element. The default implementation searches
795 /// the page and calls LoadPageImpl(). Returns a default-constructed RPage for suppressed columns.
797 /// Another version of `LoadPage` that allows to specify cluster-relative indexes.
798 /// Returns a default-constructed RPage for suppressed columns.
800
801 /// Read the packed and compressed bytes of a page into the memory buffer provided by `sealedPage`. The sealed page
802 /// can be used subsequently in a call to `RPageSink::CommitSealedPage`.
803 /// The `fSize` and `fNElements` member of the sealedPage parameters are always set. If `sealedPage.fBuffer` is
804 /// `nullptr`, no data will be copied but the returned size information can be used by the caller to allocate a large
805 /// enough buffer and call `LoadSealedPage` again.
806 virtual void
808
809 /// Populates all the pages of the given cluster ids and columns; it is possible that some columns do not
810 /// contain any pages. The page source may load more columns than the minimal necessary set from `columns`.
811 /// To indicate which columns have been loaded, `LoadClusters()`` must mark them with `SetColumnAvailable()`.
812 /// That includes the ones from the `columns` that don't have pages; otherwise subsequent requests
813 /// for the cluster would assume an incomplete cluster and trigger loading again.
814 /// `LoadClusters()` is typically called from the I/O thread of a cluster pool, i.e. the method runs
815 /// concurrently to other methods of the page source.
816 virtual std::vector<std::unique_ptr<ROOT::Internal::RCluster>>
817 LoadClusters(std::span<ROOT::Internal::RCluster::RKey> clusterKeys) = 0;
818
819 /// Parallel decompression and unpacking of the pages in the given cluster. The unzipped pages are supposed
820 /// to be preloaded in a page pool attached to the source. The method is triggered by the cluster pool's
821 /// unzip thread. It is an optional optimization, the method can safely do nothing. In particular, the
822 /// actual implementation will only run if a task scheduler is set. In practice, a task scheduler is set
823 /// if implicit multi-threading is turned on.
824 void UnzipCluster(ROOT::Internal::RCluster *cluster);
825
826 /// Instructs the cluster pool and page pool to consider the given cluster as active (should stay cached).
827 void PinCluster(ROOT::DescriptorId_t clusterId) { fPinnedClusters.insert(clusterId); }
828 /// Allows the given cluster to be evicted from the cluster pool and page pool.
829 void UnpinCluster(ROOT::DescriptorId_t clusterId) { fPinnedClusters.erase(clusterId); }
830 const std::unordered_set<ROOT::DescriptorId_t> &GetPinnedClusters() const { return fPinnedClusters; }
831
832 // TODO(gparolini): for symmetry with SealPage(), we should either make this private or SealPage() public.
834 UnsealPage(const RSealedPage &sealedPage, const ROOT::Internal::RColumnElementBase &element);
835
836 /// Builds the streamer info records from the descriptor's extra type info section. This is necessary when
837 /// connecting streamer fields so that emulated classes can be read.
838 void RegisterStreamerInfos();
839
840 /// Forces the loading of ROOT StreamerInfo from the underlying file. This currently only has an effect for
841 /// TFile-backed sources.
842 virtual void LoadStreamerInfo() = 0;
843}; // class RPageSource
844
845} // namespace Internal
846} // namespace ROOT
847
848#endif
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Definition RError.hxx:300
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
#define e(i)
Definition RSha256.hxx:103
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 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
char name[80]
Definition TGX11.cxx:110
A thread-safe integral performance counter.
A metric element that computes its floating point value from other counters.
A collection of Counter objects with a name, a unit, and a description.
Managed a set of clusters containing compressed and packed pages.
An in-memory subset of the packed and compressed pages of a cluster.
Definition RCluster.hxx:148
std::unordered_set< ROOT::DescriptorId_t > ColumnSet_t
Definition RCluster.hxx:150
A column element encapsulates the translation between basic C++ types and their column representation...
A column is a storage-backed array of a simple, fixed-size type, from which pages can be mapped into ...
Definition RColumn.hxx:38
A helper class for piece-wise construction of an RNTupleDescriptor.
const RNTupleDescriptor & GetDescriptor() const
The serialization context is used for the piecewise serialization of a descriptor.
std::map< Int_t, TVirtualStreamerInfo * > StreamerInfoMap_t
@ kForReading
Deserializes the descriptor and performs fixup on the suppressed column ranges and on clusters,...
A memory region that contains packed and compressed pages.
Definition RCluster.hxx:99
Abstract interface to allocate and release pages.
Base class for a sink with a physical storage backend.
RStagedCluster StageCluster(ROOT::NTupleSize_t nNewEntries) final
Stage the current cluster and create a new one for the following data.
void UpdateSchema(const ROOT::Internal::RNTupleModelChangeset &changeset, ROOT::NTupleSize_t firstEntry) override
Incorporate incremental changes to the model into the ntuple descriptor.
void CommitSealedPage(ROOT::DescriptorId_t physicalColumnId, const RPageStorage::RSealedPage &sealedPage) final
Write a preprocessed page to storage. The column must have been added before.
RPagePersistentSink(RPagePersistentSink &&)=default
std::uint64_t fNextClusterInGroup
Remembers the starting cluster id for the next cluster group.
std::unique_ptr< RNTupleModel > InitFromDescriptor(const ROOT::RNTupleDescriptor &descriptor, bool copyClusters)
Initialize sink based on an existing descriptor and fill into the descriptor builder,...
void UpdateExtraTypeInfo(const ROOT::RExtraTypeInfoDescriptor &extraTypeInfo) final
Adds an extra type information record to schema.
ColumnHandle_t AddColumn(ROOT::DescriptorId_t fieldId, ROOT::Internal::RColumn &column) final
Register a new column.
ROOT::Internal::RNTupleDescriptorBuilder fDescriptorBuilder
RPagePersistentSink & operator=(RPagePersistentSink &&)=default
virtual std::vector< RNTupleLocator > CommitSealedPageVImpl(std::span< RPageStorage::RSealedPageGroup > ranges, const std::vector< bool > &mask)
Vector commit of preprocessed pages.
RPagePersistentSink(std::string_view ntupleName, const ROOT::RNTupleWriteOptions &options)
RPagePersistentSink & operator=(const RPagePersistentSink &)=delete
ROOT::NTupleSize_t GetNEntries() const final
RPagePersistentSink(const RPagePersistentSink &)=delete
void CommitSuppressedColumn(ColumnHandle_t columnHandle) final
Commits a suppressed column for the current cluster.
ROOT::Internal::RNTupleSerializer::RContext fSerializationContext
Used to map the IDs of the descriptor to the physical IDs issued during header/footer serialization.
ROOT::NTupleSize_t fPrevClusterNEntries
Used to calculate the number of entries in the current cluster.
virtual RNTupleLocator CommitClusterGroupImpl(unsigned char *serializedPageList, std::uint32_t length)=0
Returns the locator of the page list envelope of the given buffer that contains the serialized page l...
void CommitStagedClusters(std::span< RStagedCluster > clusters) final
Commit staged clusters, logically appending them to the ntuple descriptor.
static std::unique_ptr< RPageSink > Create(std::string_view ntupleName, std::string_view location, const ROOT::RNTupleWriteOptions &options=ROOT::RNTupleWriteOptions())
Guess the concrete derived page source from the location.
std::vector< ROOT::RClusterDescriptor::RPageRange > fOpenPageRanges
Keeps track of the written pages in the currently open cluster. Indexed by column id.
void CommitPage(ColumnHandle_t columnHandle, const ROOT::Internal::RPage &page) final
Write a page to the storage. The column must have been added before.
virtual void InitImpl(unsigned char *serializedHeader, std::uint32_t length)=0
const ROOT::RNTupleDescriptor & GetDescriptor() const final
Return the RNTupleDescriptor being constructed.
virtual void CommitDatasetImpl(unsigned char *serializedFooter, std::uint32_t length)=0
std::vector< ROOT::RClusterDescriptor::RColumnRange > fOpenColumnRanges
Keeps track of the number of elements in the currently open cluster. Indexed by column id.
std::unique_ptr< RCounters > fCounters
void CommitClusterGroup() final
Write out the page locations (page list envelope) for all the committed clusters since the last call ...
virtual RNTupleLocator CommitSealedPageImpl(ROOT::DescriptorId_t physicalColumnId, const RPageStorage::RSealedPage &sealedPage)=0
void CommitSealedPageV(std::span< RPageStorage::RSealedPageGroup > ranges) final
Write a vector of preprocessed pages to storage. The corresponding columns must have been added befor...
void EnableDefaultMetrics(const std::string &prefix)
Enables the default set of metrics provided by RPageSink.
ROOT::Internal::RNTupleSerializer::StreamerInfoMap_t fInfosOfStreamerFields
Union of the streamer info records that are sent from streamer fields to the sink before committing t...
virtual RNTupleLocator CommitPageImpl(ColumnHandle_t columnHandle, const ROOT::Internal::RPage &page)=0
virtual std::uint64_t StageClusterImpl()=0
Returns the number of bytes written to storage (excluding metadata)
A thread-safe cache of pages loaded from the page source.
Definition RPagePool.hxx:47
Reference to a page stored in the page pool.
An RAII wrapper used to synchronize a page sink. See GetSinkGuard().
RSinkGuard & operator=(const RSinkGuard &)=delete
RSinkGuard & operator=(RSinkGuard &&)=delete
RSinkGuard(const RSinkGuard &)=delete
Abstract interface to write data into an ntuple.
RPageSink(RPageSink &&)=default
virtual void CommitSealedPage(ROOT::DescriptorId_t physicalColumnId, const RPageStorage::RSealedPage &sealedPage)=0
Write a preprocessed page to storage. The column must have been added before.
std::vector< unsigned char > fSealPageBuffer
Used as destination buffer in the simple SealPage overload.
virtual void CommitSuppressedColumn(ColumnHandle_t columnHandle)=0
Commits a suppressed column for the current cluster.
std::unique_ptr< ROOT::RNTupleWriteOptions > fOptions
void RegisterOnCommitDatasetCallback(Callback_t callback)
The registered callback is executed at the beginning of CommitDataset();.
std::vector< Callback_t > fOnDatasetCommitCallbacks
virtual ROOT::Internal::RPage ReservePage(ColumnHandle_t columnHandle, std::size_t nElements)
Get a new, empty page for the given column that can be filled with up to nElements; nElements must be...
const ROOT::RNTupleWriteOptions & GetWriteOptions() const
Returns the sink's write options.
virtual void CommitClusterGroup()=0
Write out the page locations (page list envelope) for all the committed clusters since the last call ...
virtual RStagedCluster StageCluster(ROOT::NTupleSize_t nNewEntries)=0
Stage the current cluster and create a new one for the following data.
virtual void CommitPage(ColumnHandle_t columnHandle, const ROOT::Internal::RPage &page)=0
Write a page to the storage. The column must have been added before.
RPageSink & operator=(const RPageSink &)=delete
EPageStorageType GetType() final
Whether the concrete implementation is a sink or a source.
void Init(RNTupleModel &model)
Physically creates the storage container to hold the ntuple (e.g., a keys a TFile or an S3 bucket) In...
virtual void UpdateExtraTypeInfo(const ROOT::RExtraTypeInfoDescriptor &extraTypeInfo)=0
Adds an extra type information record to schema.
RPageSink(const RPageSink &)=delete
virtual void CommitStagedClusters(std::span< RStagedCluster > clusters)=0
Commit staged clusters, logically appending them to the ntuple descriptor.
virtual std::uint64_t CommitCluster(ROOT::NTupleSize_t nNewEntries)
Finalize the current cluster and create a new one for the following data.
virtual void InitImpl(RNTupleModel &model)=0
virtual RSinkGuard GetSinkGuard()
std::function< void(RPageSink &)> Callback_t
virtual void UpdateSchema(const ROOT::Internal::RNTupleModelChangeset &changeset, ROOT::NTupleSize_t firstEntry)=0
Incorporate incremental changes to the model into the ntuple descriptor.
RSealedPage SealPage(const ROOT::Internal::RPage &page, const ROOT::Internal::RColumnElementBase &element)
Helper for streaming a page.
bool fIsInitialized
Flag if sink was initialized.
RPageSink(std::string_view ntupleName, const ROOT::RNTupleWriteOptions &options)
RPageSink & operator=(RPageSink &&)=default
virtual const ROOT::RNTupleDescriptor & GetDescriptor() const =0
Return the RNTupleDescriptor being constructed.
virtual void CommitSealedPageV(std::span< RPageStorage::RSealedPageGroup > ranges)=0
Write a vector of preprocessed pages to storage. The corresponding columns must have been added befor...
virtual ROOT::NTupleSize_t GetNEntries() const =0
void CommitDataset()
Run the registered callbacks and finalize the current cluster and the entrire data set.
RWritePageMemoryManager fWritePageMemoryManager
Used in ReservePage to maintain the page buffer budget.
virtual void CommitDatasetImpl()=0
void DropColumn(ColumnHandle_t) final
Unregisters a column.
Keeps track of the requested physical column IDs and their in-memory target type via a column element...
const std::vector< RColumnInfo > & GetColumnInfos(ROOT::DescriptorId_t physicalColumnId) const
std::unordered_map< ROOT::DescriptorId_t, std::vector< RColumnInfo > > fColumnInfos
Maps physical column IDs to all the requested in-memory representations.
bool HasColumnInfos(ROOT::DescriptorId_t physicalColumnId) const
An RAII wrapper used for the writable access to RPageSource::fDescriptor. See GetSharedDescriptorGuar...
void MoveIn(ROOT::RNTupleDescriptor desc)
RExclDescriptorGuard & operator=(const RExclDescriptorGuard &)=delete
ROOT::RNTupleDescriptor * operator->() const
RExclDescriptorGuard(RExclDescriptorGuard &&)=delete
RExclDescriptorGuard(ROOT::RNTupleDescriptor &desc, std::shared_mutex &lock)
RExclDescriptorGuard(const RExclDescriptorGuard &)=delete
RExclDescriptorGuard & operator=(RExclDescriptorGuard &&)=delete
An RAII wrapper used for the read-only access to RPageSource::fDescriptor. See GetExclDescriptorGuard...
RSharedDescriptorGuard(const RSharedDescriptorGuard &)=delete
RSharedDescriptorGuard(RSharedDescriptorGuard &&)=delete
const ROOT::RNTupleDescriptor & GetRef() const
RSharedDescriptorGuard & operator=(const RSharedDescriptorGuard &)=delete
const ROOT::RNTupleDescriptor * operator->() const
RSharedDescriptorGuard(const ROOT::RNTupleDescriptor &desc, std::shared_mutex &lock)
RSharedDescriptorGuard & operator=(RSharedDescriptorGuard &&)=delete
Abstract interface to read data from an ntuple.
ROOT::Internal::RClusterPool fClusterPool
The cluster pool asynchronously preloads the next few clusters.
const std::unordered_set< ROOT::DescriptorId_t > & GetPinnedClusters() const
RPageSource & operator=(RPageSource &&)=delete
EPageStorageType GetType() final
Whether the concrete implementation is a sink or a source.
RPageSource & operator=(const RPageSource &)=delete
RExclDescriptorGuard GetExclDescriptorGuard()
Note that the underlying lock is not recursive. See GetSharedDescriptorGuard() for further informatio...
ROOT::RNTupleReadOptions fOptions
REntryRange GetEntryRange() const
const RSharedDescriptorGuard GetSharedDescriptorGuard() const
Takes the read lock for the descriptor.
std::map< ROOT::NTupleSize_t, ROOT::DescriptorId_t > fPreloadedClusters
Clusters from where pages got preloaded in UnzipClusterImpl(), ordered by first entry number of the c...
REntryRange fEntryRange
Used by the cluster pool to prevent reading beyond the given range.
virtual ROOT::Internal::RPageRef LoadPageImpl(ColumnHandle_t columnHandle, const RClusterInfo &clusterInfo, ROOT::NTupleSize_t idxInCluster)=0
virtual std::unique_ptr< RPageSource > CloneImpl() const =0
Returns a new, unattached page source for the same data set.
void UnpinCluster(ROOT::DescriptorId_t clusterId)
Allows the given cluster to be evicted from the cluster pool and page pool.
std::unique_ptr< RCounters > fCounters
std::unordered_set< ROOT::DescriptorId_t > fPinnedClusters
Pinned clusters and their $2 * (cluster bunch size) - 1$ successors will not be evicted from the clus...
virtual void LoadStructureImpl()=0
ROOT::RNTupleDescriptor fDescriptor
void PinCluster(ROOT::DescriptorId_t clusterId)
Instructs the cluster pool and page pool to consider the given cluster as active (should stay cached)...
ROOT::Internal::RPagePool fPagePool
Pages that are unzipped with IMT are staged into the page pool.
virtual ROOT::RNTupleDescriptor AttachImpl(ROOT::Internal::RNTupleSerializer::EDescriptorDeserializeMode mode)=0
LoadStructureImpl() has been called before AttachImpl() is called
std::shared_mutex fDescriptorLock
virtual std::vector< std::unique_ptr< ROOT::Internal::RCluster > > LoadClusters(std::span< ROOT::Internal::RCluster::RKey > clusterKeys)=0
Populates all the pages of the given cluster ids and columns; it is possible that some columns do not...
RPageSource(RPageSource &&)=delete
virtual void LoadStreamerInfo()=0
Forces the loading of ROOT StreamerInfo from the underlying file.
RPageSource(const RPageSource &)=delete
const ROOT::RNTupleReadOptions & GetReadOptions() const
RActivePhysicalColumns fActivePhysicalColumns
The active columns are implicitly defined by the model fields or views.
virtual void LoadSealedPage(ROOT::DescriptorId_t physicalColumnId, RNTupleLocalIndex localIndex, RSealedPage &sealedPage)=0
Read the packed and compressed bytes of a page into the memory buffer provided by sealedPage.
The interface of a task scheduler to schedule page (de)compression tasks.
virtual void Wait()=0
Blocks until all scheduled tasks finished.
virtual void AddTask(const std::function< void(void)> &taskFunc)=0
Take a callable that represents a task.
Common functionality of an ntuple storage for both reading and writing.
virtual ColumnHandle_t AddColumn(ROOT::DescriptorId_t fieldId, ROOT::Internal::RColumn &column)=0
Register a new column.
void SetTaskScheduler(RTaskScheduler *taskScheduler)
RPageStorage(const RPageStorage &other)=delete
virtual ROOT::Experimental::Detail::RNTupleMetrics & GetMetrics()
Returns the default metrics object.
RPageStorage & operator=(const RPageStorage &other)=delete
ROOT::DescriptorId_t GetColumnId(ColumnHandle_t columnHandle) const
virtual void DropColumn(ColumnHandle_t columnHandle)=0
Unregisters a column.
RPageStorage & operator=(RPageStorage &&other)=default
std::unique_ptr< ROOT::Internal::RPageAllocator > fPageAllocator
For the time being, we will use the heap allocator for all sources and sinks. This may change in the ...
static constexpr std::size_t kNBytesPageChecksum
The page checksum is a 64bit xxhash3.
std::deque< RSealedPage > SealedPageSequence_t
virtual EPageStorageType GetType()=0
Whether the concrete implementation is a sink or a source.
RColumnHandle ColumnHandle_t
The column handle identifies a column with the current open page storage.
RPageStorage(RPageStorage &&other)=default
ROOT::Experimental::Detail::RNTupleMetrics fMetrics
RPageStorage(std::string_view name)
const std::string & GetNTupleName() const
Returns the NTuple name.
A page is a slice of a column that is mapped into memory.
Definition RPage.hxx:44
Helper to maintain a memory budget for the write pages of a set of columns.
std::size_t fCurrentAllocatedBytes
Sum of all the write page sizes (their capacity) of the columns in fColumnsSortedByPageSize
std::size_t fMaxAllocatedBytes
Maximum allowed value for fCurrentAllocatedBytes, set from RNTupleWriteOptions::fPageBufferBudget.
bool TryEvict(std::size_t targetAvailableSize, std::size_t pageSizeLimit)
Flush columns in order of allocated write page size until the sum of all write page allocations leave...
bool TryUpdate(ROOT::Internal::RColumn &column, std::size_t newWritePageSize)
Try to register the new write page size for the given column.
RWritePageMemoryManager(std::size_t maxAllocatedBytes)
std::set< RColumnInfo, std::greater< RColumnInfo > > fColumnsSortedByPageSize
All columns that called ReservePage() (hence TryUpdate()) at least once, sorted by their current writ...
Records the partition of data into pages for a particular column in a particular cluster.
Metadata for RNTuple clusters.
Base class for all ROOT issued exceptions.
Definition RError.hxx:79
Field specific extra type information from the header / extenstion header.
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.
The RNTupleModel encapulates the schema of an RNTuple.
Common user-tunable settings for reading RNTuples.
Common user-tunable settings for storing RNTuples.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
constexpr NTupleSize_t kInvalidNTupleIndex
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
constexpr DescriptorId_t kInvalidDescriptorId
The identifiers that specifies the content of a (partial) cluster.
Definition RCluster.hxx:152
Every concrete RColumnElement type is identified by its on-disk type (column type) and the in-memory ...
The incremental changes to a RNTupleModel
Default I/O performance counters that get registered in fMetrics.
ROOT::Experimental::Detail::RNTupleAtomicCounter & fSzWritePayload
ROOT::Experimental::Detail::RNTupleTickCounter< ROOT::Experimental::Detail::RNTupleAtomicCounter > & fTimeCpuWrite
ROOT::Experimental::Detail::RNTupleAtomicCounter & fTimeWallWrite
ROOT::Experimental::Detail::RNTupleTickCounter< ROOT::Experimental::Detail::RNTupleAtomicCounter > & fTimeCpuZip
ROOT::Experimental::Detail::RNTupleAtomicCounter & fTimeWallZip
ROOT::Experimental::Detail::RNTupleAtomicCounter & fSzZip
ROOT::Experimental::Detail::RNTupleAtomicCounter & fNPageCommitted
Set of optional features supported by the persistent sink.
Parameters for the SealPage() method.
bool fWriteChecksum
Adds a 8 byte little-endian xxhash3 checksum to the page payload.
std::uint32_t fCompressionSettings
Compression algorithm and level to apply.
void * fBuffer
Location for sealed output. The memory buffer has to be large enough.
const ROOT::Internal::RPage * fPage
Input page to be sealed.
bool fAllowAlias
If false, the output buffer must not point to the input page buffer, which would otherwise be an opti...
const ROOT::Internal::RColumnElementBase * fElement
Corresponds to the page's elements, for size calculation etc.
ROOT::RClusterDescriptor::RPageRange fPageRange
Cluster that was staged, but not yet logically appended to the RNTuple.
std::vector< RColumnInfo > fColumnInfos
ROOT::Internal::RColumnElementBase::RIdentifier fElementId
Summarizes cluster-level information that are necessary to load a certain page.
ROOT::RClusterDescriptor::RPageInfoExtended fPageInfo
Location of the page on disk.
Default I/O performance counters that get registered in fMetrics
ROOT::Experimental::Detail::RNTupleAtomicCounter & fNPageUnsealed
ROOT::Experimental::Detail::RNTupleAtomicCounter & fNRead
ROOT::Experimental::Detail::RNTupleAtomicCounter & fTimeWallRead
ROOT::Experimental::Detail::RNTupleAtomicCounter & fSzReadOverhead
ROOT::Experimental::Detail::RNTupleCalcPerf & fCompressionRatio
ROOT::Experimental::Detail::RNTupleCalcPerf & fFractionReadOverhead
ROOT::Experimental::Detail::RNTupleAtomicCounter & fNReadV
ROOT::Experimental::Detail::RNTupleAtomicCounter & fNClusterLoaded
ROOT::Experimental::Detail::RNTupleAtomicCounter & fTimeWallUnzip
ROOT::Experimental::Detail::RNTupleAtomicCounter & fNPageRead
ROOT::Experimental::Detail::RNTupleAtomicCounter & fSzReadPayload
ROOT::Experimental::Detail::RNTupleCalcPerf & fBandwidthReadCompressed
ROOT::Experimental::Detail::RNTupleTickCounter< ROOT::Experimental::Detail::RNTupleAtomicCounter > & fTimeCpuUnzip
ROOT::Experimental::Detail::RNTupleTickCounter< ROOT::Experimental::Detail::RNTupleAtomicCounter > & fTimeCpuRead
ROOT::Experimental::Detail::RNTupleCalcPerf & fBandwidthReadUncompressed
ROOT::Experimental::Detail::RNTupleCalcPerf & fBandwidthUnzip
ROOT::Experimental::Detail::RNTupleAtomicCounter & fSzUnzip
Used in SetEntryRange / GetEntryRange.
A range of sealed pages referring to the same column that can be used for vector commit.
SealedPageSequence_t::const_iterator fFirst
SealedPageSequence_t::const_iterator fLast
RSealedPageGroup(ROOT::DescriptorId_t d, SealedPageSequence_t::const_iterator b, SealedPageSequence_t::const_iterator e)
A sealed page contains the bytes of a page as written to storage (packed & compressed).
RSealedPage(const void *buffer, std::size_t bufferSize, std::uint32_t nElements, bool hasChecksum=false)
RResult< void > VerifyChecksumIfEnabled() const
RSealedPage(const RSealedPage &other)=default
bool fHasChecksum
If set, the last 8 bytes of the buffer are the xxhash of the rest of the buffer.
RSealedPage & operator=(RSealedPage &&other)=default
void SetNElements(std::uint32_t nElements)
RSealedPage(RSealedPage &&other)=default
RResult< std::uint64_t > GetChecksum() const
Returns a failure if the sealed page has no checksum.
RSealedPage & operator=(const RSealedPage &other)=default
void SetBufferSize(std::size_t bufferSize)
std::size_t fBufferSize
Size of the page payload and the trailing checksum (if available)
bool operator>(const RColumnInfo &other) const
Additional information about a page in an in-memory RPageRange.
Information about a single page in the context of a cluster's page range.