60namespace Experimental {
62class RCollectionField;
63class RNTupleCollectionWriter;
67struct RFieldCallbackInjector;
114 operator delete(objPtr);
119 template <
typename T>
124 std::destroy_at(
static_cast<T *
>(objPtr));
211 template <
typename T>
214 return std::static_pointer_cast<T>(
fObjPtr);
217 template <
typename T>
220 return *
static_cast<T *
>(
fObjPtr.get());
377 static const std::size_t
kAllSet = std::size_t(-1);
400 std::vector<std::unique_ptr<Internal::RColumn>>
fColumns;
431 virtual std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const = 0;
435 virtual std::unique_ptr<RDeleter>
GetDeleter()
const {
return std::make_unique<RDeleter>(); }
442 virtual std::size_t
AppendImpl(
const void *from);
492 virtual std::size_t
ReadBulkImpl(
const RBulkSpec &bulkSpec);
538 const std::string &typeAlias,
bool fContinueOnError =
false);
542 template <
bool IsConstT>
546 using FieldPtr_t = std::conditional_t<IsConstT, const RFieldBase *, RFieldBase *>;
558 using value_type = std::conditional_t<IsConstT, const RFieldBase, RFieldBase>;
559 using pointer = std::conditional_t<IsConstT, const RFieldBase *, RFieldBase *>;
560 using reference = std::conditional_t<IsConstT, const RFieldBase &, RFieldBase &>;
569 auto itr =
fStack.rbegin();
570 if (!itr->fFieldPtr->fSubFields.empty()) {
571 fStack.emplace_back(
Position(itr->fFieldPtr->fSubFields[0].get(), 0));
575 unsigned int nextIdxInParent = ++(itr->fIdxInParent);
576 while (nextIdxInParent >= itr->fFieldPtr->fParent->fSubFields.size()) {
578 itr->fFieldPtr = itr->fFieldPtr->fParent;
579 itr->fIdxInParent = -1;
584 nextIdxInParent = ++(itr->fIdxInParent);
586 itr->fFieldPtr = itr->fFieldPtr->fParent->fSubFields[nextIdxInParent].get();
600 template <
typename T>
616 std::size_t nRepetitions = 0);
624 std::unique_ptr<RFieldBase>
Clone(std::string_view newName)
const;
628 Create(
const std::string &fieldName,
const std::string &typeName);
631 static std::vector<RCheckResult>
Check(
const std::string &fieldName,
const std::string &typeName);
644 template <
typename T>
645 std::unique_ptr<T, typename RCreateObjectDeleter<T>::deleter>
CreateObject()
const;
719 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const override;
739 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
779 void operator()(
void *objPtr,
bool dtorOnly)
final;
788 RClassField(std::string_view fieldName, std::string_view className,
TClass *classp);
795 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final;
800 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RClassDeleter>(
fClass); }
802 std::size_t
AppendImpl(
const void *from)
final;
808 RClassField(std::string_view fieldName, std::string_view className);
817 void AcceptVisitor(Detail::RFieldVisitor &visitor) const override;
823 REnumField(std::string_view fieldName, std::string_view enumName,
TEnum *enump);
824 REnumField(std::string_view fieldName, std::string_view enumName, std::unique_ptr<RFieldBase> intField);
827 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final;
838 REnumField(std::string_view fieldName, std::string_view enumName);
874 void *fIterator =
nullptr;
875 void *fElementPtr =
nullptr;
879 auto fnNext_Contig = [&]() {
882 auto &iter =
reinterpret_cast<unsigned char *&
>(fIterator),
p = iter;
911 void *fBegin = &fBeginSmallBuf;
912 void *fEnd = &fEndSmallBuf;
918 std::size_t stride = 0U)
919 : fIFuncs(ifuncs), fStride(stride)
931 std::shared_ptr<TVirtualCollectionProxy>
fProxy;
933 std::size_t fItemSize = 0;
940 : fProxy(proxy), fItemDeleter(std::move(itemDeleter)), fItemSize(itemSize)
942 fIFuncsWrite = RCollectionIterableOnce::GetIteratorFuncs(fProxy.get(),
false );
944 void operator()(
void *objPtr,
bool dtorOnly)
final;
948 std::shared_ptr<TVirtualCollectionProxy>
fProxy;
963 std::unique_ptr<RFieldBase> itemField);
966 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const override;
968 void GenerateColumnsImpl() final;
971 void ConstructValue(
void *where) const override;
972 std::unique_ptr<
RDeleter> GetDeleter() const override;
974 std::
size_t AppendImpl(const
void *from) override;
975 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) override;
977 void CommitClusterImpl() final { fNWritten = 0; }
985 std::vector<RValue> SplitValue(
const RValue &
value)
const override;
987 size_t GetAlignment()
const override {
return alignof(std::max_align_t); }
991 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
995 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
1009 RRecordDeleter(std::vector<std::unique_ptr<RDeleter>> &itemDeleters,
const std::vector<std::size_t> &offsets)
1010 : fItemDeleters(std::move(itemDeleters)), fOffsets(offsets)
1013 void operator()(
void *objPtr,
bool dtorOnly)
final;
1017 std::size_t fMaxAlignment = 1;
1021 std::size_t GetItemPadding(std::size_t baseOffset, std::size_t itemAlignment)
const;
1023 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const override;
1028 void ConstructValue(
void *where)
const override;
1029 std::unique_ptr<RDeleter> GetDeleter()
const override;
1031 std::size_t AppendImpl(
const void *from)
final;
1032 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
1033 void ReadInClusterImpl(
RClusterIndex clusterIndex,
void *to)
final;
1035 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &&itemFields,
1036 const std::vector<std::size_t> &offsets, std::string_view typeName =
"");
1038 template <std::
size_t N>
1039 RRecordField(std::string_view fieldName, std::array<std::unique_ptr<RFieldBase>,
N> &&itemFields,
1040 const std::array<std::size_t, N> &offsets, std::string_view typeName =
"")
1043 fTraits |= kTraitTrivialType;
1044 for (
unsigned i = 0; i <
N; ++i) {
1045 fOffsets.push_back(offsets[i]);
1046 fMaxAlignment = std::max(fMaxAlignment, itemFields[i]->GetAlignment());
1047 fSize += GetItemPadding(
fSize, itemFields[i]->GetAlignment()) + itemFields[i]->GetValueSize();
1048 fTraits &= itemFields[i]->GetTraits();
1049 Attach(std::move(itemFields[i]));
1055 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &&itemFields);
1056 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &itemFields);
1061 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1072 std::size_t fItemSize = 0;
1078 : fItemSize(itemSize), fItemDeleter(std::move(itemDeleter))
1081 void operator()(
void *objPtr,
bool dtorOnly)
final;
1089 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1092 void GenerateColumnsImpl() final;
1095 void ConstructValue(
void *where)
const override {
new (where) std::vector<char>(); }
1096 std::unique_ptr<RDeleter> GetDeleter() const final;
1098 std::
size_t AppendImpl(const
void *from) final;
1099 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1101 void CommitClusterImpl() final { fNWritten = 0; }
1104 RVectorField(std::string_view fieldName, std::unique_ptr<RFieldBase> itemField);
1109 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1111 size_t GetAlignment() const final {
return std::alignment_of<std::vector<char>>(); }
1114 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
1118 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
1129 std::size_t fItemSize = 0;
1133 explicit RRVecDeleter(std::size_t itemAlignment) : fItemAlignment(itemAlignment) {}
1134 RRVecDeleter(std::size_t itemAlignment, std::size_t itemSize, std::unique_ptr<RDeleter> itemDeleter)
1135 : fItemAlignment(itemAlignment), fItemSize(itemSize), fItemDeleter(std::move(itemDeleter))
1138 void operator()(
void *objPtr,
bool dtorOnly)
final;
1148 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const override;
1150 void GenerateColumnsImpl() final;
1153 void ConstructValue(
void *where) const override;
1154 std::unique_ptr<
RDeleter> GetDeleter() const override;
1156 std::
size_t AppendImpl(const
void *from) override;
1157 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) override;
1158 std::
size_t ReadBulkImpl(const
RBulkSpec &bulkSpec) final;
1160 void CommitClusterImpl() final { fNWritten = 0; }
1163 RRVecField(std::string_view fieldName, std::unique_ptr<RFieldBase> itemField);
1170 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1171 size_t GetValueSize()
const override;
1172 size_t GetAlignment()
const override;
1176 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
1180 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
1189 std::size_t fItemSize = 0;
1190 std::size_t fArrayLength = 0;
1194 RArrayDeleter(std::size_t itemSize, std::size_t arrayLength, std::unique_ptr<RDeleter> itemDeleter)
1195 : fItemSize(itemSize), fArrayLength(arrayLength), fItemDeleter(std::move(itemDeleter))
1198 void operator()(
void *objPtr,
bool dtorOnly)
final;
1205 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1210 void ConstructValue(
void *where)
const override;
1211 std::unique_ptr<RDeleter> GetDeleter() const final;
1213 std::
size_t AppendImpl(const
void *from) final;
1214 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1215 void ReadInClusterImpl(
RClusterIndex clusterIndex,
void *to) final;
1218 RArrayField(std::string_view fieldName, std::unique_ptr<
RFieldBase> itemField, std::
size_t arrayLength);
1224 size_t GetLength()
const {
return fArrayLength; }
1226 size_t GetAlignment() const final {
return fSubFields[0]->GetAlignment(); }
1245 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1250 void ConstructValue(
void *where)
const final;
1252 std::unique_ptr<RDeleter> GetDeleter() const final;
1254 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1255 void ReadInClusterImpl(
RClusterIndex clusterIndex,
void *to) final;
1271 std::size_t GetAlignment() const final;
1274 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
1282 static constexpr std::size_t kWordSize =
sizeof(
Word_t);
1283 static constexpr std::size_t kBitsPerWord = kWordSize * 8;
1289 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
1291 return std::make_unique<RBitsetField>(newName, fN);
1293 const RColumnRepresentations &GetColumnRepresentations() const final;
1294 void GenerateColumnsImpl() final;
1296 void ConstructValue(
void *where) const final { memset(where, 0, GetValueSize()); }
1297 std::size_t AppendImpl(
const void *from)
final;
1298 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
1306 size_t GetValueSize() const final {
return kWordSize * ((fN + kBitsPerWord - 1) / kBitsPerWord); }
1311 std::size_t
GetN()
const {
return fN; }
1323 RVariantDeleter(std::size_t tagOffset, std::vector<std::unique_ptr<RDeleter>> &itemDeleters)
1324 : fTagOffset(tagOffset), fItemDeleters(std::move(itemDeleters))
1327 void operator()(
void *objPtr,
bool dtorOnly)
final;
1330 size_t fMaxItemSize = 0;
1331 size_t fMaxAlignment = 1;
1333 size_t fTagOffset = 0;
1336 static std::string GetTypeList(
const std::vector<RFieldBase *> &itemFields);
1338 static std::uint32_t GetTag(
const void *variantPtr, std::size_t tagOffset);
1339 static void SetTag(
void *variantPtr, std::size_t tagOffset, std::uint32_t tag);
1342 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1345 void GenerateColumnsImpl() final;
1348 void ConstructValue(
void *where) const override;
1349 std::unique_ptr<
RDeleter> GetDeleter() const final;
1351 std::
size_t AppendImpl(const
void *from) final;
1352 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1354 void CommitClusterImpl() final;
1363 size_t GetValueSize() const final;
1364 size_t GetAlignment() const final {
return fMaxAlignment; }
1370 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1373 RSetField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
1378 size_t GetAlignment()
const override {
return std::alignment_of<std::set<std::max_align_t>>(); }
1387 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1389 std::size_t AppendImpl(
const void *from)
final;
1390 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
1393 RMapField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
1398 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1400 size_t GetAlignment()
const override {
return std::alignment_of<std::map<std::max_align_t, std::max_align_t>>(); }
1419 void GenerateColumnsImpl() final;
1422 std::
size_t AppendNull();
1423 std::
size_t AppendValue(const
void *from);
1424 void CommitClusterImpl() final { fNWritten = 0; }
1430 RNullableField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
1437 bool IsDense()
const {
return GetColumnRepresentative()[0] == EColumnType::kBit; }
1439 void SetDense() { SetColumnRepresentative({EColumnType::kBit}); }
1440 void SetSparse() { SetColumnRepresentative({EColumnType::kSplitIndex32}); }
1451 explicit RUniquePtrDeleter(std::unique_ptr<RDeleter> itemDeleter) : fItemDeleter(std::move(itemDeleter)) {}
1452 void operator()(
void *objPtr,
bool dtorOnly)
final;
1458 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1460 void ConstructValue(
void *where)
const final {
new (where) std::unique_ptr<char>(); }
1461 std::unique_ptr<RDeleter> GetDeleter() const final;
1463 std::
size_t AppendImpl(const
void *from) final;
1464 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1473 size_t GetValueSize() const final {
return sizeof(std::unique_ptr<char>); }
1474 size_t GetAlignment() const final {
return alignof(std::unique_ptr<char>); }
1479 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1483 void ConstructValue(
void *where)
const final { CallConstructValueOn(*fSubFields[0], where); }
1484 std::unique_ptr<RDeleter>
GetDeleter() const final {
return GetDeleterOf(*fSubFields[0]); }
1486 std::size_t
AppendImpl(
const void *from)
final {
return CallAppendOn(*fSubFields[0], from); }
1491 RAtomicField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
1496 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1498 size_t GetValueSize() const final {
return fSubFields[0]->GetValueSize(); }
1499 size_t GetAlignment() const final {
return fSubFields[0]->GetAlignment(); }
1505template <
typename T,
typename =
void>
1510 if constexpr (std::is_default_constructible_v<T>) {
1514 new (where) T(
static_cast<TRootIOCtor *
>(
nullptr));
1521 static_assert(std::is_class_v<T>,
"no I/O support for this basic C++ type");
1528template <
typename T>
1538template <
typename T,
typename =
void>
1541template <
typename T>
1543 T, typename std::enable_if<std::is_same<typename T::IsCollectionProxy, std::true_type>::value>
::type>
1584template <
typename T,
typename =
void>
1602template <
typename T>
1605 void ConstructValue(
void *where)
const final {
new (where) T(); }
1609 RField(std::string_view
name) : RProxiedCollectionField(
name, TypeName())
1611 static_assert(std::is_class<T>::value,
"collection proxy unsupported for fundamental types");
1625 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1627 void GenerateColumnsImpl() final;
1629 void ConstructValue(
void *) const final {}
1631 std::size_t AppendImpl(
const void *from)
final;
1632 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
1634 void CommitClusterImpl() final;
1637 static std::
string TypeName() {
return ""; }
1638 RCollectionField(std::string_view
name, std::shared_ptr<RNTupleCollectionWriter> collectionWriter,
1639 std::unique_ptr<RFieldZero> collectionParent);
1657 void operator()(
void *objPtr,
bool dtorOnly)
final;
1661 static std::string
GetTypeList(
const std::array<std::unique_ptr<RFieldBase>, 2> &itemFields);
1664 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const override;
1666 void ConstructValue(
void *where)
const override;
1667 std::unique_ptr<RDeleter>
GetDeleter()
const override {
return std::make_unique<RPairDeleter>(
fClass); }
1669 RPairField(std::string_view fieldName, std::array<std::unique_ptr<RFieldBase>, 2> &&itemFields,
1670 const std::array<std::size_t, 2> &offsets);
1673 RPairField(std::string_view fieldName, std::array<std::unique_ptr<RFieldBase>, 2> &itemFields);
1688 void operator()(
void *objPtr,
bool dtorOnly)
final;
1692 static std::string
GetTypeList(
const std::vector<std::unique_ptr<RFieldBase>> &itemFields);
1695 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const override;
1697 void ConstructValue(
void *where)
const override;
1698 std::unique_ptr<RDeleter>
GetDeleter()
const override {
return std::make_unique<RTupleDeleter>(
fClass); }
1700 RTupleField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &&itemFields,
1701 const std::vector<std::size_t> &offsets);
1704 RTupleField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &itemFields);
1722 const RColumnRepresentations &GetColumnRepresentations() const final;
1724 void GenerateColumnsImpl() final {
throw RException(
R__FAIL(
"Cardinality fields must only be used for reading")); }
1755 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
1757 return std::make_unique<RField>(newName);
1761 void GenerateColumnsImpl() final;
1766 static std::string
TypeName() {
return "ROOT::Experimental::ClusterSize_t"; }
1769 fTraits |= kTraitTrivialType;
1780 return fPrincipalColumn->MapV<
ClusterSize_t>(globalIndex, nItems);
1784 return fPrincipalColumn->MapV<
ClusterSize_t>(clusterIndex, nItems);
1792 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
1796 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
1801template <
typename SizeT>
1804 std::unique_ptr<ROOT::Experimental::RFieldBase>
CloneImpl(std::string_view newName)
const final
1806 return std::make_unique<RField<RNTupleCardinality<SizeT>>>(newName);
1825 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &
size);
1834 fPrincipalColumn->GetCollectionInfo(clusterIndex, &collectionStart, &
size);
1842 fPrincipalColumn->GetCollectionInfo(bulkSpec.fFirstIndex, &collectionStart, &collectionSize);
1845 typedValues[0] = collectionSize;
1847 auto lastOffset = collectionStart.
GetIndex() + collectionSize;
1849 std::size_t nEntries = 1;
1850 while (nRemainingEntries > 0) {
1852 auto offsets = fPrincipalColumn->MapV<
ClusterSize_t>(bulkSpec.fFirstIndex + nEntries, nItemsUntilPageEnd);
1853 std::size_t nBatch = std::min(nRemainingEntries, nItemsUntilPageEnd);
1854 for (std::size_t i = 0; i < nBatch; ++i) {
1855 typedValues[nEntries + i] = offsets[i] - lastOffset;
1856 lastOffset = offsets[i];
1858 nRemainingEntries -= nBatch;
1861 return RBulkSpec::kAllSet;
1868 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
1870 return std::make_unique<RField>(newName);
1873 const RColumnRepresentations &GetColumnRepresentations() const final;
1874 void GenerateColumnsImpl() final;
1876 void ConstructValue(
void *where) const final {
new (where)
bool(
false); }
1882 fTraits |= kTraitTrivialType;
1889 return fPrincipalColumn->Map<
bool>(globalIndex);
1893 return fPrincipalColumn->MapV<
bool>(globalIndex, nItems);
1897 return fPrincipalColumn->MapV<
bool>(clusterIndex, nItems);
1908 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
1910 return std::make_unique<RField>(newName);
1913 const RColumnRepresentations &GetColumnRepresentations() const final;
1914 void GenerateColumnsImpl() final;
1916 void ConstructValue(
void *where) const final {
new (where)
float(0.0); }
1922 fTraits |= kTraitTrivialType;
1929 return fPrincipalColumn->Map<
float>(globalIndex);
1933 return fPrincipalColumn->MapV<
float>(globalIndex, nItems);
1937 return fPrincipalColumn->MapV<
float>(clusterIndex, nItems);
1944 void SetHalfPrecision();
1950 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
1952 return std::make_unique<RField>(newName);
1955 const RColumnRepresentations &GetColumnRepresentations() const final;
1956 void GenerateColumnsImpl() final;
1958 void ConstructValue(
void *where) const final {
new (where)
double(0.0); }
1964 fTraits |= kTraitTrivialType;
1971 return fPrincipalColumn->Map<
double>(globalIndex);
1973 double *
Map(
RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<
double>(clusterIndex); }
1975 return fPrincipalColumn->MapV<
double>(globalIndex, nItems);
1979 return fPrincipalColumn->MapV<
double>(clusterIndex, nItems);
1991class RField<std::
byte> final :
public RFieldBase {
1993 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
1995 return std::make_unique<RField>(newName);
1998 const RColumnRepresentations &GetColumnRepresentations() const final;
1999 void GenerateColumnsImpl() final;
2000 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2001 void ConstructValue(
void *where) const final {
new (where) std::byte{0}; }
2004 static std::string TypeName() {
return "std::byte"; }
2007 fTraits |= kTraitTrivialType;
2013 std::byte *
Map(NTupleSize_t globalIndex) {
return fPrincipalColumn->Map<std::byte>(globalIndex); }
2014 std::byte *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::byte>(clusterIndex); }
2015 std::byte *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
2017 return fPrincipalColumn->MapV<std::byte>(globalIndex, nItems);
2019 std::byte *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2021 return fPrincipalColumn->MapV<std::byte>(clusterIndex, nItems);
2024 size_t GetValueSize() const final {
return sizeof(std::byte); }
2025 size_t GetAlignment() const final {
return alignof(std::byte); }
2026 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2032 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
2034 return std::make_unique<RField>(newName);
2037 const RColumnRepresentations &GetColumnRepresentations() const final;
2038 void GenerateColumnsImpl() final;
2040 void ConstructValue(
void *where) const final {
new (where)
char(0); }
2046 fTraits |= kTraitTrivialType;
2053 return fPrincipalColumn->Map<
char>(globalIndex);
2057 return fPrincipalColumn->MapV<
char>(globalIndex, nItems);
2061 return fPrincipalColumn->MapV<
char>(clusterIndex, nItems);
2070class RField<std::int8_t> final :
public RFieldBase {
2072 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2074 return std::make_unique<RField>(newName);
2077 const RColumnRepresentations &GetColumnRepresentations() const final;
2078 void GenerateColumnsImpl() final;
2079 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2080 void ConstructValue(
void *where) const final {
new (where) int8_t(0); }
2083 static std::string TypeName() {
return "std::int8_t"; }
2086 fTraits |= kTraitTrivialType;
2092 std::int8_t *
Map(NTupleSize_t globalIndex) {
2093 return fPrincipalColumn->Map<std::int8_t>(globalIndex);
2095 std::int8_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::int8_t>(clusterIndex); }
2096 std::int8_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2097 return fPrincipalColumn->MapV<std::int8_t>(globalIndex, nItems);
2099 std::int8_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2101 return fPrincipalColumn->MapV<std::int8_t>(clusterIndex, nItems);
2104 size_t GetValueSize() const final {
return sizeof(std::int8_t); }
2105 size_t GetAlignment() const final {
return alignof(std::int8_t); }
2106 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2110class RField<std::uint8_t> final :
public RFieldBase {
2112 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2114 return std::make_unique<RField>(newName);
2117 const RColumnRepresentations &GetColumnRepresentations() const final;
2118 void GenerateColumnsImpl() final;
2119 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2120 void ConstructValue(
void *where) const final {
new (where) uint8_t(0); }
2123 static std::string TypeName() {
return "std::uint8_t"; }
2126 fTraits |= kTraitTrivialType;
2132 std::uint8_t *
Map(NTupleSize_t globalIndex) {
2133 return fPrincipalColumn->Map<std::uint8_t>(globalIndex);
2135 std::uint8_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::uint8_t>(clusterIndex); }
2136 std::uint8_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2137 return fPrincipalColumn->MapV<std::uint8_t>(globalIndex, nItems);
2139 std::uint8_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2141 return fPrincipalColumn->MapV<std::uint8_t>(clusterIndex, nItems);
2144 size_t GetValueSize() const final {
return sizeof(std::uint8_t); }
2145 size_t GetAlignment() const final {
return alignof(std::uint8_t); }
2146 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2150class RField<std::int16_t> final :
public RFieldBase {
2152 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2154 return std::make_unique<RField>(newName);
2157 const RColumnRepresentations &GetColumnRepresentations() const final;
2158 void GenerateColumnsImpl() final;
2159 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2160 void ConstructValue(
void *where) const final {
new (where) int16_t(0); }
2163 static std::string TypeName() {
return "std::int16_t"; }
2166 fTraits |= kTraitTrivialType;
2172 std::int16_t *
Map(NTupleSize_t globalIndex) {
2173 return fPrincipalColumn->Map<std::int16_t>(globalIndex);
2175 std::int16_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::int16_t>(clusterIndex); }
2176 std::int16_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2177 return fPrincipalColumn->MapV<std::int16_t>(globalIndex, nItems);
2179 std::int16_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2181 return fPrincipalColumn->MapV<std::int16_t>(clusterIndex, nItems);
2184 size_t GetValueSize() const final {
return sizeof(std::int16_t); }
2185 size_t GetAlignment() const final {
return alignof(std::int16_t); }
2186 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2190class RField<std::uint16_t> final :
public RFieldBase {
2192 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2194 return std::make_unique<RField>(newName);
2197 const RColumnRepresentations &GetColumnRepresentations() const final;
2198 void GenerateColumnsImpl() final;
2199 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2200 void ConstructValue(
void *where) const final {
new (where) int16_t(0); }
2203 static std::string TypeName() {
return "std::uint16_t"; }
2206 fTraits |= kTraitTrivialType;
2212 std::uint16_t *
Map(NTupleSize_t globalIndex) {
2213 return fPrincipalColumn->Map<std::uint16_t>(globalIndex);
2215 std::uint16_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::uint16_t>(clusterIndex); }
2216 std::uint16_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2217 return fPrincipalColumn->MapV<std::uint16_t>(globalIndex, nItems);
2219 std::uint16_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2221 return fPrincipalColumn->MapV<std::uint16_t>(clusterIndex, nItems);
2224 size_t GetValueSize() const final {
return sizeof(std::uint16_t); }
2225 size_t GetAlignment() const final {
return alignof(std::uint16_t); }
2226 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2230class RField<std::int32_t> final :
public RFieldBase {
2232 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2234 return std::make_unique<RField>(newName);
2237 const RColumnRepresentations &GetColumnRepresentations() const final;
2238 void GenerateColumnsImpl() final;
2239 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2240 void ConstructValue(
void *where) const final {
new (where) int32_t(0); }
2243 static std::string TypeName() {
return "std::int32_t"; }
2246 fTraits |= kTraitTrivialType;
2252 std::int32_t *
Map(NTupleSize_t globalIndex) {
2253 return fPrincipalColumn->Map<std::int32_t>(globalIndex);
2255 std::int32_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::int32_t>(clusterIndex); }
2256 std::int32_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2257 return fPrincipalColumn->MapV<std::int32_t>(globalIndex, nItems);
2259 std::int32_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2261 return fPrincipalColumn->MapV<std::int32_t>(clusterIndex, nItems);
2264 size_t GetValueSize() const final {
return sizeof(std::int32_t); }
2265 size_t GetAlignment() const final {
return alignof(std::int32_t); }
2266 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2270class RField<std::uint32_t> final :
public RFieldBase {
2272 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2274 return std::make_unique<RField>(newName);
2277 const RColumnRepresentations &GetColumnRepresentations() const final;
2278 void GenerateColumnsImpl() final;
2279 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2280 void ConstructValue(
void *where) const final {
new (where) uint32_t(0); }
2283 static std::string TypeName() {
return "std::uint32_t"; }
2286 fTraits |= kTraitTrivialType;
2292 std::uint32_t *
Map(NTupleSize_t globalIndex) {
2293 return fPrincipalColumn->Map<std::uint32_t>(globalIndex);
2295 std::uint32_t *
Map(
const RClusterIndex clusterIndex) {
2296 return fPrincipalColumn->Map<std::uint32_t>(clusterIndex);
2298 std::uint32_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2299 return fPrincipalColumn->MapV<std::uint32_t>(globalIndex, nItems);
2301 std::uint32_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2303 return fPrincipalColumn->MapV<std::uint32_t>(clusterIndex, nItems);
2306 size_t GetValueSize() const final {
return sizeof(std::uint32_t); }
2307 size_t GetAlignment() const final {
return alignof(std::uint32_t); }
2308 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2312class RField<std::uint64_t> final :
public RFieldBase {
2314 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2316 return std::make_unique<RField>(newName);
2319 const RColumnRepresentations &GetColumnRepresentations() const final;
2320 void GenerateColumnsImpl() final;
2321 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2322 void ConstructValue(
void *where) const final {
new (where) uint64_t(0); }
2325 static std::string TypeName() {
return "std::uint64_t"; }
2328 fTraits |= kTraitTrivialType;
2334 std::uint64_t *
Map(NTupleSize_t globalIndex) {
2335 return fPrincipalColumn->Map<std::uint64_t>(globalIndex);
2337 std::uint64_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::uint64_t>(clusterIndex); }
2338 std::uint64_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2339 return fPrincipalColumn->MapV<std::uint64_t>(globalIndex, nItems);
2341 std::uint64_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2343 return fPrincipalColumn->MapV<std::uint64_t>(clusterIndex, nItems);
2346 size_t GetValueSize() const final {
return sizeof(std::uint64_t); }
2347 size_t GetAlignment() const final {
return alignof(std::uint64_t); }
2348 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2352class RField<std::int64_t> final :
public RFieldBase {
2354 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2356 return std::make_unique<RField>(newName);
2359 const RColumnRepresentations &GetColumnRepresentations() const final;
2360 void GenerateColumnsImpl() final;
2361 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2362 void ConstructValue(
void *where) const final {
new (where) int64_t(0); }
2365 static std::string TypeName() {
return "std::int64_t"; }
2368 fTraits |= kTraitTrivialType;
2374 std::int64_t *
Map(NTupleSize_t globalIndex) {
2375 return fPrincipalColumn->Map<std::int64_t>(globalIndex);
2377 std::int64_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::int64_t>(clusterIndex); }
2378 std::int64_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2379 return fPrincipalColumn->MapV<std::int64_t>(globalIndex, nItems);
2381 std::int64_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2383 return fPrincipalColumn->MapV<std::int64_t>(clusterIndex, nItems);
2386 size_t GetValueSize() const final {
return sizeof(std::int64_t); }
2387 size_t GetAlignment() const final {
return alignof(std::int64_t); }
2388 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2392class RField<std::string> final :
public RFieldBase {
2396 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2398 return std::make_unique<RField>(newName);
2401 const RColumnRepresentations &GetColumnRepresentations() const final;
2402 void GenerateColumnsImpl() final;
2403 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2405 void ConstructValue(
void *where) const final {
new (where) std::string(); }
2406 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<std::string>>(); }
2408 std::size_t AppendImpl(
const void *from)
final;
2411 void CommitClusterImpl() final { fIndex = 0; }
2414 static std::string TypeName() {
return "std::string"; }
2423 size_t GetValueSize() const final {
return sizeof(std::string); }
2424 size_t GetAlignment() const final {
return std::alignment_of<std::string>(); }
2425 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2431 static std::size_t GetOffsetOfMember(
const char *
name);
2436 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
2440 void ConstructValue(
void *where)
const override;
2441 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RTypedDeleter<TObject>>(); }
2443 std::size_t AppendImpl(
const void *from)
final;
2444 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
2446 void OnConnectPageSource() final;
2449 static std::
string TypeName() {
return "TObject"; }
2451 RField(std::string_view fieldName);
2456 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
2457 size_t GetValueSize() const final;
2458 size_t GetAlignment() const final;
2459 std::uint32_t GetTypeVersion() const final;
2460 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
2463template <typename ItemT, std::
size_t N>
2465 using ContainerT =
typename std::array<ItemT, N>;
2468 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2471 static std::string TypeName() {
2481template <
typename ItemT, std::
size_t N>
2490template <
typename ItemT>
2492 using ContainerT =
typename std::set<ItemT>;
2495 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2496 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2501 explicit RField(std::string_view
name) : RSetField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
2506 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2507 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2510template <
typename ItemT>
2511class RField<std::unordered_set<ItemT>> final :
public RSetField {
2512 using ContainerT =
typename std::unordered_set<ItemT>;
2515 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2516 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2521 explicit RField(std::string_view
name) : RSetField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
2526 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2527 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2530template <
typename KeyT,
typename ValueT>
2531class RField<std::map<KeyT, ValueT>> final :
public RMapField {
2532 using ContainerT =
typename std::map<KeyT, ValueT>;
2535 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2536 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2539 static std::string TypeName()
2545 : RMapField(
name, TypeName(), std::make_unique<
RField<std::pair<KeyT, ValueT>>>(
"_0"))
2552 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2553 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2556template <
typename KeyT,
typename ValueT>
2557class RField<std::unordered_map<KeyT, ValueT>> final :
public RMapField {
2558 using ContainerT =
typename std::unordered_map<KeyT, ValueT>;
2561 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2562 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2565 static std::string TypeName()
2571 : RMapField(
name, TypeName(), std::make_unique<
RField<std::pair<KeyT, ValueT>>>(
"_0"))
2578 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2579 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2582template <
typename... ItemTs>
2583class RField<std::variant<ItemTs...>> final :
public RVariantField {
2584 using ContainerT =
typename std::variant<ItemTs...>;
2586 template <
typename HeadT,
typename... TailTs>
2587 static std::string BuildItemTypes()
2590 if constexpr(
sizeof...(TailTs) > 0)
2591 result +=
"," + BuildItemTypes<TailTs...>();
2595 template <
typename HeadT,
typename... TailTs>
2596 static std::vector<RFieldBase *> BuildItemFields(
unsigned int index = 0)
2598 std::vector<RFieldBase *>
result;
2600 if constexpr(
sizeof...(TailTs) > 0) {
2601 auto tailFields = BuildItemFields<TailTs...>(
index + 1);
2602 result.insert(
result.end(), tailFields.begin(), tailFields.end());
2608 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2611 static std::string TypeName() {
return "std::variant<" + BuildItemTypes<ItemTs...>() +
">"; }
2612 explicit RField(std::string_view
name) : RVariantField(
name, BuildItemFields<ItemTs...>()) {}
2618template <
typename ItemT>
2619class RField<std::vector<ItemT>> final :
public RVectorField {
2620 using ContainerT =
typename std::vector<ItemT>;
2623 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2628 : RVectorField(
name, std::make_unique<
RField<ItemT>>(
"_0"))
2634 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2639class RField<std::vector<bool>> final :
public RFieldBase {
2644 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2646 return std::make_unique<RField>(newName);
2649 const RColumnRepresentations &GetColumnRepresentations() const final;
2650 void GenerateColumnsImpl() final;
2651 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2653 void ConstructValue(
void *where) const final {
new (where) std::vector<bool>(); }
2654 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<std::vector<bool>>>(); }
2656 std::size_t AppendImpl(
const void *from)
final;
2657 void ReadGlobalImpl(NTupleSize_t globalIndex,
void *to)
final;
2659 void CommitClusterImpl() final { fNWritten = 0; }
2662 static std::string TypeName() {
return "std::vector<bool>"; }
2668 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
2670 size_t GetValueSize() const final {
return sizeof(std::vector<bool>); }
2671 size_t GetAlignment() const final {
return std::alignment_of<std::vector<bool>>(); }
2672 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2673 void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *
size)
const {
2674 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
2676 void GetCollectionInfo(RClusterIndex clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *
size)
const
2678 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
2682template <
typename ItemT>
2686 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
2688 auto newItemField = fSubFields[0]->Clone(fSubFields[0]->GetFieldName());
2689 return std::make_unique<RField<ROOT::VecOps::RVec<ItemT>>>(newName, std::move(newItemField));
2693 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2697 auto typedValue =
static_cast<const ContainerT *
>(from);
2699 auto count = typedValue->size();
2700 for (
unsigned i = 0; i < count; ++i) {
2701 nbytes += CallAppendOn(*fSubFields[0], &typedValue->data()[i]);
2703 this->fNWritten += count;
2704 fColumns[0]->Append(&this->fNWritten);
2705 return nbytes + fColumns[0]->GetElement()->GetPackedSize();
2709 auto typedValue =
static_cast<ContainerT *
>(to);
2712 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &nItems);
2713 typedValue->resize(nItems);
2714 for (
unsigned i = 0; i < nItems; ++i) {
2715 CallReadOn(*fSubFields[0], collectionStart + i, &typedValue->data()[i]);
2720 RField(std::string_view fieldName, std::unique_ptr<RFieldBase> itemField)
2721 :
RRVecField(fieldName, std::move(itemField))
2736 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2739template <
typename T1,
typename T2>
2740class RField<std::pair<T1, T2>> final :
public RPairField {
2741 using ContainerT =
typename std::pair<T1,T2>;
2743 template <
typename Ty1,
typename Ty2>
2744 static std::array<std::unique_ptr<RFieldBase>, 2> BuildItemFields()
2746 return {std::make_unique<RField<Ty1>>(
"_0"), std::make_unique<
RField<Ty2>>(
"_1")};
2749 static std::array<std::size_t, 2> BuildItemOffsets()
2751 auto pair = ContainerT();
2752 auto offsetFirst =
reinterpret_cast<std::uintptr_t
>(&(pair.first)) -
reinterpret_cast<std::uintptr_t
>(&pair);
2753 auto offsetSecond =
reinterpret_cast<std::uintptr_t
>(&(pair.second)) -
reinterpret_cast<std::uintptr_t
>(&pair);
2754 return {offsetFirst, offsetSecond};
2758 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2760 std::array<std::unique_ptr<RFieldBase>, 2> items{fSubFields[0]->Clone(fSubFields[0]->GetFieldName()),
2761 fSubFields[1]->Clone(fSubFields[1]->GetFieldName())};
2762 return std::make_unique<RField<std::pair<T1, T2>>>(newName, std::move(items));
2765 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2766 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2769 static std::string TypeName() {
2772 explicit RField(std::string_view
name, std::array<std::unique_ptr<RFieldBase>, 2> &&itemFields)
2773 : RPairField(
name, std::move(itemFields), BuildItemOffsets())
2775 fMaxAlignment = std::max(
alignof(
T1),
alignof(
T2));
2776 fSize =
sizeof(ContainerT);
2784template <
typename... ItemTs>
2785class RField<std::tuple<ItemTs...>> final :
public RTupleField {
2786 using ContainerT =
typename std::tuple<ItemTs...>;
2788 template <
typename HeadT,
typename... TailTs>
2789 static std::string BuildItemTypes()
2792 if constexpr (
sizeof...(TailTs) > 0)
2793 result +=
"," + BuildItemTypes<TailTs...>();
2797 template <
typename HeadT,
typename... TailTs>
2798 static void _BuildItemFields(std::vector<std::unique_ptr<RFieldBase>> &itemFields,
unsigned int index = 0)
2801 if constexpr (
sizeof...(TailTs) > 0)
2802 _BuildItemFields<TailTs...>(itemFields,
index + 1);
2804 template <
typename... Ts>
2805 static std::vector<std::unique_ptr<RFieldBase>> BuildItemFields()
2807 std::vector<std::unique_ptr<RFieldBase>>
result;
2808 _BuildItemFields<Ts...>(
result);
2812 template <
unsigned Index,
typename HeadT,
typename... TailTs>
2813 static void _BuildItemOffsets(std::vector<std::size_t> &offsets,
const ContainerT &tuple)
2816 reinterpret_cast<std::uintptr_t
>(&std::get<Index>(tuple)) -
reinterpret_cast<std::uintptr_t
>(&tuple);
2817 offsets.emplace_back(
offset);
2818 if constexpr (
sizeof...(TailTs) > 0)
2819 _BuildItemOffsets<
Index + 1, TailTs...>(offsets, tuple);
2821 template <
typename... Ts>
2822 static std::vector<std::size_t> BuildItemOffsets()
2824 std::vector<std::size_t>
result;
2825 _BuildItemOffsets<0, Ts...>(
result, ContainerT());
2830 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2832 std::vector<std::unique_ptr<RFieldBase>> items;
2833 for (
auto &item : fSubFields)
2834 items.push_back(item->Clone(item->GetFieldName()));
2835 return std::make_unique<
RField<std::tuple<ItemTs...>>>(newName, std::move(items));
2838 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2839 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2842 static std::string TypeName() {
return "std::tuple<" + BuildItemTypes<ItemTs...>() +
">"; }
2843 explicit RField(std::string_view
name, std::vector<std::unique_ptr<RFieldBase>> &&itemFields)
2844 : RTupleField(
name, std::move(itemFields), BuildItemOffsets<ItemTs...>())
2846 fMaxAlignment = std::max({
alignof(ItemTs)...});
2847 fSize =
sizeof(ContainerT);
2855template <std::
size_t N>
2856class RField<std::bitset<N>> final :
public RBitsetField {
2858 static std::string TypeName() {
return "std::bitset<" + std::to_string(
N) +
">"; }
2865template <
typename ItemT>
2866class RField<std::unique_ptr<ItemT>> final :
public RUniquePtrField {
2869 explicit RField(std::string_view
name) : RUniquePtrField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
2875template <
typename ItemT>
2876class RField<std::atomic<ItemT>> final :
public RAtomicField {
2879 explicit RField(std::string_view
name) : RAtomicField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
2888template <
typename T>
2889std::unique_ptr<T, typename RFieldBase::RCreateObjectDeleter<T>::deleter> RFieldBase::CreateObject()
const
2895 return std::unique_ptr<T>(
static_cast<T *
>(CreateObjectRawPtr()));
2905std::unique_ptr<void, typename RFieldBase::RCreateObjectDeleter<void>::deleter>
2906ROOT::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...
std::unique_ptr< RDeleter > GetDeleter() const final
static std::size_t GetOffsetUniqueID()
RField(RField &&other)=default
static std::size_t GetOffsetBits()
void GenerateColumnsImpl(const RNTupleDescriptor &) final
Creates the backing columns corresponsing to the field type for reading.
~RField() override=default
RField & operator=(RField &&other)=default
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
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.
Mother of all ROOT objects.
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