59namespace Experimental {
61class RCollectionField;
62class RNTupleCollectionWriter;
66struct RFieldCallbackInjector;
113 operator delete(objPtr);
118 template <
typename T>
123 std::destroy_at(
static_cast<T *
>(objPtr));
210 template <
typename T>
213 return std::static_pointer_cast<T>(
fObjPtr);
216 template <
typename T>
219 return *
static_cast<T *
>(
fObjPtr.get());
376 static const std::size_t
kAllSet = std::size_t(-1);
399 std::vector<std::unique_ptr<Internal::RColumn>>
fColumns;
430 virtual std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const = 0;
434 virtual std::unique_ptr<RDeleter>
GetDeleter()
const {
return std::make_unique<RDeleter>(); }
441 virtual std::size_t
AppendImpl(
const void *from);
491 virtual std::size_t
ReadBulkImpl(
const RBulkSpec &bulkSpec);
537 const std::string &typeAlias,
bool fContinueOnError =
false);
541 template <
bool IsConstT>
545 using FieldPtr_t = std::conditional_t<IsConstT, const RFieldBase *, RFieldBase *>;
557 using value_type = std::conditional_t<IsConstT, const RFieldBase, RFieldBase>;
558 using pointer = std::conditional_t<IsConstT, const RFieldBase *, RFieldBase *>;
559 using reference = std::conditional_t<IsConstT, const RFieldBase &, RFieldBase &>;
568 auto itr =
fStack.rbegin();
569 if (!itr->fFieldPtr->fSubFields.empty()) {
570 fStack.emplace_back(
Position(itr->fFieldPtr->fSubFields[0].get(), 0));
574 unsigned int nextIdxInParent = ++(itr->fIdxInParent);
575 while (nextIdxInParent >= itr->fFieldPtr->fParent->fSubFields.size()) {
577 itr->fFieldPtr = itr->fFieldPtr->fParent;
578 itr->fIdxInParent = -1;
583 nextIdxInParent = ++(itr->fIdxInParent);
585 itr->fFieldPtr = itr->fFieldPtr->fParent->fSubFields[nextIdxInParent].get();
599 template <
typename T>
615 std::size_t nRepetitions = 0);
623 std::unique_ptr<RFieldBase>
Clone(std::string_view newName)
const;
627 Create(
const std::string &fieldName,
const std::string &typeName);
630 static std::vector<RCheckResult>
Check(
const std::string &fieldName,
const std::string &typeName);
643 template <
typename T>
644 std::unique_ptr<T, typename RCreateObjectDeleter<T>::deleter>
CreateObject()
const;
718 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const override;
738 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
778 void operator()(
void *objPtr,
bool dtorOnly)
final;
787 RClassField(std::string_view fieldName, std::string_view className,
TClass *classp);
794 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final;
799 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RClassDeleter>(
fClass); }
801 std::size_t
AppendImpl(
const void *from)
final;
807 RClassField(std::string_view fieldName, std::string_view className);
816 void AcceptVisitor(Detail::RFieldVisitor &visitor) const override;
822 REnumField(std::string_view fieldName, std::string_view enumName,
TEnum *enump);
823 REnumField(std::string_view fieldName, std::string_view enumName, std::unique_ptr<RFieldBase> intField);
826 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final;
837 REnumField(std::string_view fieldName, std::string_view enumName);
873 void *fIterator =
nullptr;
874 void *fElementPtr =
nullptr;
878 auto fnNext_Contig = [&]() {
881 auto &iter =
reinterpret_cast<unsigned char *&
>(fIterator),
p = iter;
910 void *fBegin = &fBeginSmallBuf;
911 void *fEnd = &fEndSmallBuf;
917 std::size_t stride = 0U)
918 : fIFuncs(ifuncs), fStride(stride)
930 std::shared_ptr<TVirtualCollectionProxy>
fProxy;
932 std::size_t fItemSize = 0;
939 : fProxy(proxy), fItemDeleter(std::move(itemDeleter)), fItemSize(itemSize)
941 fIFuncsWrite = RCollectionIterableOnce::GetIteratorFuncs(fProxy.get(),
false );
943 void operator()(
void *objPtr,
bool dtorOnly)
final;
947 std::shared_ptr<TVirtualCollectionProxy>
fProxy;
962 std::unique_ptr<RFieldBase> itemField);
965 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const override;
967 void GenerateColumnsImpl() final;
970 void ConstructValue(
void *where) const override;
971 std::unique_ptr<
RDeleter> GetDeleter() const override;
973 std::
size_t AppendImpl(const
void *from) override;
974 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) override;
976 void CommitClusterImpl() final { fNWritten = 0; }
984 std::vector<RValue> SplitValue(
const RValue &
value)
const override;
986 size_t GetAlignment()
const override {
return alignof(std::max_align_t); }
990 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
994 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
1008 RRecordDeleter(std::vector<std::unique_ptr<RDeleter>> &itemDeleters,
const std::vector<std::size_t> &offsets)
1009 : fItemDeleters(std::move(itemDeleters)), fOffsets(offsets)
1012 void operator()(
void *objPtr,
bool dtorOnly)
final;
1016 std::size_t fMaxAlignment = 1;
1020 std::size_t GetItemPadding(std::size_t baseOffset, std::size_t itemAlignment)
const;
1022 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const override;
1027 void ConstructValue(
void *where)
const override;
1028 std::unique_ptr<RDeleter> GetDeleter()
const override;
1030 std::size_t AppendImpl(
const void *from)
final;
1031 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
1032 void ReadInClusterImpl(
RClusterIndex clusterIndex,
void *to)
final;
1034 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &&itemFields,
1035 const std::vector<std::size_t> &offsets, std::string_view typeName =
"");
1037 template <std::
size_t N>
1038 RRecordField(std::string_view fieldName, std::array<std::unique_ptr<RFieldBase>,
N> &&itemFields,
1039 const std::array<std::size_t, N> &offsets, std::string_view typeName =
"")
1042 fTraits |= kTraitTrivialType;
1043 for (
unsigned i = 0; i <
N; ++i) {
1044 fOffsets.push_back(offsets[i]);
1045 fMaxAlignment = std::max(fMaxAlignment, itemFields[i]->GetAlignment());
1046 fSize += GetItemPadding(
fSize, itemFields[i]->GetAlignment()) + itemFields[i]->GetValueSize();
1047 fTraits &= itemFields[i]->GetTraits();
1048 Attach(std::move(itemFields[i]));
1054 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &&itemFields);
1055 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &itemFields);
1060 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1071 std::size_t fItemSize = 0;
1077 : fItemSize(itemSize), fItemDeleter(std::move(itemDeleter))
1080 void operator()(
void *objPtr,
bool dtorOnly)
final;
1088 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1091 void GenerateColumnsImpl() final;
1094 void ConstructValue(
void *where)
const override {
new (where) std::vector<char>(); }
1095 std::unique_ptr<RDeleter> GetDeleter() const final;
1097 std::
size_t AppendImpl(const
void *from) final;
1098 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1100 void CommitClusterImpl() final { fNWritten = 0; }
1103 RVectorField(std::string_view fieldName, std::unique_ptr<RFieldBase> itemField);
1108 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1110 size_t GetAlignment() const final {
return std::alignment_of<std::vector<char>>(); }
1113 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
1117 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
1128 std::size_t fItemSize = 0;
1132 explicit RRVecDeleter(std::size_t itemAlignment) : fItemAlignment(itemAlignment) {}
1133 RRVecDeleter(std::size_t itemAlignment, std::size_t itemSize, std::unique_ptr<RDeleter> itemDeleter)
1134 : fItemAlignment(itemAlignment), fItemSize(itemSize), fItemDeleter(std::move(itemDeleter))
1137 void operator()(
void *objPtr,
bool dtorOnly)
final;
1147 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const override;
1149 void GenerateColumnsImpl() final;
1152 void ConstructValue(
void *where) const override;
1153 std::unique_ptr<
RDeleter> GetDeleter() const override;
1155 std::
size_t AppendImpl(const
void *from) override;
1156 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) override;
1157 std::
size_t ReadBulkImpl(const
RBulkSpec &bulkSpec) final;
1159 void CommitClusterImpl() final { fNWritten = 0; }
1162 RRVecField(std::string_view fieldName, std::unique_ptr<RFieldBase> itemField);
1169 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1170 size_t GetValueSize()
const override;
1171 size_t GetAlignment()
const override;
1175 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
1179 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
1188 std::size_t fItemSize = 0;
1189 std::size_t fArrayLength = 0;
1193 RArrayDeleter(std::size_t itemSize, std::size_t arrayLength, std::unique_ptr<RDeleter> itemDeleter)
1194 : fItemSize(itemSize), fArrayLength(arrayLength), fItemDeleter(std::move(itemDeleter))
1197 void operator()(
void *objPtr,
bool dtorOnly)
final;
1204 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1209 void ConstructValue(
void *where)
const override;
1210 std::unique_ptr<RDeleter> GetDeleter() const final;
1212 std::
size_t AppendImpl(const
void *from) final;
1213 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1214 void ReadInClusterImpl(
RClusterIndex clusterIndex,
void *to) final;
1217 RArrayField(std::string_view fieldName, std::unique_ptr<
RFieldBase> itemField, std::
size_t arrayLength);
1223 size_t GetLength()
const {
return fArrayLength; }
1225 size_t GetAlignment() const final {
return fSubFields[0]->GetAlignment(); }
1244 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1249 void ConstructValue(
void *where)
const final;
1251 std::unique_ptr<RDeleter> GetDeleter() const final;
1253 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1254 void ReadInClusterImpl(
RClusterIndex clusterIndex,
void *to) final;
1270 std::size_t GetAlignment() const final;
1273 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
1281 static constexpr std::size_t kWordSize =
sizeof(
Word_t);
1282 static constexpr std::size_t kBitsPerWord = kWordSize * 8;
1288 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
1290 return std::make_unique<RBitsetField>(newName, fN);
1292 const RColumnRepresentations &GetColumnRepresentations() const final;
1293 void GenerateColumnsImpl() final;
1295 void ConstructValue(
void *where) const final { memset(where, 0, GetValueSize()); }
1296 std::size_t AppendImpl(
const void *from)
final;
1297 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
1305 size_t GetValueSize() const final {
return kWordSize * ((fN + kBitsPerWord - 1) / kBitsPerWord); }
1310 std::size_t
GetN()
const {
return fN; }
1322 RVariantDeleter(std::size_t tagOffset, std::vector<std::unique_ptr<RDeleter>> &itemDeleters)
1323 : fTagOffset(tagOffset), fItemDeleters(std::move(itemDeleters))
1326 void operator()(
void *objPtr,
bool dtorOnly)
final;
1329 size_t fMaxItemSize = 0;
1330 size_t fMaxAlignment = 1;
1332 size_t fTagOffset = 0;
1335 static std::string GetTypeList(
const std::vector<RFieldBase *> &itemFields);
1337 static std::uint32_t GetTag(
const void *variantPtr, std::size_t tagOffset);
1338 static void SetTag(
void *variantPtr, std::size_t tagOffset, std::uint32_t tag);
1341 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1344 void GenerateColumnsImpl() final;
1347 void ConstructValue(
void *where) const override;
1348 std::unique_ptr<
RDeleter> GetDeleter() const final;
1350 std::
size_t AppendImpl(const
void *from) final;
1351 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1353 void CommitClusterImpl() final;
1362 size_t GetValueSize() const final;
1363 size_t GetAlignment() const final {
return fMaxAlignment; }
1369 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1372 RSetField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
1377 size_t GetAlignment()
const override {
return std::alignment_of<std::set<std::max_align_t>>(); }
1386 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1388 std::size_t AppendImpl(
const void *from)
final;
1389 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
1392 RMapField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
1397 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1399 size_t GetAlignment()
const override {
return std::alignment_of<std::map<std::max_align_t, std::max_align_t>>(); }
1418 void GenerateColumnsImpl() final;
1421 std::
size_t AppendNull();
1422 std::
size_t AppendValue(const
void *from);
1423 void CommitClusterImpl() final { fNWritten = 0; }
1429 RNullableField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
1436 bool IsDense()
const {
return GetColumnRepresentative()[0] == EColumnType::kBit; }
1438 void SetDense() { SetColumnRepresentative({EColumnType::kBit}); }
1439 void SetSparse() { SetColumnRepresentative({EColumnType::kSplitIndex32}); }
1450 explicit RUniquePtrDeleter(std::unique_ptr<RDeleter> itemDeleter) : fItemDeleter(std::move(itemDeleter)) {}
1451 void operator()(
void *objPtr,
bool dtorOnly)
final;
1457 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1459 void ConstructValue(
void *where)
const final {
new (where) std::unique_ptr<char>(); }
1460 std::unique_ptr<RDeleter> GetDeleter() const final;
1462 std::
size_t AppendImpl(const
void *from) final;
1463 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1472 size_t GetValueSize() const final {
return sizeof(std::unique_ptr<char>); }
1473 size_t GetAlignment() const final {
return alignof(std::unique_ptr<char>); }
1478 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1482 void ConstructValue(
void *where)
const final { CallConstructValueOn(*fSubFields[0], where); }
1483 std::unique_ptr<RDeleter>
GetDeleter() const final {
return GetDeleterOf(*fSubFields[0]); }
1485 std::size_t
AppendImpl(
const void *from)
final {
return CallAppendOn(*fSubFields[0], from); }
1490 RAtomicField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
1495 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1497 size_t GetValueSize() const final {
return fSubFields[0]->GetValueSize(); }
1498 size_t GetAlignment() const final {
return fSubFields[0]->GetAlignment(); }
1504template <
typename T,
typename =
void>
1509 if constexpr (std::is_default_constructible_v<T>) {
1513 new (where) T(
static_cast<TRootIOCtor *
>(
nullptr));
1520 static_assert(std::is_class_v<T>,
"no I/O support for this basic C++ type");
1527template <
typename T>
1537template <
typename T,
typename =
void>
1540template <
typename T>
1542 T, typename std::enable_if<std::is_same<typename T::IsCollectionProxy, std::true_type>::value>
::type>
1583template <
typename T,
typename =
void>
1601template <
typename T>
1604 void ConstructValue(
void *where)
const final {
new (where) T(); }
1608 RField(std::string_view
name) : RProxiedCollectionField(
name, TypeName())
1610 static_assert(std::is_class<T>::value,
"collection proxy unsupported for fundamental types");
1624 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1626 void GenerateColumnsImpl() final;
1628 void ConstructValue(
void *) const final {}
1630 std::size_t AppendImpl(
const void *from)
final;
1631 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
1633 void CommitClusterImpl() final;
1636 static std::
string TypeName() {
return ""; }
1637 RCollectionField(std::string_view
name, std::shared_ptr<RNTupleCollectionWriter> collectionWriter,
1638 std::unique_ptr<RFieldZero> collectionParent);
1656 void operator()(
void *objPtr,
bool dtorOnly)
final;
1660 static std::string
GetTypeList(
const std::array<std::unique_ptr<RFieldBase>, 2> &itemFields);
1663 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const override;
1665 void ConstructValue(
void *where)
const override;
1666 std::unique_ptr<RDeleter>
GetDeleter()
const override {
return std::make_unique<RPairDeleter>(
fClass); }
1668 RPairField(std::string_view fieldName, std::array<std::unique_ptr<RFieldBase>, 2> &&itemFields,
1669 const std::array<std::size_t, 2> &offsets);
1672 RPairField(std::string_view fieldName, std::array<std::unique_ptr<RFieldBase>, 2> &itemFields);
1687 void operator()(
void *objPtr,
bool dtorOnly)
final;
1691 static std::string
GetTypeList(
const std::vector<std::unique_ptr<RFieldBase>> &itemFields);
1694 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const override;
1696 void ConstructValue(
void *where)
const override;
1697 std::unique_ptr<RDeleter>
GetDeleter()
const override {
return std::make_unique<RTupleDeleter>(
fClass); }
1699 RTupleField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &&itemFields,
1700 const std::vector<std::size_t> &offsets);
1703 RTupleField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &itemFields);
1721 const RColumnRepresentations &GetColumnRepresentations() const final;
1723 void GenerateColumnsImpl() final {
throw RException(
R__FAIL(
"Cardinality fields must only be used for reading")); }
1754 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
1756 return std::make_unique<RField>(newName);
1760 void GenerateColumnsImpl() final;
1765 static std::string
TypeName() {
return "ROOT::Experimental::ClusterSize_t"; }
1768 fTraits |= kTraitTrivialType;
1779 return fPrincipalColumn->MapV<
ClusterSize_t>(globalIndex, nItems);
1783 return fPrincipalColumn->MapV<
ClusterSize_t>(clusterIndex, nItems);
1791 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
1795 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
1800template <
typename SizeT>
1803 std::unique_ptr<ROOT::Experimental::RFieldBase>
CloneImpl(std::string_view newName)
const final
1805 return std::make_unique<RField<RNTupleCardinality<SizeT>>>(newName);
1824 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &
size);
1833 fPrincipalColumn->GetCollectionInfo(clusterIndex, &collectionStart, &
size);
1841 fPrincipalColumn->GetCollectionInfo(bulkSpec.fFirstIndex, &collectionStart, &collectionSize);
1844 typedValues[0] = collectionSize;
1846 auto lastOffset = collectionStart.
GetIndex() + collectionSize;
1848 std::size_t nEntries = 1;
1849 while (nRemainingEntries > 0) {
1851 auto offsets = fPrincipalColumn->MapV<
ClusterSize_t>(bulkSpec.fFirstIndex + nEntries, nItemsUntilPageEnd);
1852 std::size_t nBatch = std::min(nRemainingEntries, nItemsUntilPageEnd);
1853 for (std::size_t i = 0; i < nBatch; ++i) {
1854 typedValues[nEntries + i] = offsets[i] - lastOffset;
1855 lastOffset = offsets[i];
1857 nRemainingEntries -= nBatch;
1860 return RBulkSpec::kAllSet;
1867 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
1869 return std::make_unique<RField>(newName);
1872 const RColumnRepresentations &GetColumnRepresentations() const final;
1873 void GenerateColumnsImpl() final;
1875 void ConstructValue(
void *where) const final {
new (where)
bool(
false); }
1881 fTraits |= kTraitTrivialType;
1888 return fPrincipalColumn->Map<
bool>(globalIndex);
1892 return fPrincipalColumn->MapV<
bool>(globalIndex, nItems);
1896 return fPrincipalColumn->MapV<
bool>(clusterIndex, nItems);
1907 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
1909 return std::make_unique<RField>(newName);
1912 const RColumnRepresentations &GetColumnRepresentations() const final;
1913 void GenerateColumnsImpl() final;
1915 void ConstructValue(
void *where) const final {
new (where)
float(0.0); }
1921 fTraits |= kTraitTrivialType;
1928 return fPrincipalColumn->Map<
float>(globalIndex);
1932 return fPrincipalColumn->MapV<
float>(globalIndex, nItems);
1936 return fPrincipalColumn->MapV<
float>(clusterIndex, nItems);
1943 void SetHalfPrecision();
1949 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
1951 return std::make_unique<RField>(newName);
1954 const RColumnRepresentations &GetColumnRepresentations() const final;
1955 void GenerateColumnsImpl() final;
1957 void ConstructValue(
void *where) const final {
new (where)
double(0.0); }
1963 fTraits |= kTraitTrivialType;
1970 return fPrincipalColumn->Map<
double>(globalIndex);
1972 double *
Map(
RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<
double>(clusterIndex); }
1974 return fPrincipalColumn->MapV<
double>(globalIndex, nItems);
1978 return fPrincipalColumn->MapV<
double>(clusterIndex, nItems);
1990class RField<std::
byte> final :
public RFieldBase {
1992 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
1994 return std::make_unique<RField>(newName);
1997 const RColumnRepresentations &GetColumnRepresentations() const final;
1998 void GenerateColumnsImpl() final;
1999 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2000 void ConstructValue(
void *where) const final {
new (where) std::byte{0}; }
2003 static std::string TypeName() {
return "std::byte"; }
2006 fTraits |= kTraitTrivialType;
2012 std::byte *
Map(NTupleSize_t globalIndex) {
return fPrincipalColumn->Map<std::byte>(globalIndex); }
2013 std::byte *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::byte>(clusterIndex); }
2014 std::byte *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
2016 return fPrincipalColumn->MapV<std::byte>(globalIndex, nItems);
2018 std::byte *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2020 return fPrincipalColumn->MapV<std::byte>(clusterIndex, nItems);
2023 size_t GetValueSize() const final {
return sizeof(std::byte); }
2024 size_t GetAlignment() const final {
return alignof(std::byte); }
2025 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2031 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
2033 return std::make_unique<RField>(newName);
2036 const RColumnRepresentations &GetColumnRepresentations() const final;
2037 void GenerateColumnsImpl() final;
2039 void ConstructValue(
void *where) const final {
new (where)
char(0); }
2045 fTraits |= kTraitTrivialType;
2052 return fPrincipalColumn->Map<
char>(globalIndex);
2056 return fPrincipalColumn->MapV<
char>(globalIndex, nItems);
2060 return fPrincipalColumn->MapV<
char>(clusterIndex, nItems);
2069class RField<std::int8_t> final :
public RFieldBase {
2071 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2073 return std::make_unique<RField>(newName);
2076 const RColumnRepresentations &GetColumnRepresentations() const final;
2077 void GenerateColumnsImpl() final;
2078 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2079 void ConstructValue(
void *where) const final {
new (where) int8_t(0); }
2082 static std::string TypeName() {
return "std::int8_t"; }
2085 fTraits |= kTraitTrivialType;
2091 std::int8_t *
Map(NTupleSize_t globalIndex) {
2092 return fPrincipalColumn->Map<std::int8_t>(globalIndex);
2094 std::int8_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::int8_t>(clusterIndex); }
2095 std::int8_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2096 return fPrincipalColumn->MapV<std::int8_t>(globalIndex, nItems);
2098 std::int8_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2100 return fPrincipalColumn->MapV<std::int8_t>(clusterIndex, nItems);
2103 size_t GetValueSize() const final {
return sizeof(std::int8_t); }
2104 size_t GetAlignment() const final {
return alignof(std::int8_t); }
2105 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2109class RField<std::uint8_t> final :
public RFieldBase {
2111 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2113 return std::make_unique<RField>(newName);
2116 const RColumnRepresentations &GetColumnRepresentations() const final;
2117 void GenerateColumnsImpl() final;
2118 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2119 void ConstructValue(
void *where) const final {
new (where) uint8_t(0); }
2122 static std::string TypeName() {
return "std::uint8_t"; }
2125 fTraits |= kTraitTrivialType;
2131 std::uint8_t *
Map(NTupleSize_t globalIndex) {
2132 return fPrincipalColumn->Map<std::uint8_t>(globalIndex);
2134 std::uint8_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::uint8_t>(clusterIndex); }
2135 std::uint8_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2136 return fPrincipalColumn->MapV<std::uint8_t>(globalIndex, nItems);
2138 std::uint8_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2140 return fPrincipalColumn->MapV<std::uint8_t>(clusterIndex, nItems);
2143 size_t GetValueSize() const final {
return sizeof(std::uint8_t); }
2144 size_t GetAlignment() const final {
return alignof(std::uint8_t); }
2145 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2149class RField<std::int16_t> final :
public RFieldBase {
2151 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2153 return std::make_unique<RField>(newName);
2156 const RColumnRepresentations &GetColumnRepresentations() const final;
2157 void GenerateColumnsImpl() final;
2158 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2159 void ConstructValue(
void *where) const final {
new (where) int16_t(0); }
2162 static std::string TypeName() {
return "std::int16_t"; }
2165 fTraits |= kTraitTrivialType;
2171 std::int16_t *
Map(NTupleSize_t globalIndex) {
2172 return fPrincipalColumn->Map<std::int16_t>(globalIndex);
2174 std::int16_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::int16_t>(clusterIndex); }
2175 std::int16_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2176 return fPrincipalColumn->MapV<std::int16_t>(globalIndex, nItems);
2178 std::int16_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2180 return fPrincipalColumn->MapV<std::int16_t>(clusterIndex, nItems);
2183 size_t GetValueSize() const final {
return sizeof(std::int16_t); }
2184 size_t GetAlignment() const final {
return alignof(std::int16_t); }
2185 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2189class RField<std::uint16_t> final :
public RFieldBase {
2191 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2193 return std::make_unique<RField>(newName);
2196 const RColumnRepresentations &GetColumnRepresentations() const final;
2197 void GenerateColumnsImpl() final;
2198 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2199 void ConstructValue(
void *where) const final {
new (where) int16_t(0); }
2202 static std::string TypeName() {
return "std::uint16_t"; }
2205 fTraits |= kTraitTrivialType;
2211 std::uint16_t *
Map(NTupleSize_t globalIndex) {
2212 return fPrincipalColumn->Map<std::uint16_t>(globalIndex);
2214 std::uint16_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::uint16_t>(clusterIndex); }
2215 std::uint16_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2216 return fPrincipalColumn->MapV<std::uint16_t>(globalIndex, nItems);
2218 std::uint16_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2220 return fPrincipalColumn->MapV<std::uint16_t>(clusterIndex, nItems);
2223 size_t GetValueSize() const final {
return sizeof(std::uint16_t); }
2224 size_t GetAlignment() const final {
return alignof(std::uint16_t); }
2225 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2229class RField<std::int32_t> final :
public RFieldBase {
2231 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2233 return std::make_unique<RField>(newName);
2236 const RColumnRepresentations &GetColumnRepresentations() const final;
2237 void GenerateColumnsImpl() final;
2238 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2239 void ConstructValue(
void *where) const final {
new (where) int32_t(0); }
2242 static std::string TypeName() {
return "std::int32_t"; }
2245 fTraits |= kTraitTrivialType;
2251 std::int32_t *
Map(NTupleSize_t globalIndex) {
2252 return fPrincipalColumn->Map<std::int32_t>(globalIndex);
2254 std::int32_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::int32_t>(clusterIndex); }
2255 std::int32_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2256 return fPrincipalColumn->MapV<std::int32_t>(globalIndex, nItems);
2258 std::int32_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2260 return fPrincipalColumn->MapV<std::int32_t>(clusterIndex, nItems);
2263 size_t GetValueSize() const final {
return sizeof(std::int32_t); }
2264 size_t GetAlignment() const final {
return alignof(std::int32_t); }
2265 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2269class RField<std::uint32_t> final :
public RFieldBase {
2271 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2273 return std::make_unique<RField>(newName);
2276 const RColumnRepresentations &GetColumnRepresentations() const final;
2277 void GenerateColumnsImpl() final;
2278 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2279 void ConstructValue(
void *where) const final {
new (where) uint32_t(0); }
2282 static std::string TypeName() {
return "std::uint32_t"; }
2285 fTraits |= kTraitTrivialType;
2291 std::uint32_t *
Map(NTupleSize_t globalIndex) {
2292 return fPrincipalColumn->Map<std::uint32_t>(globalIndex);
2294 std::uint32_t *
Map(
const RClusterIndex clusterIndex) {
2295 return fPrincipalColumn->Map<std::uint32_t>(clusterIndex);
2297 std::uint32_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2298 return fPrincipalColumn->MapV<std::uint32_t>(globalIndex, nItems);
2300 std::uint32_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2302 return fPrincipalColumn->MapV<std::uint32_t>(clusterIndex, nItems);
2305 size_t GetValueSize() const final {
return sizeof(std::uint32_t); }
2306 size_t GetAlignment() const final {
return alignof(std::uint32_t); }
2307 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2311class RField<std::uint64_t> final :
public RFieldBase {
2313 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2315 return std::make_unique<RField>(newName);
2318 const RColumnRepresentations &GetColumnRepresentations() const final;
2319 void GenerateColumnsImpl() final;
2320 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2321 void ConstructValue(
void *where) const final {
new (where) uint64_t(0); }
2324 static std::string TypeName() {
return "std::uint64_t"; }
2327 fTraits |= kTraitTrivialType;
2333 std::uint64_t *
Map(NTupleSize_t globalIndex) {
2334 return fPrincipalColumn->Map<std::uint64_t>(globalIndex);
2336 std::uint64_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::uint64_t>(clusterIndex); }
2337 std::uint64_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2338 return fPrincipalColumn->MapV<std::uint64_t>(globalIndex, nItems);
2340 std::uint64_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2342 return fPrincipalColumn->MapV<std::uint64_t>(clusterIndex, nItems);
2345 size_t GetValueSize() const final {
return sizeof(std::uint64_t); }
2346 size_t GetAlignment() const final {
return alignof(std::uint64_t); }
2347 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2351class RField<std::int64_t> final :
public RFieldBase {
2353 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2355 return std::make_unique<RField>(newName);
2358 const RColumnRepresentations &GetColumnRepresentations() const final;
2359 void GenerateColumnsImpl() final;
2360 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2361 void ConstructValue(
void *where) const final {
new (where) int64_t(0); }
2364 static std::string TypeName() {
return "std::int64_t"; }
2367 fTraits |= kTraitTrivialType;
2373 std::int64_t *
Map(NTupleSize_t globalIndex) {
2374 return fPrincipalColumn->Map<std::int64_t>(globalIndex);
2376 std::int64_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::int64_t>(clusterIndex); }
2377 std::int64_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2378 return fPrincipalColumn->MapV<std::int64_t>(globalIndex, nItems);
2380 std::int64_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2382 return fPrincipalColumn->MapV<std::int64_t>(clusterIndex, nItems);
2385 size_t GetValueSize() const final {
return sizeof(std::int64_t); }
2386 size_t GetAlignment() const final {
return alignof(std::int64_t); }
2387 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2391class RField<std::string> final :
public RFieldBase {
2395 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2397 return std::make_unique<RField>(newName);
2400 const RColumnRepresentations &GetColumnRepresentations() const final;
2401 void GenerateColumnsImpl() final;
2402 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2404 void ConstructValue(
void *where) const final {
new (where) std::string(); }
2405 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<std::string>>(); }
2407 std::size_t AppendImpl(
const void *from)
final;
2410 void CommitClusterImpl() final { fIndex = 0; }
2413 static std::string TypeName() {
return "std::string"; }
2422 size_t GetValueSize() const final {
return sizeof(std::string); }
2423 size_t GetAlignment() const final {
return std::alignment_of<std::string>(); }
2424 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2427template <
typename ItemT, std::
size_t N>
2428class RField<std::array<ItemT, N>> :
public RArrayField {
2429 using ContainerT =
typename std::array<ItemT, N>;
2432 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2435 static std::string TypeName() {
2438 explicit RField(std::string_view
name) : RArrayField(
name, std::make_unique<
RField<ItemT>>(
"_0"),
N)
2445template <
typename ItemT, std::
size_t N>
2454template <
typename ItemT>
2456 using ContainerT =
typename std::set<ItemT>;
2459 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2460 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2465 explicit RField(std::string_view
name) : RSetField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
2470 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2471 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2474template <
typename ItemT>
2475class RField<std::unordered_set<ItemT>> final :
public RSetField {
2476 using ContainerT =
typename std::unordered_set<ItemT>;
2479 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2480 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2485 explicit RField(std::string_view
name) : RSetField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
2490 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2491 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2494template <
typename KeyT,
typename ValueT>
2495class RField<std::map<KeyT, ValueT>> final :
public RMapField {
2496 using ContainerT =
typename std::map<KeyT, ValueT>;
2499 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2500 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2503 static std::string TypeName()
2509 : RMapField(
name, TypeName(), std::make_unique<
RField<std::pair<KeyT, ValueT>>>(
"_0"))
2516 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2517 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2520template <
typename KeyT,
typename ValueT>
2521class RField<std::unordered_map<KeyT, ValueT>> final :
public RMapField {
2522 using ContainerT =
typename std::unordered_map<KeyT, ValueT>;
2525 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2526 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2529 static std::string TypeName()
2535 : RMapField(
name, TypeName(), std::make_unique<
RField<std::pair<KeyT, ValueT>>>(
"_0"))
2542 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2543 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2546template <
typename... ItemTs>
2547class RField<std::variant<ItemTs...>> final :
public RVariantField {
2548 using ContainerT =
typename std::variant<ItemTs...>;
2550 template <
typename HeadT,
typename... TailTs>
2551 static std::string BuildItemTypes()
2554 if constexpr(
sizeof...(TailTs) > 0)
2555 result +=
"," + BuildItemTypes<TailTs...>();
2559 template <
typename HeadT,
typename... TailTs>
2560 static std::vector<RFieldBase *> BuildItemFields(
unsigned int index = 0)
2562 std::vector<RFieldBase *>
result;
2564 if constexpr(
sizeof...(TailTs) > 0) {
2565 auto tailFields = BuildItemFields<TailTs...>(
index + 1);
2566 result.insert(
result.end(), tailFields.begin(), tailFields.end());
2572 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2575 static std::string TypeName() {
return "std::variant<" + BuildItemTypes<ItemTs...>() +
">"; }
2576 explicit RField(std::string_view
name) : RVariantField(
name, BuildItemFields<ItemTs...>()) {}
2582template <
typename ItemT>
2583class RField<std::vector<ItemT>> final :
public RVectorField {
2584 using ContainerT =
typename std::vector<ItemT>;
2587 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2592 : RVectorField(
name, std::make_unique<
RField<ItemT>>(
"_0"))
2598 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2603class RField<std::vector<bool>> final :
public RFieldBase {
2608 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2610 return std::make_unique<RField>(newName);
2613 const RColumnRepresentations &GetColumnRepresentations() const final;
2614 void GenerateColumnsImpl() final;
2615 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2617 void ConstructValue(
void *where) const final {
new (where) std::vector<bool>(); }
2618 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<std::vector<bool>>>(); }
2620 std::size_t AppendImpl(
const void *from)
final;
2621 void ReadGlobalImpl(NTupleSize_t globalIndex,
void *to)
final;
2623 void CommitClusterImpl() final { fNWritten = 0; }
2626 static std::string TypeName() {
return "std::vector<bool>"; }
2632 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
2634 size_t GetValueSize() const final {
return sizeof(std::vector<bool>); }
2635 size_t GetAlignment() const final {
return std::alignment_of<std::vector<bool>>(); }
2636 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2637 void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *
size)
const {
2638 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
2640 void GetCollectionInfo(RClusterIndex clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *
size)
const
2642 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
2646template <
typename ItemT>
2650 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
2652 auto newItemField = fSubFields[0]->Clone(fSubFields[0]->GetFieldName());
2653 return std::make_unique<RField<ROOT::VecOps::RVec<ItemT>>>(newName, std::move(newItemField));
2657 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2661 auto typedValue =
static_cast<const ContainerT *
>(from);
2663 auto count = typedValue->size();
2664 for (
unsigned i = 0; i < count; ++i) {
2665 nbytes += CallAppendOn(*fSubFields[0], &typedValue->data()[i]);
2667 this->fNWritten += count;
2668 fColumns[0]->Append(&this->fNWritten);
2669 return nbytes + fColumns[0]->GetElement()->GetPackedSize();
2673 auto typedValue =
static_cast<ContainerT *
>(to);
2676 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &nItems);
2677 typedValue->resize(nItems);
2678 for (
unsigned i = 0; i < nItems; ++i) {
2679 CallReadOn(*fSubFields[0], collectionStart + i, &typedValue->data()[i]);
2684 RField(std::string_view fieldName, std::unique_ptr<RFieldBase> itemField)
2685 :
RRVecField(fieldName, std::move(itemField))
2700 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2703template <
typename T1,
typename T2>
2704class RField<std::pair<T1, T2>> final :
public RPairField {
2705 using ContainerT =
typename std::pair<T1,T2>;
2707 template <
typename Ty1,
typename Ty2>
2708 static std::array<std::unique_ptr<RFieldBase>, 2> BuildItemFields()
2710 return {std::make_unique<RField<Ty1>>(
"_0"), std::make_unique<
RField<Ty2>>(
"_1")};
2713 static std::array<std::size_t, 2> BuildItemOffsets()
2715 auto pair = ContainerT();
2716 auto offsetFirst =
reinterpret_cast<std::uintptr_t
>(&(pair.first)) -
reinterpret_cast<std::uintptr_t
>(&pair);
2717 auto offsetSecond =
reinterpret_cast<std::uintptr_t
>(&(pair.second)) -
reinterpret_cast<std::uintptr_t
>(&pair);
2718 return {offsetFirst, offsetSecond};
2722 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2724 std::array<std::unique_ptr<RFieldBase>, 2> items{fSubFields[0]->Clone(fSubFields[0]->GetFieldName()),
2725 fSubFields[1]->Clone(fSubFields[1]->GetFieldName())};
2726 return std::make_unique<RField<std::pair<T1, T2>>>(newName, std::move(items));
2729 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2730 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2733 static std::string TypeName() {
2736 explicit RField(std::string_view
name, std::array<std::unique_ptr<RFieldBase>, 2> &&itemFields)
2737 : RPairField(
name, std::move(itemFields), BuildItemOffsets())
2739 fMaxAlignment = std::max(
alignof(
T1),
alignof(
T2));
2740 fSize =
sizeof(ContainerT);
2748template <
typename... ItemTs>
2749class RField<std::tuple<ItemTs...>> final :
public RTupleField {
2750 using ContainerT =
typename std::tuple<ItemTs...>;
2752 template <
typename HeadT,
typename... TailTs>
2753 static std::string BuildItemTypes()
2756 if constexpr (
sizeof...(TailTs) > 0)
2757 result +=
"," + BuildItemTypes<TailTs...>();
2761 template <
typename HeadT,
typename... TailTs>
2762 static void _BuildItemFields(std::vector<std::unique_ptr<RFieldBase>> &itemFields,
unsigned int index = 0)
2765 if constexpr (
sizeof...(TailTs) > 0)
2766 _BuildItemFields<TailTs...>(itemFields,
index + 1);
2768 template <
typename... Ts>
2769 static std::vector<std::unique_ptr<RFieldBase>> BuildItemFields()
2771 std::vector<std::unique_ptr<RFieldBase>>
result;
2772 _BuildItemFields<Ts...>(
result);
2776 template <
unsigned Index,
typename HeadT,
typename... TailTs>
2777 static void _BuildItemOffsets(std::vector<std::size_t> &offsets,
const ContainerT &tuple)
2780 reinterpret_cast<std::uintptr_t
>(&std::get<Index>(tuple)) -
reinterpret_cast<std::uintptr_t
>(&tuple);
2781 offsets.emplace_back(
offset);
2782 if constexpr (
sizeof...(TailTs) > 0)
2783 _BuildItemOffsets<
Index + 1, TailTs...>(offsets, tuple);
2785 template <
typename... Ts>
2786 static std::vector<std::size_t> BuildItemOffsets()
2788 std::vector<std::size_t>
result;
2789 _BuildItemOffsets<0, Ts...>(
result, ContainerT());
2794 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2796 std::vector<std::unique_ptr<RFieldBase>> items;
2797 for (
auto &item : fSubFields)
2798 items.push_back(item->Clone(item->GetFieldName()));
2799 return std::make_unique<
RField<std::tuple<ItemTs...>>>(newName, std::move(items));
2802 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2803 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2806 static std::string TypeName() {
return "std::tuple<" + BuildItemTypes<ItemTs...>() +
">"; }
2807 explicit RField(std::string_view
name, std::vector<std::unique_ptr<RFieldBase>> &&itemFields)
2808 : RTupleField(
name, std::move(itemFields), BuildItemOffsets<ItemTs...>())
2810 fMaxAlignment = std::max({
alignof(ItemTs)...});
2811 fSize =
sizeof(ContainerT);
2819template <std::
size_t N>
2820class RField<std::bitset<N>> final :
public RBitsetField {
2822 static std::string TypeName() {
return "std::bitset<" + std::to_string(
N) +
">"; }
2829template <
typename ItemT>
2830class RField<std::unique_ptr<ItemT>> final :
public RUniquePtrField {
2833 explicit RField(std::string_view
name) : RUniquePtrField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
2839template <
typename ItemT>
2840class RField<std::atomic<ItemT>> final :
public RAtomicField {
2843 explicit RField(std::string_view
name) : RAtomicField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
2852template <
typename T>
2853std::unique_ptr<T, typename RFieldBase::RCreateObjectDeleter<T>::deleter> RFieldBase::CreateObject()
const
2859 return std::unique_ptr<T>(
static_cast<T *
>(CreateObjectRawPtr()));
2869std::unique_ptr<void, typename RFieldBase::RCreateObjectDeleter<void>::deleter>
2870ROOT::Experimental::RFieldBase::CreateObject<void>()
const;
#define R__unlikely(expr)
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
ROOT::Experimental::RField< T > RField
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
TRObject operator()(const T1 &t1) const
Binding & operator=(OUT(*fun)(void))
Abstract base class for classes implementing the visitor design pattern.
std::size_t GetPackedSize(std::size_t nElements=1U) const
NTupleSize_t GetGlobalIndex(RClusterIndex clusterIndex)
RColumnElementBase * GetElement() const
void Append(const void *from)
void ReadV(const NTupleSize_t globalIndex, const ClusterSize_t::ValueType count, void *to)
void Read(const NTupleSize_t globalIndex, void *to)
NTupleSize_t GetNElements() const
Abstract interface to write data into an ntuple.
Abstract interface to read data from an ntuple.
A field for fixed-size arrays that are represented as RVecs in memory.
std::size_t fArrayLength
The size of a child field's item.
std::size_t fValueSize
The length of the arrays in this field.
void GenerateColumnsImpl(const RNTupleDescriptor &) final
Creates the backing columns corresponsing to the field type for reading.
std::size_t fItemSize
Sub field deleter or nullptr for simple fields.
std::unique_ptr< RDeleter > fItemDeleter
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
RArrayDeleter(std::size_t itemSize, std::size_t arrayLength, std::unique_ptr< RDeleter > itemDeleter)
std::unique_ptr< RDeleter > fItemDeleter
The generic field for fixed size arrays, which do not need an offset column.
void GenerateColumnsImpl(const RNTupleDescriptor &) final
Creates the backing columns corresponsing to the field type for reading.
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
~RAtomicField() override=default
void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final
std::unique_ptr< RDeleter > GetDeleter() const final
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
void GenerateColumnsImpl(const RNTupleDescriptor &) final
Creates the backing columns corresponsing to the field type for reading.
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
RAtomicField & operator=(RAtomicField &&other)=default
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
RAtomicField(RAtomicField &&other)=default
The generic field an std::bitset<N>.
std::size_t GetN() const
Get the number of bits in the bitset, i.e. the N in std::bitset<N>
RBitsetField(RBitsetField &&other)=default
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
~RBitsetField() override=default
RBitsetField & operator=(RBitsetField &&other)=default
An artificial field that transforms an RNTuple column that contains the offset of collections into co...
RCardinalityField & operator=(RCardinalityField &&other)=default
~RCardinalityField() override=default
RCardinalityField(RCardinalityField &&other)=default
RCardinalityField(std::string_view fieldName, std::string_view typeName)
void operator()(void *objPtr, bool dtorOnly) final
RClassDeleter(TClass *cl)
The field for a class with dictionary.
void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final
static constexpr const char * kPrefixInherited
Prefix used in the subfield names generated for base classes.
void Attach(std::unique_ptr< RFieldBase > child, RSubFieldInfo info)
void OnConnectPageSource() final
Called by ConnectPageSource() only once connected; derived classes may override this as appropriate.
size_t GetValueSize() const override
The number of bytes taken by a value of the appropriate type.
void ConstructValue(void *where) const override
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void AddReadCallbacksFromIORules(const std::span< const TSchemaRule * > rules, TClass *classp=nullptr)
Register post-read callbacks corresponding to a list of ROOT I/O customization rules.
void AcceptVisitor(Detail::RFieldVisitor &visitor) const override
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::uint32_t GetTypeVersion() const final
Indicates an evolution of the C++ type itself.
void GenerateColumnsImpl(const RNTupleDescriptor &) final
Creates the backing columns corresponsing to the field type for reading.
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given a value for this field.
std::vector< RSubFieldInfo > fSubFieldsInfo
Additional information kept for each entry in fSubFields
std::size_t fMaxAlignment
std::unique_ptr< RDeleter > GetDeleter() const final
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
DescriptorId_t GetClusterId() const
ClusterSize_t::ValueType GetIndex() const
The collection field is only used for writing; when reading, untyped collections are projected to an ...
std::shared_ptr< RNTupleCollectionWriter > fCollectionWriter
Save the link to the collection ntuple in order to reset the offset counter when committing the clust...
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
~RCollectionField() override=default
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
RCollectionField(RCollectionField &&other)=default
The field for an unscoped or scoped enum with dictionary.
~REnumField() override=default
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
REnumField & operator=(REnumField &&other)=default
void GenerateColumnsImpl(const RNTupleDescriptor &) final
Creates the backing columns corresponsing to the field type for reading.
void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final
REnumField(REnumField &&other)=default
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
Base class for all ROOT issued exceptions.
Similar to RValue but manages an array of consecutive values.
bool fIsAdopted
True if the user provides the memory buffer for fValues.
void * ReadBulk(RClusterIndex firstIndex, const bool *maskReq, std::size_t size)
Reads 'size' values from the associated field, starting from 'firstIndex'.
RFieldBase * fField
The field that created the array of values.
std::vector< unsigned char > fAuxData
Reading arrays of complex values may require additional memory, for instance for the elements of arra...
bool ContainsRange(RClusterIndex firstIndex, std::size_t size) const
RBulk(const RBulk &)=delete
std::size_t fCapacity
The size of the array memory block in number of values.
std::unique_ptr< bool[]> fMaskAvail
Masks invalid values in the array.
std::size_t fValueSize
Cached copy of fField->GetValueSize()
void AdoptBuffer(void *buf, std::size_t capacity)
void * GetValuePtrAt(std::size_t idx) const
RBulk & operator=(const RBulk &)=delete
void Reset(RClusterIndex firstIndex, std::size_t size)
Sets a new range for the bulk.
std::size_t fNValidValues
The sum of non-zero elements in the fMask.
RClusterIndex fFirstIndex
Index of the first value of the array.
std::size_t fSize
The number of available values in the array (provided their mask is set)
void * fValues
Cached deleter of fField.
std::unique_ptr< RFieldBase::RDeleter > fDeleter
Some fields have multiple possible column representations, e.g.
const TypesList_t & GetSerializationTypes() const
std::vector< ColumnRepresentation_t > TypesList_t
TypesList_t fSerializationTypes
TypesList_t fDeserializationTypes
The union of the serialization types and the deserialization extra types.
const TypesList_t & GetDeserializationTypes() const
const ColumnRepresentation_t & GetSerializationDefault() const
The first column list from fSerializationTypes is the default for writing.
A functor to release the memory acquired by CreateValue (memory and constructor).
virtual ~RDeleter()=default
virtual void operator()(void *objPtr, bool dtorOnly)
Iterates over the sub tree of fields in depth-first search order.
reference operator*() const
RSchemaIteratorTemplate(pointer val, int idxInParent)
std::conditional_t< IsConstT, const RFieldBase *, RFieldBase * > pointer
RSchemaIteratorTemplate()
pointer operator->() const
std::vector< Position > fStack
The stack of nodes visited when walking down the tree of fields.
std::ptrdiff_t difference_type
~RSchemaIteratorTemplate()
void Advance()
Given that the iterator points to a valid field which is not the end iterator, go to the next field i...
bool operator!=(const iterator &rh) const
bool operator==(const iterator &rh) const
std::conditional_t< IsConstT, const RFieldBase, RFieldBase > value_type
std::forward_iterator_tag iterator_category
std::conditional_t< IsConstT, const RFieldBase &, RFieldBase & > reference
A deleter for templated RFieldBase descendents where the value type is known.
void operator()(void *objPtr, bool dtorOnly) final
Points to an object with RNTuple I/O support and keeps a pointer to the corresponding field.
RValue & operator=(RValue &&other)=default
RValue(const RValue &)=default
void Read(NTupleSize_t globalIndex)
RFieldBase * fField
The field that created the RValue.
RValue & operator=(const RValue &)=default
const RFieldBase & GetField() const
void EmplaceNew()
Replace the current object pointer by a pointer to a new object constructed by the field.
std::shared_ptr< void > fObjPtr
Set by Bind() or by RFieldBase::CreateValue(), SplitValue() or BindValue()
void BindRawPtr(void *rawPtr)
std::shared_ptr< T > GetPtr() const
void Read(RClusterIndex clusterIndex)
void Bind(std::shared_ptr< void > objPtr)
RValue(RFieldBase *field, std::shared_ptr< void > objPtr)
RValue(RValue &&other)=default
A field translates read and write calls from/to underlying columns to/from tree values.
virtual void GenerateColumnsImpl()=0
Creates the backing columns corresponsing to the field type for writing.
static constexpr std::uint32_t kInvalidTypeVersion
static constexpr int kTraitTriviallyDestructible
The type is cleaned up just by freeing its memory. I.e. the destructor performs a no-op.
const RFieldBase * GetParent() const
std::string GetFieldName() const
void Attach(std::unique_ptr< RFieldBase > child)
Add a new subfield to the list of nested fields.
bool HasDefaultColumnRepresentative() const
Whether or not an explicit column representative was set.
std::uint32_t fOnDiskTypeVersion
C++ type version cached from the descriptor after a call to ConnectPageSource()
void AutoAdjustColumnTypes(const RNTupleWriteOptions &options)
When connecting a field to a page sink, the field's default column representation is subject to adjus...
const ColumnRepresentation_t & EnsureCompatibleColumnTypes(const RNTupleDescriptor &desc) const
Returns the on-disk column types found in the provided descriptor for fOnDiskId.
ENTupleStructure fStructure
The role of this field in the data model structure.
std::vector< RFieldBase * > GetSubFields()
static std::vector< RCheckResult > Check(const std::string &fieldName, const std::string &typeName)
Checks if the given type is supported by RNTuple.
static constexpr int kTraitMappable
A field of a fundamental type that can be directly mapped via RField<T>::Map(), i....
std::function< void(void *)> ReadCallback_t
EState fState
Changed by ConnectTo[Sink,Source], reset by Clone()
static constexpr int kTraitTriviallyConstructible
No constructor needs to be called, i.e.
std::string fTypeAlias
A typedef or using name that was used when creating the field.
std::vector< std::unique_ptr< Internal::RColumn > > fColumns
The columns are connected either to a sink or to a source (not to both); they are owned by the field.
RConstSchemaIterator cbegin() const
RSchemaIteratorTemplate< false > RSchemaIterator
ENTupleStructure GetStructure() const
RValue BindValue(std::shared_ptr< void > objPtr)
Creates a value from a memory location with an already constructed object.
RFieldBase(RFieldBase &&)=default
std::string GetTypeName() const
virtual void AcceptVisitor(Detail::RFieldVisitor &visitor) const
std::string fDescription
Free text set by the user.
static Internal::RColumn * GetPrincipalColumnOf(const RFieldBase &other)
Fields may need direct access to the principal column of their sub fields, e.g. in RRVecField::ReadBu...
friend struct ROOT::Experimental::Internal::RFieldCallbackInjector
bool HasReadCallbacks() const
std::size_t fNRepetitions
For fixed sized arrays, the array length.
RFieldBase & operator=(const RFieldBase &)=delete
RFieldBase * fParent
Sub fields point to their mother field.
std::unique_ptr< T, typename RCreateObjectDeleter< T >::deleter > CreateObject() const
Generates an object of the field type and allocates new initialized memory according to the type.
static std::size_t CallAppendOn(RFieldBase &other, const void *from)
Allow derived classes to call Append and Read on other (sub) fields.
int fTraits
Properties of the type that allow for optimizations of collections of that type.
static std::unique_ptr< RDeleter > GetDeleterOf(const RFieldBase &other)
void ConnectPageSink(Internal::RPageSink &pageSink, NTupleSize_t firstEntry=0)
Fields and their columns live in the void until connected to a physical page storage.
DescriptorId_t fOnDiskId
When the columns are connected to a page source or page sink, the field represents a field id in the ...
virtual std::size_t AppendImpl(const void *from)
Operations on values of complex types, e.g.
virtual void GenerateColumnsImpl(const RNTupleDescriptor &desc)=0
Creates the backing columns corresponsing to the field type for reading.
RConstSchemaIterator cend() const
const ColumnRepresentation_t * fColumnRepresentative
Points into the static vector GetColumnRepresentations().GetSerializationTypes() when SetColumnRepres...
void Read(NTupleSize_t globalIndex, void *to)
Populate a single value with data from the field.
bool fIsSimple
A field qualifies as simple if it is both mappable and has no post-read callback.
std::uint32_t GetOnDiskTypeVersion() const
Return the C++ type version stored in the field descriptor; only valid after a call to ConnectPageSou...
std::string GetQualifiedFieldName() const
Returns the field name and parent field names separated by dots ("grandparent.parent....
virtual std::uint32_t GetTypeVersion() const
Indicates an evolution of the C++ type itself.
std::vector< EColumnType > ColumnRepresentation_t
virtual std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec)
General implementation of bulk read.
virtual std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const =0
Called by Clone(), which additionally copies the on-disk ID.
std::size_t Append(const void *from)
Write the given value into columns.
RFieldBase(const RFieldBase &)=delete
void RemoveReadCallback(size_t idx)
void * CreateObjectRawPtr() const
Factory method for the field's type. The caller owns the returned pointer.
void CommitCluster()
Flushes data from active columns to disk and calls CommitClusterImpl.
void ConnectPageSource(Internal::RPageSource &pageSource)
Connects the field and its sub field tree to the given page source.
RValue CreateValue()
Generates an object of the field type and wraps the created object in a shared pointer and returns it...
std::unique_ptr< RFieldBase > Clone(std::string_view newName) const
Copies the field and its sub fields using a possibly new name and a new, unconnected set of columns.
std::size_t ReadBulk(const RBulkSpec &bulkSpec)
Returns the number of newly available values, that is the number of bools in bulkSpec....
virtual std::unique_ptr< RDeleter > GetDeleter() const
virtual void ReadInClusterImpl(RClusterIndex clusterIndex, void *to)
static void CallReadOn(RFieldBase &other, RClusterIndex clusterIndex, void *to)
virtual std::uint32_t GetFieldVersion() const
Indicates an evolution of the mapping scheme from C++ type to columns.
virtual void ConstructValue(void *where) const =0
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
static RResult< std::unique_ptr< RFieldBase > > Create(const std::string &fieldName, const std::string &canonicalType, const std::string &typeAlias, bool fContinueOnError=false)
Factory method to resurrect a field from the stored on-disk type information.
RSchemaIteratorTemplate< true > RConstSchemaIterator
std::string GetDescription() const
Get the field's description.
size_t AddReadCallback(ReadCallback_t func)
Set a user-defined function to be called after reading a value, giving a chance to inspect and/or mod...
virtual std::vector< RValue > SplitValue(const RValue &value) const
Creates the list of direct child values given a value for this field.
void SetOnDiskId(DescriptorId_t id)
std::size_t GetNRepetitions() const
virtual ~RFieldBase()=default
std::string fName
The field name relative to its parent field.
virtual size_t GetAlignment() const =0
As a rule of thumb, the alignment is equal to the size of the type.
RBulk CreateBulk()
The returned bulk is initially empty; RBulk::ReadBulk will construct the array of values.
void InvokeReadCallbacks(void *target)
virtual void OnConnectPageSource()
Called by ConnectPageSource() only once connected; derived classes may override this as appropriate.
static void CallReadOn(RFieldBase &other, NTupleSize_t globalIndex, void *to)
void Read(RClusterIndex clusterIndex, void *to)
void SetColumnRepresentative(const ColumnRepresentation_t &representative)
Fixes a column representative.
static void CallConstructValueOn(const RFieldBase &other, void *where)
Allow derived classes to call ConstructValue(void *) and GetDeleter on other (sub) fields.
std::vector< std::unique_ptr< RFieldBase > > fSubFields
Collections and classes own sub fields.
std::string fType
The C++ type captured by this field.
Internal::RColumn * fPrincipalColumn
Points into fColumns.
DescriptorId_t GetOnDiskId() const
virtual size_t GetValueSize() const =0
The number of bytes taken by a value of the appropriate type.
static constexpr int kTraitTrivialType
Shorthand for types that are both trivially constructible and destructible.
const ColumnRepresentation_t & GetColumnRepresentative() const
Returns the fColumnRepresentative pointee or, if unset, the field's default representative.
std::string GetTypeAlias() const
EState
During its lifetime, a field undergoes the following possible state transitions:
std::vector< ReadCallback_t > fReadCallbacks
List of functions to be called after reading a value.
void SetDescription(std::string_view description)
static RResult< void > EnsureValidFieldName(std::string_view fieldName)
Check whether a given string is a valid field name.
NTupleSize_t EntryToColumnElementIndex(NTupleSize_t globalIndex) const
Translate an entry index to a column element index of the principal column and viceversa.
virtual void ReadGlobalImpl(NTupleSize_t globalIndex, void *to)
NTupleSize_t GetNElements() const
virtual void CommitClusterImpl()
virtual const RColumnRepresentations & GetColumnRepresentations() const
Implementations in derived classes should return a static RColumnRepresentations object.
The container field for an ntuple model, which itself has no physical representation.
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const override
Called by Clone(), which additionally copies the on-disk ID.
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
void GenerateColumnsImpl(const RNTupleDescriptor &) final
Creates the backing columns corresponsing to the field type for reading.
void ConstructValue(void *) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
ClusterSize_t * MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
static std::string TypeName()
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
RField(std::string_view name)
~RField() override=default
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
RField(RField &&other)=default
ClusterSize_t * Map(NTupleSize_t globalIndex)
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *size)
Special help for offset fields.
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
ClusterSize_t * Map(RClusterIndex clusterIndex)
void GetCollectionInfo(RClusterIndex clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size)
ClusterSize_t * MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
RField & operator=(RField &&other)=default
RField(RField &&other)=default
~RField() override=default
RField(std::string_view name)
RField(std::string_view name)
std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec) final
General implementation of bulk read.
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
std::unique_ptr< ROOT::Experimental::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
RField(RField &&other)=default
void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final
Get the number of elements of the collection identified by clusterIndex.
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
Get the number of elements of the collection identified by globalIndex.
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
RField & operator=(RField &&other)=default
~RField() override=default
static std::string TypeName()
RField(std::string_view name)
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
typename ROOT::VecOps::RVec< ItemT > ContainerT
static std::string TypeName()
~RField() override=default
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
RField(RField &&other)=default
std::unique_ptr< RDeleter > GetDeleter() const final
RField(std::string_view fieldName, std::unique_ptr< RFieldBase > itemField)
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
bool * MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
RField(std::string_view name)
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
bool * MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
bool * Map(RClusterIndex clusterIndex)
~RField() override=default
static std::string TypeName()
RField(RField &&other)=default
bool * Map(NTupleSize_t globalIndex)
char * MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
RField(std::string_view name)
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
char * Map(RClusterIndex clusterIndex)
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
char * Map(NTupleSize_t globalIndex)
RField(RField &&other)=default
char * MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
static std::string TypeName()
~RField() override=default
double * Map(RClusterIndex clusterIndex)
double * MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
RField(std::string_view name)
double * MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
~RField() override=default
double * Map(NTupleSize_t globalIndex)
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
RField(RField &&other)=default
static std::string TypeName()
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
static std::string TypeName()
RField(RField &&other)=default
float * MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
RField(std::string_view name)
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
float * MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
float * Map(NTupleSize_t globalIndex)
~RField() override=default
float * Map(RClusterIndex clusterIndex)
RField(const RField &)=delete
static std::string TypeName()
RField & operator=(const RField &)=delete
Classes with dictionaries that can be inspected by TClass.
RField(std::string_view name)
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
RField & operator=(RField &&other)=default
RField(RField &&other)=default
static std::string TypeName()
~RField() override=default
Used in RFieldBase::Check() to record field creation failures.
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
RInvalidField(std::string_view name, std::string_view type, std::string_view error)
std::string GetError() const
void GenerateColumnsImpl(const RNTupleDescriptor &) final
Creates the backing columns corresponsing to the field type for reading.
void ConstructValue(void *) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
The generic field for a std::map<KeyType, ValueType> and std::unordered_map<KeyType,...
size_t GetAlignment() const override
As a rule of thumb, the alignment is equal to the size of the type.
RMapField(RMapField &&other)=default
~RMapField() override=default
RMapField & operator=(RMapField &&other)=default
The on-storage meta-data of an ntuple.
Common user-tunable settings for storing ntuples.
The field for values that may or may not be present in an entry.
RNullableField & operator=(RNullableField &&other)=default
~RNullableField() override=default
RNullableField(RNullableField &&other)=default
std::unique_ptr< RValue > fDefaultItemValue
For a dense nullable field, used to write a default-constructed item for missing ones.
The generic field for std::pair<T1, T2> types.
~RPairField() override=default
static std::string GetTypeList(const std::array< std::unique_ptr< RFieldBase >, 2 > &itemFields)
RPairField(RPairField &&other)=default
std::unique_ptr< RDeleter > GetDeleter() const override
RPairField & operator=(RPairField &&other)=default
pointer operator*() const
bool operator==(const iterator &rh) const
RIterator(const RCollectionIterableOnce &owner)
bool operator!=(const iterator &rh) const
std::forward_iterator_tag iterator_category
const RCollectionIterableOnce & fOwner
RIterator(const RCollectionIterableOnce &owner, void *iter)
std::ptrdiff_t difference_type
Allows for iterating over the elements of a proxied collection.
const RIteratorFuncs & fIFuncs
const std::size_t fStride
~RCollectionIterableOnce()
RCollectionIterableOnce(void *collection, const RIteratorFuncs &ifuncs, TVirtualCollectionProxy *proxy, std::size_t stride=0U)
Construct a RCollectionIterableOnce that iterates over collection.
RProxiedCollectionDeleter(std::shared_ptr< TVirtualCollectionProxy > proxy, std::unique_ptr< RDeleter > itemDeleter, size_t itemSize)
std::shared_ptr< TVirtualCollectionProxy > fProxy
std::unique_ptr< RDeleter > fItemDeleter
RCollectionIterableOnce::RIteratorFuncs fIFuncsWrite
RProxiedCollectionDeleter(std::shared_ptr< TVirtualCollectionProxy > proxy)
The field for a class representing a collection of elements via TVirtualCollectionProxy.
void GetCollectionInfo(RClusterIndex clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
std::shared_ptr< TVirtualCollectionProxy > fProxy
The collection proxy is needed by the deleters and thus defined as a shared pointer.
RCollectionIterableOnce::RIteratorFuncs fIFuncsRead
Two sets of functions to operate on iterators, to be used depending on the access type.
RProxiedCollectionField(RProxiedCollectionField &&other)=default
void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
~RProxiedCollectionField() override=default
RCollectionIterableOnce::RIteratorFuncs fIFuncsWrite
size_t GetAlignment() const override
As a rule of thumb, the alignment is equal to the size of the type.
size_t GetValueSize() const override
The number of bytes taken by a value of the appropriate type.
RProxiedCollectionField & operator=(RProxiedCollectionField &&other)=default
the RRVecDeleter is also used by RArrayAsRVecField and therefore declared public
std::size_t fItemAlignment
RRVecDeleter(std::size_t itemAlignment)
RRVecDeleter(std::size_t itemAlignment, std::size_t itemSize, std::unique_ptr< RDeleter > itemDeleter)
std::unique_ptr< RDeleter > fItemDeleter
The type-erased field for a RVec<Type>
void GetCollectionInfo(RClusterIndex clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
std::unique_ptr< RDeleter > fItemDeleter
RRVecField(RRVecField &&)=default
~RRVecField() override=default
RRVecField(const RRVecField &)=delete
RRVecField & operator=(RRVecField &&)=default
RRVecField & operator=(RRVecField &)=delete
void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
std::vector< std::size_t > fOffsets
std::vector< std::unique_ptr< RDeleter > > fItemDeleters
RRecordDeleter(std::vector< std::unique_ptr< RDeleter > > &itemDeleters, const std::vector< std::size_t > &offsets)
The field for an untyped record.
RRecordField(std::string_view fieldName, std::array< std::unique_ptr< RFieldBase >, N > &&itemFields, const std::array< std::size_t, N > &offsets, std::string_view typeName="")
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::vector< std::size_t > fOffsets
RRecordField(RRecordField &&other)=default
void GenerateColumnsImpl(const RNTupleDescriptor &) final
Creates the backing columns corresponsing to the field type for reading.
~RRecordField() override=default
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
The generic field for a std::set<Type> and std::unordered_set<Type>
RSetField(RSetField &&other)=default
RSetField & operator=(RSetField &&other)=default
size_t GetAlignment() const override
As a rule of thumb, the alignment is equal to the size of the type.
~RSetField() override=default
RTupleDeleter(TClass *cl)
The generic field for std::tuple<Ts...> types.
std::unique_ptr< RDeleter > GetDeleter() const override
RTupleField & operator=(RTupleField &&other)=default
static std::string GetTypeList(const std::vector< std::unique_ptr< RFieldBase > > &itemFields)
~RTupleField() override=default
RTupleField(RTupleField &&other)=default
RUniquePtrDeleter(std::unique_ptr< RDeleter > itemDeleter)
std::unique_ptr< RDeleter > fItemDeleter
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
std::unique_ptr< RDeleter > fItemDeleter
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::vector< std::unique_ptr< RDeleter > > fItemDeleters
RVariantDeleter(std::size_t tagOffset, std::vector< std::unique_ptr< RDeleter > > &itemDeleters)
The generic field for std::variant types.
std::vector< ClusterSize_t::ValueType > fNWritten
std::unique_ptr< RDeleter > fItemDeleter
RVectorDeleter(std::size_t itemSize, std::unique_ptr< RDeleter > itemDeleter)
The generic field for a (nested) std::vector<Type> except for std::vector<bool>
~RVectorField() override=default
std::unique_ptr< RDeleter > fItemDeleter
size_t GetValueSize() const override
The number of bytes taken by a value of the appropriate type.
void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
void GetCollectionInfo(RClusterIndex clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
RVectorField(RVectorField &&other)=default
A "std::vector"-like collection of values implementing handy operation to analyse them.
TClass instances represent classes, structs and namespaces in the ROOT type system.
The TEnum class implements the enum type.
Defines a common interface to inspect/change the contents of an object that represents a collection.
void(* CreateIterators_t)(void *collection, void **begin_arena, void **end_arena, TVirtualCollectionProxy *proxy)
*begin_arena and *end_arena should contain the location of a memory arena of size fgIteratorArenaSize...
void *(* Next_t)(void *iter, const void *end)
iter and end should be pointers to an iterator to be incremented and an iterator that points to the e...
void(* DeleteTwoIterators_t)(void *begin, void *end)
static const Int_t fgIteratorArenaSize
The size of a small buffer that can be allocated on the stack to store iterator-specific information.
RooCmdArg Index(RooCategory &icat)
auto Map(Args &&... args)
Create new collection applying a callable to the elements of the input collection.
void CallConnectPageSinkOnField(RFieldBase &, RPageSink &, NTupleSize_t firstEntry=0)
void CallConnectPageSourceOnField(RFieldBase &, RPageSource &)
void CallCommitClusterOnField(RFieldBase &)
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
RClusterSize ClusterSize_t
ENTupleStructure
The fields in the ntuple model tree can carry different structural information about the type system.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
constexpr DescriptorId_t kInvalidDescriptorId
std::string GetDemangledTypeName(const std::type_info &t)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
The point here is that we can only tell at run time if a class has an associated collection proxy.
Wrap the integer in a struct in order to avoid template specialization clash with std::uint64_t.
Input parameter to ReadBulk() and ReadBulkImpl(). See RBulk class for more information.
void * fValues
The destination area, which has to be a big enough array of valid objects of the correct type.
const bool * fMaskReq
A bool array of size fCount, indicating the required values in the requested range.
bool * fMaskAvail
A bool array of size fCount, indicating the valid values in fValues.
std::size_t fCount
Size of the bulk range.
RClusterIndex fFirstIndex
Start of the bulk range.
std::vector< unsigned char > * fAuxData
Reference to memory owned by the RBulk class.
static const std::size_t kAllSet
As a return value of ReadBulk and ReadBulkImpl(), indicates that the full bulk range was read indepen...
Used in the return value of the Check() method.
std::string fFieldName
Qualified field name causing the error.
std::string fTypeName
Type name corresponding to the (sub) field.
std::string fErrMsg
Cause of the failure, e.g. unsupported type.
std::default_delete< T > deleter
Position(FieldPtr_t fieldPtr, int idxInParent)
std::conditional_t< IsConstT, const RFieldBase *, RFieldBase * > FieldPtr_t
void operator()(void *objPtr)
RSharedPtrDeleter(std::unique_ptr< RFieldBase::RDeleter > deleter)
std::unique_ptr< RFieldBase::RDeleter > fDeleter
Helper types to present an offset column as array of collection sizes.
TVirtualCollectionProxy::Next_t fNext
TVirtualCollectionProxy::DeleteTwoIterators_t fDeleteTwoIterators
TVirtualCollectionProxy::CreateIterators_t fCreateIterators