|
|
|||
File indexing completed on 2026-10-03 09:25:24
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 \note This is the documentation for the RNTuple anchor class. For a generic introduction to RNTuple, see \ref NTuple "the RNTuple Introduction". For reading RNTuples, see RNTupleReader. For writing RNTuples, see RNTupleWriter. 0047 For exploring the contents of an RNTuple, use ROOT::RDataFrame. See \ref rosetta-stone for examples how to draw and scan the contents. 0048 0049 The class points to the header and footer keys, which in turn have the references to the pages (via page lists). 0050 Only the RNTuple key will be listed in the list of keys. Like TBaskets, the pages are "invisible" keys. 0051 Byte offset references in the RNTuple header and footer reference directly the data part of page records, 0052 skipping the TFile key part. 0053 0054 In the list of keys, this object appears as "ROOT::RNTuple". 0055 It is the user-facing representation of an RNTuple data set in a ROOT file and 0056 it provides an API entry point to an RNTuple stored in a ROOT file. Its main purpose is to 0057 construct a page source for an RNTuple, which in turn can be used to read an RNTuple with an RDF or 0058 an RNTupleReader. 0059 0060 For instance, for an RNTuple called "Events" in a ROOT file, usage can be 0061 ~~~ {.cpp} 0062 auto f = TFile::Open("data.root"); 0063 auto ntpl = f->Get<ROOT::RNTuple>("Events"); 0064 auto reader = RNTupleReader::Open(ntpl); 0065 ~~~ 0066 */ 0067 // clang-format on 0068 class RNTuple final { 0069 friend class Internal::RNTupleFileWriter; 0070 friend class Internal::RPageSourceFile; 0071 0072 friend ROOT::RNTuple 0073 Internal::CreateAnchor(std::uint16_t versionEpoch, std::uint16_t versionMajor, std::uint16_t versionMinor, 0074 std::uint16_t versionPatch, std::uint64_t seekHeader, std::uint64_t nbytesHeader, 0075 std::uint64_t lenHeader, std::uint64_t seekFooter, std::uint64_t nbytesFooter, 0076 std::uint64_t lenFooter, std::uint64_t maxKeySize); 0077 0078 public: 0079 static constexpr std::uint16_t kVersionEpoch = 1; 0080 static constexpr std::uint16_t kVersionMajor = 0; 0081 static constexpr std::uint16_t kVersionMinor = 2; 0082 static constexpr std::uint16_t kVersionPatch = 0; 0083 0084 /// Returns the RNTuple version in the following form: 0085 /// Epoch: 2 most significant bytes 0086 /// Major: next 2 bytes 0087 /// Minor: next 2 bytes 0088 /// Patch: 2 least significant bytes 0089 /// This integer can be compared with that of another RNTuple to determine which one has the highest overall version. 0090 static constexpr std::uint64_t GetCurrentVersion() 0091 { 0092 return (static_cast<std::uint64_t>(kVersionEpoch) << 48) | (static_cast<std::uint64_t>(kVersionMajor) << 32) | 0093 (static_cast<std::uint64_t>(kVersionMinor) << 16) | (static_cast<std::uint64_t>(kVersionPatch)); 0094 } 0095 0096 private: 0097 /// Version of the RNTuple binary format that the writer supports (see specification). 0098 /// Changing the epoch indicates backward-incompatible changes 0099 std::uint16_t fVersionEpoch = kVersionEpoch; 0100 /// Changing the major version indicates forward incompatible changes; such changes should correspond to a new 0101 /// bit in the feature flag of the RNTuple header. 0102 /// For the pre-release epoch 0, indicates the release candidate number 0103 std::uint16_t fVersionMajor = kVersionMajor; 0104 /// Changing the minor version indicates new optional fields added to the RNTuple metadata 0105 std::uint16_t fVersionMinor = kVersionMinor; 0106 /// Changing the patch version indicates clarifications or new backported features from newer binary format versions 0107 std::uint16_t fVersionPatch = kVersionPatch; 0108 /// The file offset of the header excluding the TKey part 0109 std::uint64_t fSeekHeader = 0; 0110 /// The size of the compressed ntuple header 0111 std::uint64_t fNBytesHeader = 0; 0112 /// The size of the uncompressed ntuple header 0113 std::uint64_t fLenHeader = 0; 0114 /// The file offset of the footer excluding the TKey part 0115 std::uint64_t fSeekFooter = 0; 0116 /// The size of the compressed ntuple footer 0117 std::uint64_t fNBytesFooter = 0; 0118 /// The size of the uncompressed ntuple footer 0119 std::uint64_t fLenFooter = 0; 0120 /// The maximum size for a TKey payload. Payloads bigger than this size will be written as multiple blobs. 0121 std::uint64_t fMaxKeySize = 0; 0122 0123 TFile *fFile = nullptr; ///<! The file from which the ntuple was streamed, registered in the custom streamer 0124 0125 public: 0126 RNTuple() = default; 0127 ~RNTuple() = default; 0128 0129 std::uint16_t GetVersionEpoch() const { return fVersionEpoch; } 0130 std::uint16_t GetVersionMajor() const { return fVersionMajor; } 0131 std::uint16_t GetVersionMinor() const { return fVersionMinor; } 0132 std::uint16_t GetVersionPatch() const { return fVersionPatch; } 0133 0134 std::uint64_t GetSeekHeader() const { return fSeekHeader; } 0135 std::uint64_t GetNBytesHeader() const { return fNBytesHeader; } 0136 std::uint64_t GetLenHeader() const { return fLenHeader; } 0137 0138 std::uint64_t GetSeekFooter() const { return fSeekFooter; } 0139 std::uint64_t GetNBytesFooter() const { return fNBytesFooter; } 0140 std::uint64_t GetLenFooter() const { return fLenFooter; } 0141 std::uint64_t GetMaxKeySize() const { return fMaxKeySize; } 0142 0143 /// RNTuple implements the hadd MergeFile interface 0144 /// Merge this NTuple with the input list entries 0145 Long64_t Merge(TCollection *input, TFileMergeInfo *mergeInfo); 0146 0147 /// NOTE: if you change this version you also need to update RTFNTuple::fClassVersion in RMiniFile.cxx 0148 ClassDefNV(RNTuple, 2); 0149 }; // class RNTuple 0150 0151 } // namespace ROOT 0152 0153 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|