File indexing completed on 2025-01-18 10:10:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef ROOT7_RNTupleUtil
0017 #define ROOT7_RNTupleUtil
0018
0019 #include <cstdint>
0020
0021 #include <string>
0022 #include <variant>
0023
0024 #include <ROOT/RLogger.hxx>
0025
0026 namespace ROOT {
0027 namespace Experimental {
0028
0029 class RLogChannel;
0030
0031 RLogChannel &NTupleLog();
0032
0033
0034
0035
0036
0037
0038 enum ENTupleStructure {
0039 kLeaf,
0040 kCollection,
0041 kRecord,
0042 kVariant,
0043 kReference,
0044 kInvalid,
0045 };
0046
0047
0048 using NTupleSize_t = std::uint64_t;
0049 constexpr NTupleSize_t kInvalidNTupleIndex = std::uint64_t(-1);
0050
0051 struct RClusterSize {
0052 using ValueType = std::uint64_t;
0053
0054 RClusterSize() : fValue(0) {}
0055 explicit constexpr RClusterSize(ValueType value) : fValue(value) {}
0056 RClusterSize& operator =(const ValueType value) { fValue = value; return *this; }
0057 RClusterSize& operator +=(const ValueType value) { fValue += value; return *this; }
0058 RClusterSize operator++(int) { auto result = *this; fValue++; return result; }
0059 operator ValueType() const { return fValue; }
0060
0061 ValueType fValue;
0062 };
0063 using ClusterSize_t = RClusterSize;
0064 constexpr ClusterSize_t kInvalidClusterIndex(std::uint64_t(-1));
0065
0066 constexpr int kUnknownCompressionSettings = -1;
0067
0068
0069
0070 template <typename SizeT>
0071 struct RNTupleCardinality {
0072 static_assert(std::is_same_v<SizeT, std::uint32_t> || std::is_same_v<SizeT, std::uint64_t>,
0073 "RNTupleCardinality is only supported with std::uint32_t or std::uint64_t template parameters");
0074
0075 using ValueType = SizeT;
0076
0077 RNTupleCardinality() : fValue(0) {}
0078 explicit constexpr RNTupleCardinality(ValueType value) : fValue(value) {}
0079 RNTupleCardinality &operator=(const ValueType value)
0080 {
0081 fValue = value;
0082 return *this;
0083 }
0084 operator ValueType() const { return fValue; }
0085
0086 ValueType fValue;
0087 };
0088
0089
0090 class RColumnSwitch {
0091 private:
0092 ClusterSize_t fIndex;
0093 std::uint32_t fTag = 0;
0094
0095 public:
0096 RColumnSwitch() = default;
0097 RColumnSwitch(ClusterSize_t index, std::uint32_t tag) : fIndex(index), fTag(tag) { }
0098 ClusterSize_t GetIndex() const { return fIndex; }
0099 std::uint32_t GetTag() const { return fTag; }
0100 };
0101
0102
0103 using ColumnId_t = std::int64_t;
0104 constexpr ColumnId_t kInvalidColumnId = -1;
0105
0106
0107 using DescriptorId_t = std::uint64_t;
0108 constexpr DescriptorId_t kInvalidDescriptorId = std::uint64_t(-1);
0109
0110
0111 class RClusterIndex {
0112 private:
0113 DescriptorId_t fClusterId = kInvalidDescriptorId;
0114 ClusterSize_t::ValueType fIndex = kInvalidClusterIndex;
0115 public:
0116 RClusterIndex() = default;
0117 RClusterIndex(const RClusterIndex &other) = default;
0118 RClusterIndex &operator =(const RClusterIndex &other) = default;
0119 constexpr RClusterIndex(DescriptorId_t clusterId, ClusterSize_t::ValueType index)
0120 : fClusterId(clusterId), fIndex(index) {}
0121
0122 RClusterIndex operator+(ClusterSize_t::ValueType off) const { return RClusterIndex(fClusterId, fIndex + off); }
0123 RClusterIndex operator-(ClusterSize_t::ValueType off) const { return RClusterIndex(fClusterId, fIndex - off); }
0124 RClusterIndex operator++(int) { auto r = *this; fIndex++; return r; }
0125 RClusterIndex& operator++() { ++fIndex; return *this; }
0126 bool operator==(RClusterIndex other) const { return fClusterId == other.fClusterId && fIndex == other.fIndex; }
0127 bool operator!=(RClusterIndex other) const { return !(*this == other); }
0128
0129 DescriptorId_t GetClusterId() const { return fClusterId; }
0130 ClusterSize_t::ValueType GetIndex() const { return fIndex; }
0131 };
0132
0133
0134
0135
0136 struct RNTupleLocatorObject64 {
0137 std::uint64_t fLocation = 0;
0138 bool operator==(const RNTupleLocatorObject64 &other) const { return fLocation == other.fLocation; }
0139 };
0140
0141
0142
0143
0144
0145 struct RNTupleLocator {
0146
0147
0148 enum ELocatorType : std::uint8_t {
0149 kTypeFile = 0x00,
0150 kTypeURI = 0x01,
0151 kTypeDAOS = 0x02,
0152
0153 kLastSerializableType = 0x7f,
0154 kTypePageZero = kLastSerializableType + 1,
0155 };
0156
0157
0158
0159 std::variant<std::uint64_t, std::string, RNTupleLocatorObject64> fPosition;
0160 std::uint32_t fBytesOnStorage = 0;
0161
0162
0163 ELocatorType fType = kTypeFile;
0164
0165 std::uint8_t fReserved = 0;
0166
0167 bool operator==(const RNTupleLocator &other) const {
0168 return fPosition == other.fPosition && fBytesOnStorage == other.fBytesOnStorage && fType == other.fType;
0169 }
0170 template <typename T>
0171 const T &GetPosition() const
0172 {
0173 return std::get<T>(fPosition);
0174 }
0175 };
0176
0177 namespace Internal {
0178 template <typename T>
0179 auto MakeAliasedSharedPtr(T *rawPtr)
0180 {
0181 const static std::shared_ptr<T> fgRawPtrCtrlBlock;
0182 return std::shared_ptr<T>(fgRawPtrCtrlBlock, rawPtr);
0183 }
0184 }
0185
0186 }
0187 }
0188
0189 #endif