Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
RNTupleTypes.cxx
Go to the documentation of this file.
1/// \file RNTupleTypes.cxx
2/// \author Jakob Blomer <jblomer@cern.ch>
3/// \date 2026-02-00
4
5/*************************************************************************
6 * Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#include <ROOT/RError.hxx>
14#include <ROOT/RNTupleTypes.hxx>
15
16#include <TError.h>
17
18#include <string>
19
20/// See GetReserved(): we ignore the reserved flag since we don't use it anywhere currently.
21void ROOT::RNTupleLocator::SetReserved(std::uint8_t reserved)
22{
23 if (reserved > 1) {
24 throw RException(R__FAIL("Overflow of the locator reserved field"));
25 }
26
27 fFlagsAndNBytes = (fFlagsAndNBytes & ~kMaskReservedBit) | (std::uint64_t(reserved) << 60);
28}
29
30void ROOT::RNTupleLocator::SetNBytesOnStorage(std::uint64_t nBytesOnStorage)
31{
32 if (nBytesOnStorage & kMaskFlags) {
33 throw RException(R__FAIL("overflow in on-disk size of locator: " + std::to_string(nBytesOnStorage)));
34 }
35
36 fFlagsAndNBytes = (fFlagsAndNBytes & kMaskFlags) | nBytesOnStorage;
37}
38
40{
41 std::uint64_t compactType = fFlagsAndNBytes >> 61;
42 switch (compactType) {
43 case 0: return kTypeFile;
44 case 1: return kTypeDAOS;
45 case 2: return kTypePageZero;
46 case 3: return kTypeUnknown;
47 case 4: return Internal::kTestLocatorType;
48 default: break;
49 }
50 R__ASSERT(false);
51 return kTypeUnknown;
52}
53
55{
56 std::uint64_t compactType;
57 switch (type) {
58 case kTypeFile: compactType = 0; break;
59 case kTypeDAOS: compactType = 1; break;
60 case kTypePageZero: compactType = 2; break;
61 case kTypeUnknown: compactType = 3; break;
62 default:
64 compactType = 4;
65 else
66 throw RException(R__FAIL("invalid locator type: " + std::to_string(type)));
67 }
68
69 fFlagsAndNBytes = (fFlagsAndNBytes & ~kMaskType) | (compactType << 61);
70}
71
72void ROOT::RNTupleLocator::SetPosition(std::uint64_t position)
73{
74 if (GetType() != kTypeFile)
75 throw RException(R__FAIL("cannot set position as 64bit offset for type " + std::to_string(GetType())));
76 fPosition = position;
77}
78
80{
81 if (GetType() != kTypeDAOS)
82 throw RException(R__FAIL("cannot set position as 64bit object for type " + std::to_string(GetType())));
83 fPosition = position.GetLocation();
84}
85
87{
89 throw RException(R__FAIL("cannot retrieve position as 64bit offset for type " + std::to_string(loc.GetType())));
90 return loc.fPosition;
91}
92
95{
96 if (loc.GetType() != ROOT::RNTupleLocator::kTypeDAOS)
97 throw RException(R__FAIL("cannot retrieve position as 64bit object for type " + std::to_string(loc.GetType())));
98 return RNTupleLocatorObject64{loc.fPosition};
99}
#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:299
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
Base class for all ROOT issued exceptions.
Definition RError.hxx:78
RNTupleLocator payload that is common for object stores using 64bit location information.
std::uint64_t GetLocation() const
Generic information about the physical location of data.
std::uint64_t fPosition
Simple on-disk locators consisting of a 64-bit offset use variant type uint64_t; Object store locator...
ELocatorType
Values for the Type field in non-disk locators.
std::uint64_t fFlagsAndNBytes
To save memory, we use the most significant bits to store the locator type (file, DAOS,...
static constexpr std::uint64_t kMaskFlags
The 4 most significant bits of fFlagsAndNBytes carry the locator type (3 bits) plus one bit for a res...
ELocatorType GetType() const
For non-disk locators, the value for the Type field.
static constexpr std::uint64_t kMaskReservedBit
void SetType(ELocatorType type)
void SetPosition(std::uint64_t position)
static constexpr std::uint64_t kMaskType
void SetReserved(std::uint8_t reserved)
See GetReserved(): we ignore the reserved flag since we don't use it anywhere currently.
void SetNBytesOnStorage(std::uint64_t nBytesOnStorage)
constexpr RNTupleLocator::ELocatorType kTestLocatorType