Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 09:11:43

0001 /// \file ROOT/RNTuple.hxx
0002 /// \ingroup NTuple
0003 /// \author Jakob Blomer <jblomer@cern.ch>
0004 /// \date 2023-09-19
0005 
0006 /*************************************************************************
0007  * Copyright (C) 1995-2023, Rene Brun and Fons Rademakers.               *
0008  * All rights reserved.                                                  *
0009  *                                                                       *
0010  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0011  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0012  *************************************************************************/
0013 
0014 #ifndef ROOT_RNTuple
0015 #define ROOT_RNTuple
0016 
0017 #include <Rtypes.h>
0018 
0019 #include <cstdint>
0020 
0021 class TCollection;
0022 class TFile;
0023 class TFileMergeInfo;
0024 
0025 namespace ROOT {
0026 
0027 class RNTuple;
0028 
0029 namespace Internal {
0030 class RPageSourceFile;
0031 class RNTupleFileWriter;
0032 
0033 RNTuple CreateAnchor(std::uint16_t versionEpoch, std::uint16_t versionMajor, std::uint16_t versionMinor,
0034                      std::uint16_t versionPatch, std::uint64_t seekHeader, std::uint64_t nbytesHeader,
0035                      std::uint64_t lenHeader, std::uint64_t seekFooter, std::uint64_t nbytesFooter,
0036                      std::uint64_t lenFooter, std::uint64_t maxKeySize);
0037 
0038 } // namespace Internal
0039 
0040 // clang-format off
0041 /**
0042 \class ROOT::RNTuple
0043 \ingroup NTuple
0044 \brief Representation of an RNTuple data set in a ROOT file
0045 
0046 The class points to the header and footer keys, which in turn have the references to the pages (via page lists).
0047 Only the RNTuple key will be listed in the list of keys. Like TBaskets, the pages are "invisible" keys.
0048 Byte offset references in the RNTuple header and footer reference directly the data part of page records,
0049 skipping the TFile key part.
0050 
0051 In the list of keys, this object appears as "ROOT::RNTuple".
0052 It is the user-facing representation of an RNTuple data set in a ROOT file and
0053 it provides an API entry point to an RNTuple stored in a ROOT file. Its main purpose is to
0054 construct a page source for an RNTuple, which in turn can be used to read an RNTuple with an RDF or
0055 an RNTupleReader.
0056 
0057 For instance, for an RNTuple called "Events" in a ROOT file, usage can be
0058 ~~~ {.cpp}
0059 auto f = TFile::Open("data.root");
0060 auto ntpl = f->Get<ROOT::RNTuple>("Events");
0061 auto reader = RNTupleReader::Open(ntpl);
0062 ~~~
0063 */
0064 // clang-format on
0065 class RNTuple final {
0066    friend class Internal::RNTupleFileWriter;
0067    friend class Internal::RPageSourceFile;
0068 
0069    friend ROOT::RNTuple
0070    Internal::CreateAnchor(std::uint16_t versionEpoch, std::uint16_t versionMajor, std::uint16_t versionMinor,
0071                           std::uint16_t versionPatch, std::uint64_t seekHeader, std::uint64_t nbytesHeader,
0072                           std::uint64_t lenHeader, std::uint64_t seekFooter, std::uint64_t nbytesFooter,
0073                           std::uint64_t lenFooter, std::uint64_t maxKeySize);
0074 
0075 public:
0076    static constexpr std::uint16_t kVersionEpoch = 1;
0077    static constexpr std::uint16_t kVersionMajor = 0;
0078    static constexpr std::uint16_t kVersionMinor = 0;
0079    static constexpr std::uint16_t kVersionPatch = 1;
0080 
0081 private:
0082    /// Version of the RNTuple binary format that the writer supports (see specification).
0083    /// Changing the epoch indicates backward-incompatible changes
0084    std::uint16_t fVersionEpoch = kVersionEpoch;
0085    /// Changing the major version indicates forward incompatible changes; such changes should correspond to a new
0086    /// bit in the feature flag of the RNTuple header.
0087    /// For the pre-release epoch 0, indicates the release candidate number
0088    std::uint16_t fVersionMajor = kVersionMajor;
0089    /// Changing the minor version indicates new optional fields added to the RNTuple metadata
0090    std::uint16_t fVersionMinor = kVersionMinor;
0091    /// Changing the patch version indicates new backported features from newer binary format versions
0092    std::uint16_t fVersionPatch = kVersionPatch;
0093    /// The file offset of the header excluding the TKey part
0094    std::uint64_t fSeekHeader = 0;
0095    /// The size of the compressed ntuple header
0096    std::uint64_t fNBytesHeader = 0;
0097    /// The size of the uncompressed ntuple header
0098    std::uint64_t fLenHeader = 0;
0099    /// The file offset of the footer excluding the TKey part
0100    std::uint64_t fSeekFooter = 0;
0101    /// The size of the compressed ntuple footer
0102    std::uint64_t fNBytesFooter = 0;
0103    /// The size of the uncompressed ntuple footer
0104    std::uint64_t fLenFooter = 0;
0105    /// The maximum size for a TKey payload. Payloads bigger than this size will be written as multiple blobs.
0106    std::uint64_t fMaxKeySize = 0;
0107 
0108    TFile *fFile = nullptr; ///<! The file from which the ntuple was streamed, registered in the custom streamer
0109 
0110 public:
0111    RNTuple() = default;
0112    ~RNTuple() = default;
0113 
0114    std::uint16_t GetVersionEpoch() const { return fVersionEpoch; }
0115    std::uint16_t GetVersionMajor() const { return fVersionMajor; }
0116    std::uint16_t GetVersionMinor() const { return fVersionMinor; }
0117    std::uint16_t GetVersionPatch() const { return fVersionPatch; }
0118 
0119    std::uint64_t GetSeekHeader() const { return fSeekHeader; }
0120    std::uint64_t GetNBytesHeader() const { return fNBytesHeader; }
0121    std::uint64_t GetLenHeader() const { return fLenHeader; }
0122 
0123    std::uint64_t GetSeekFooter() const { return fSeekFooter; }
0124    std::uint64_t GetNBytesFooter() const { return fNBytesFooter; }
0125    std::uint64_t GetLenFooter() const { return fLenFooter; }
0126    std::uint64_t GetMaxKeySize() const { return fMaxKeySize; }
0127 
0128    /// RNTuple implements the hadd MergeFile interface
0129    /// Merge this NTuple with the input list entries
0130    Long64_t Merge(TCollection *input, TFileMergeInfo *mergeInfo);
0131 
0132    /// NOTE: if you change this version you also need to update RTFNTuple::fClassVersion in RMiniFile.cxx
0133    ClassDefNV(RNTuple, 2);
0134 }; // class RNTuple
0135 
0136 } // namespace ROOT
0137 
0138 #endif