Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:22:36

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