58namespace Experimental {
60class RCollectionField;
61class RNTupleCollectionWriter;
65struct RFieldCallbackInjector;
112 operator delete(objPtr);
117 template <
typename T>
122 std::destroy_at(
static_cast<T *
>(objPtr));
209 template <
typename T>
212 return std::static_pointer_cast<T>(
fObjPtr);
215 template <
typename T>
218 return *
static_cast<T *
>(
fObjPtr.get());
375 static const std::size_t
kAllSet = std::size_t(-1);
398 std::vector<std::unique_ptr<Internal::RColumn>>
fColumns;
429 virtual std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const = 0;
433 virtual std::unique_ptr<RDeleter>
GetDeleter()
const {
return std::make_unique<RDeleter>(); }
440 virtual std::size_t
AppendImpl(
const void *from);
490 virtual std::size_t
ReadBulkImpl(
const RBulkSpec &bulkSpec);
536 Create(
const std::string &fieldName,
const std::string &canonicalType,
const std::string &typeAlias);
540 template <
bool IsConstT>
544 using FieldPtr_t = std::conditional_t<IsConstT, const RFieldBase *, RFieldBase *>;
556 using value_type = std::conditional_t<IsConstT, const RFieldBase, RFieldBase>;
557 using pointer = std::conditional_t<IsConstT, const RFieldBase *, RFieldBase *>;
558 using reference = std::conditional_t<IsConstT, const RFieldBase &, RFieldBase &>;
567 auto itr =
fStack.rbegin();
568 if (!itr->fFieldPtr->fSubFields.empty()) {
569 fStack.emplace_back(
Position(itr->fFieldPtr->fSubFields[0].get(), 0));
573 unsigned int nextIdxInParent = ++(itr->fIdxInParent);
574 while (nextIdxInParent >= itr->fFieldPtr->fParent->fSubFields.size()) {
576 itr->fFieldPtr = itr->fFieldPtr->fParent;
577 itr->fIdxInParent = -1;
582 nextIdxInParent = ++(itr->fIdxInParent);
584 itr->fFieldPtr = itr->fFieldPtr->fParent->fSubFields[nextIdxInParent].get();
598 template <
typename T>
607 std::size_t nRepetitions = 0);
615 std::unique_ptr<RFieldBase>
Clone(std::string_view newName)
const;
619 Create(
const std::string &fieldName,
const std::string &typeName);
632 template <
typename T>
633 std::unique_ptr<T, typename RCreateObjectDeleter<T>::deleter>
CreateObject()
const;
707 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const override;
742 void operator()(
void *objPtr,
bool dtorOnly)
final;
751 RClassField(std::string_view fieldName, std::string_view className,
TClass *classp);
758 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final;
763 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RClassDeleter>(
fClass); }
765 std::size_t
AppendImpl(
const void *from)
final;
771 RClassField(std::string_view fieldName, std::string_view className);
780 void AcceptVisitor(Detail::RFieldVisitor &visitor) const override;
786 REnumField(std::string_view fieldName, std::string_view enumName,
TEnum *enump);
787 REnumField(std::string_view fieldName, std::string_view enumName, std::unique_ptr<RFieldBase> intField);
790 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final;
801 REnumField(std::string_view fieldName, std::string_view enumName);
837 void *fIterator =
nullptr;
838 void *fElementPtr =
nullptr;
842 auto fnNext_Contig = [&]() {
845 auto &iter =
reinterpret_cast<unsigned char *&
>(fIterator),
p = iter;
874 void *fBegin = &fBeginSmallBuf;
875 void *fEnd = &fEndSmallBuf;
881 std::size_t stride = 0U)
882 : fIFuncs(ifuncs), fStride(stride)
894 std::shared_ptr<TVirtualCollectionProxy>
fProxy;
896 std::size_t fItemSize = 0;
903 : fProxy(proxy), fItemDeleter(std::move(itemDeleter)), fItemSize(itemSize)
905 fIFuncsWrite = RCollectionIterableOnce::GetIteratorFuncs(fProxy.get(),
false );
907 void operator()(
void *objPtr,
bool dtorOnly)
final;
911 std::shared_ptr<TVirtualCollectionProxy>
fProxy;
926 std::unique_ptr<RFieldBase> itemField);
929 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const override;
931 void GenerateColumnsImpl() final;
934 void ConstructValue(
void *where) const override;
935 std::unique_ptr<
RDeleter> GetDeleter() const override;
937 std::
size_t AppendImpl(const
void *from) override;
938 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) override;
940 void CommitClusterImpl() final { fNWritten = 0; }
948 std::vector<RValue> SplitValue(
const RValue &
value)
const override;
950 size_t GetAlignment()
const override {
return alignof(std::max_align_t); }
954 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
958 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
972 RRecordDeleter(std::vector<std::unique_ptr<RDeleter>> &itemDeleters,
const std::vector<std::size_t> &offsets)
973 : fItemDeleters(std::move(itemDeleters)), fOffsets(offsets)
976 void operator()(
void *objPtr,
bool dtorOnly)
final;
980 std::size_t fMaxAlignment = 1;
984 std::size_t GetItemPadding(std::size_t baseOffset, std::size_t itemAlignment)
const;
986 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const override;
991 void ConstructValue(
void *where)
const override;
992 std::unique_ptr<RDeleter> GetDeleter()
const override;
994 std::size_t AppendImpl(
const void *from)
final;
995 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
996 void ReadInClusterImpl(
RClusterIndex clusterIndex,
void *to)
final;
998 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &&itemFields,
999 const std::vector<std::size_t> &offsets, std::string_view typeName =
"");
1001 template <std::
size_t N>
1002 RRecordField(std::string_view fieldName, std::array<std::unique_ptr<RFieldBase>,
N> &&itemFields,
1003 const std::array<std::size_t, N> &offsets, std::string_view typeName =
"")
1006 fTraits |= kTraitTrivialType;
1007 for (
unsigned i = 0; i <
N; ++i) {
1008 fOffsets.push_back(offsets[i]);
1009 fMaxAlignment = std::max(fMaxAlignment, itemFields[i]->GetAlignment());
1010 fSize += GetItemPadding(
fSize, itemFields[i]->GetAlignment()) + itemFields[i]->GetValueSize();
1011 fTraits &= itemFields[i]->GetTraits();
1012 Attach(std::move(itemFields[i]));
1018 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &&itemFields);
1019 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &itemFields);
1024 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1035 std::size_t fItemSize = 0;
1041 : fItemSize(itemSize), fItemDeleter(std::move(itemDeleter))
1044 void operator()(
void *objPtr,
bool dtorOnly)
final;
1052 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1055 void GenerateColumnsImpl() final;
1058 void ConstructValue(
void *where)
const override {
new (where) std::vector<char>(); }
1059 std::unique_ptr<RDeleter> GetDeleter() const final;
1061 std::
size_t AppendImpl(const
void *from) final;
1062 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1064 void CommitClusterImpl() final { fNWritten = 0; }
1067 RVectorField(std::string_view fieldName, std::unique_ptr<RFieldBase> itemField);
1072 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1074 size_t GetAlignment() const final {
return std::alignment_of<std::vector<char>>(); }
1077 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
1081 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
1092 std::size_t fItemSize = 0;
1096 explicit RRVecDeleter(std::size_t itemAlignment) : fItemAlignment(itemAlignment) {}
1097 RRVecDeleter(std::size_t itemAlignment, std::size_t itemSize, std::unique_ptr<RDeleter> itemDeleter)
1098 : fItemAlignment(itemAlignment), fItemSize(itemSize), fItemDeleter(std::move(itemDeleter))
1101 void operator()(
void *objPtr,
bool dtorOnly)
final;
1111 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const override;
1113 void GenerateColumnsImpl() final;
1116 void ConstructValue(
void *where) const override;
1117 std::unique_ptr<
RDeleter> GetDeleter() const override;
1119 std::
size_t AppendImpl(const
void *from) override;
1120 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) override;
1121 std::
size_t ReadBulkImpl(const
RBulkSpec &bulkSpec) final;
1123 void CommitClusterImpl() final { fNWritten = 0; }
1126 RRVecField(std::string_view fieldName, std::unique_ptr<RFieldBase> itemField);
1133 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1134 size_t GetValueSize()
const override;
1135 size_t GetAlignment()
const override;
1139 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
1143 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
1152 std::size_t fItemSize = 0;
1153 std::size_t fArrayLength = 0;
1157 RArrayDeleter(std::size_t itemSize, std::size_t arrayLength, std::unique_ptr<RDeleter> itemDeleter)
1158 : fItemSize(itemSize), fArrayLength(arrayLength), fItemDeleter(std::move(itemDeleter))
1161 void operator()(
void *objPtr,
bool dtorOnly)
final;
1168 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1173 void ConstructValue(
void *where)
const override;
1174 std::unique_ptr<RDeleter> GetDeleter() const final;
1176 std::
size_t AppendImpl(const
void *from) final;
1177 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1178 void ReadInClusterImpl(
RClusterIndex clusterIndex,
void *to) final;
1181 RArrayField(std::string_view fieldName, std::unique_ptr<
RFieldBase> itemField, std::
size_t arrayLength);
1187 size_t GetLength()
const {
return fArrayLength; }
1189 size_t GetAlignment() const final {
return fSubFields[0]->GetAlignment(); }
1208 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1213 void ConstructValue(
void *where)
const final;
1215 std::unique_ptr<RDeleter> GetDeleter() const final;
1217 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1218 void ReadInClusterImpl(
RClusterIndex clusterIndex,
void *to) final;
1234 std::size_t GetAlignment() const final;
1237 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
1245 static constexpr std::size_t kWordSize =
sizeof(
Word_t);
1246 static constexpr std::size_t kBitsPerWord = kWordSize * 8;
1252 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
1254 return std::make_unique<RBitsetField>(newName, fN);
1256 const RColumnRepresentations &GetColumnRepresentations() const final;
1257 void GenerateColumnsImpl() final;
1259 void ConstructValue(
void *where) const final { memset(where, 0, GetValueSize()); }
1260 std::size_t AppendImpl(
const void *from)
final;
1261 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
1269 size_t GetValueSize() const final {
return kWordSize * ((fN + kBitsPerWord - 1) / kBitsPerWord); }
1274 std::size_t
GetN()
const {
return fN; }
1286 RVariantDeleter(std::size_t tagOffset, std::vector<std::unique_ptr<RDeleter>> &itemDeleters)
1287 : fTagOffset(tagOffset), fItemDeleters(std::move(itemDeleters))
1290 void operator()(
void *objPtr,
bool dtorOnly)
final;
1293 size_t fMaxItemSize = 0;
1294 size_t fMaxAlignment = 1;
1296 size_t fTagOffset = 0;
1299 static std::string GetTypeList(
const std::vector<RFieldBase *> &itemFields);
1301 static std::uint32_t GetTag(
const void *variantPtr, std::size_t tagOffset);
1302 static void SetTag(
void *variantPtr, std::size_t tagOffset, std::uint32_t tag);
1305 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1308 void GenerateColumnsImpl() final;
1311 void ConstructValue(
void *where) const override;
1312 std::unique_ptr<
RDeleter> GetDeleter() const final;
1314 std::
size_t AppendImpl(const
void *from) final;
1315 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1317 void CommitClusterImpl() final;
1326 size_t GetValueSize() const final;
1327 size_t GetAlignment() const final {
return fMaxAlignment; }
1333 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1336 RSetField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
1341 size_t GetAlignment()
const override {
return std::alignment_of<std::set<std::max_align_t>>(); }
1350 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1352 std::size_t AppendImpl(
const void *from)
final;
1353 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
1356 RMapField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
1361 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1363 size_t GetAlignment()
const override {
return std::alignment_of<std::map<std::max_align_t, std::max_align_t>>(); }
1382 void GenerateColumnsImpl() final;
1385 std::
size_t AppendNull();
1386 std::
size_t AppendValue(const
void *from);
1387 void CommitClusterImpl() final { fNWritten = 0; }
1393 RNullableField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
1400 bool IsDense()
const {
return GetColumnRepresentative()[0] == EColumnType::kBit; }
1402 void SetDense() { SetColumnRepresentative({EColumnType::kBit}); }
1403 void SetSparse() { SetColumnRepresentative({EColumnType::kSplitIndex32}); }
1414 explicit RUniquePtrDeleter(std::unique_ptr<RDeleter> itemDeleter) : fItemDeleter(std::move(itemDeleter)) {}
1415 void operator()(
void *objPtr,
bool dtorOnly)
final;
1421 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1423 void ConstructValue(
void *where)
const final {
new (where) std::unique_ptr<char>(); }
1424 std::unique_ptr<RDeleter> GetDeleter() const final;
1426 std::
size_t AppendImpl(const
void *from) final;
1427 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1436 size_t GetValueSize() const final {
return sizeof(std::unique_ptr<char>); }
1437 size_t GetAlignment() const final {
return alignof(std::unique_ptr<char>); }
1442 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1446 void ConstructValue(
void *where)
const final { CallConstructValueOn(*fSubFields[0], where); }
1447 std::unique_ptr<RDeleter>
GetDeleter() const final {
return GetDeleterOf(*fSubFields[0]); }
1449 std::size_t
AppendImpl(
const void *from)
final {
return CallAppendOn(*fSubFields[0], from); }
1454 RAtomicField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
1459 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1461 size_t GetValueSize() const final {
return fSubFields[0]->GetValueSize(); }
1462 size_t GetAlignment() const final {
return fSubFields[0]->GetAlignment(); }
1468template <
typename T,
typename =
void>
1473 if constexpr (std::is_default_constructible_v<T>) {
1477 new (where) T(
static_cast<TRootIOCtor *
>(
nullptr));
1484 static_assert(std::is_class_v<T>,
"no I/O support for this basic C++ type");
1491template <
typename T>
1501template <
typename T,
typename =
void>
1504template <
typename T>
1506 T, typename std::enable_if<std::is_same<typename T::IsCollectionProxy, std::true_type>::value>
::type>
1547template <
typename T,
typename =
void>
1565template <
typename T>
1568 void ConstructValue(
void *where)
const final {
new (where) T(); }
1572 RField(std::string_view
name) : RProxiedCollectionField(
name, TypeName())
1574 static_assert(std::is_class<T>::value,
"collection proxy unsupported for fundamental types");
1588 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
1590 void GenerateColumnsImpl() final;
1592 void ConstructValue(
void *) const final {}
1594 std::size_t AppendImpl(
const void *from)
final;
1595 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
1597 void CommitClusterImpl() final;
1600 static std::
string TypeName() {
return ""; }
1601 RCollectionField(std::string_view
name, std::shared_ptr<RNTupleCollectionWriter> collectionWriter,
1602 std::unique_ptr<RFieldZero> collectionParent);
1620 void operator()(
void *objPtr,
bool dtorOnly)
final;
1624 static std::string
GetTypeList(
const std::array<std::unique_ptr<RFieldBase>, 2> &itemFields);
1627 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const override;
1629 void ConstructValue(
void *where)
const override;
1630 std::unique_ptr<RDeleter>
GetDeleter()
const override {
return std::make_unique<RPairDeleter>(
fClass); }
1632 RPairField(std::string_view fieldName, std::array<std::unique_ptr<RFieldBase>, 2> &&itemFields,
1633 const std::array<std::size_t, 2> &offsets);
1636 RPairField(std::string_view fieldName, std::array<std::unique_ptr<RFieldBase>, 2> &itemFields);
1651 void operator()(
void *objPtr,
bool dtorOnly)
final;
1655 static std::string
GetTypeList(
const std::vector<std::unique_ptr<RFieldBase>> &itemFields);
1658 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const override;
1660 void ConstructValue(
void *where)
const override;
1661 std::unique_ptr<RDeleter>
GetDeleter()
const override {
return std::make_unique<RTupleDeleter>(
fClass); }
1663 RTupleField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &&itemFields,
1664 const std::vector<std::size_t> &offsets);
1667 RTupleField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &itemFields);
1685 const RColumnRepresentations &GetColumnRepresentations() const final;
1687 void GenerateColumnsImpl() final {
throw RException(
R__FAIL(
"Cardinality fields must only be used for reading")); }
1718 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
1720 return std::make_unique<RField>(newName);
1724 void GenerateColumnsImpl() final;
1729 static std::string
TypeName() {
return "ROOT::Experimental::ClusterSize_t"; }
1732 fTraits |= kTraitTrivialType;
1743 return fPrincipalColumn->MapV<
ClusterSize_t>(globalIndex, nItems);
1747 return fPrincipalColumn->MapV<
ClusterSize_t>(clusterIndex, nItems);
1755 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
1759 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
1764template <
typename SizeT>
1767 std::unique_ptr<ROOT::Experimental::RFieldBase>
CloneImpl(std::string_view newName)
const final
1769 return std::make_unique<RField<RNTupleCardinality<SizeT>>>(newName);
1788 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &
size);
1797 fPrincipalColumn->GetCollectionInfo(clusterIndex, &collectionStart, &
size);
1805 fPrincipalColumn->GetCollectionInfo(bulkSpec.fFirstIndex, &collectionStart, &collectionSize);
1808 typedValues[0] = collectionSize;
1810 auto lastOffset = collectionStart.
GetIndex() + collectionSize;
1812 std::size_t nEntries = 1;
1813 while (nRemainingEntries > 0) {
1815 auto offsets = fPrincipalColumn->MapV<
ClusterSize_t>(bulkSpec.fFirstIndex + nEntries, nItemsUntilPageEnd);
1816 std::size_t nBatch = std::min(nRemainingEntries, nItemsUntilPageEnd);
1817 for (std::size_t i = 0; i < nBatch; ++i) {
1818 typedValues[nEntries + i] = offsets[i] - lastOffset;
1819 lastOffset = offsets[i];
1821 nRemainingEntries -= nBatch;
1824 return RBulkSpec::kAllSet;
1831 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
1833 return std::make_unique<RField>(newName);
1836 const RColumnRepresentations &GetColumnRepresentations() const final;
1837 void GenerateColumnsImpl() final;
1839 void ConstructValue(
void *where) const final {
new (where)
bool(
false); }
1845 fTraits |= kTraitTrivialType;
1852 return fPrincipalColumn->Map<
bool>(globalIndex);
1856 return fPrincipalColumn->MapV<
bool>(globalIndex, nItems);
1860 return fPrincipalColumn->MapV<
bool>(clusterIndex, nItems);
1871 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
1873 return std::make_unique<RField>(newName);
1876 const RColumnRepresentations &GetColumnRepresentations() const final;
1877 void GenerateColumnsImpl() final;
1879 void ConstructValue(
void *where) const final {
new (where)
float(0.0); }
1885 fTraits |= kTraitTrivialType;
1892 return fPrincipalColumn->Map<
float>(globalIndex);
1896 return fPrincipalColumn->MapV<
float>(globalIndex, nItems);
1900 return fPrincipalColumn->MapV<
float>(clusterIndex, nItems);
1907 void SetHalfPrecision();
1913 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
1915 return std::make_unique<RField>(newName);
1918 const RColumnRepresentations &GetColumnRepresentations() const final;
1919 void GenerateColumnsImpl() final;
1921 void ConstructValue(
void *where) const final {
new (where)
double(0.0); }
1927 fTraits |= kTraitTrivialType;
1934 return fPrincipalColumn->Map<
double>(globalIndex);
1936 double *
Map(
RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<
double>(clusterIndex); }
1938 return fPrincipalColumn->MapV<
double>(globalIndex, nItems);
1942 return fPrincipalColumn->MapV<
double>(clusterIndex, nItems);
1954class RField<std::
byte> final :
public RFieldBase {
1956 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
1958 return std::make_unique<RField>(newName);
1961 const RColumnRepresentations &GetColumnRepresentations() const final;
1962 void GenerateColumnsImpl() final;
1963 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
1964 void ConstructValue(
void *where) const final {
new (where) std::byte{0}; }
1967 static std::string TypeName() {
return "std::byte"; }
1970 fTraits |= kTraitTrivialType;
1976 std::byte *
Map(NTupleSize_t globalIndex) {
return fPrincipalColumn->Map<std::byte>(globalIndex); }
1977 std::byte *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::byte>(clusterIndex); }
1978 std::byte *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
1980 return fPrincipalColumn->MapV<std::byte>(globalIndex, nItems);
1982 std::byte *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
1984 return fPrincipalColumn->MapV<std::byte>(clusterIndex, nItems);
1987 size_t GetValueSize() const final {
return sizeof(std::byte); }
1988 size_t GetAlignment() const final {
return alignof(std::byte); }
1989 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
1995 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
1997 return std::make_unique<RField>(newName);
2000 const RColumnRepresentations &GetColumnRepresentations() const final;
2001 void GenerateColumnsImpl() final;
2003 void ConstructValue(
void *where) const final {
new (where)
char(0); }
2009 fTraits |= kTraitTrivialType;
2016 return fPrincipalColumn->Map<
char>(globalIndex);
2020 return fPrincipalColumn->MapV<
char>(globalIndex, nItems);
2024 return fPrincipalColumn->MapV<
char>(clusterIndex, nItems);
2033class RField<std::int8_t> final :
public RFieldBase {
2035 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2037 return std::make_unique<RField>(newName);
2040 const RColumnRepresentations &GetColumnRepresentations() const final;
2041 void GenerateColumnsImpl() final;
2042 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2043 void ConstructValue(
void *where) const final {
new (where) int8_t(0); }
2046 static std::string TypeName() {
return "std::int8_t"; }
2049 fTraits |= kTraitTrivialType;
2055 std::int8_t *
Map(NTupleSize_t globalIndex) {
2056 return fPrincipalColumn->Map<std::int8_t>(globalIndex);
2058 std::int8_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::int8_t>(clusterIndex); }
2059 std::int8_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2060 return fPrincipalColumn->MapV<std::int8_t>(globalIndex, nItems);
2062 std::int8_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2064 return fPrincipalColumn->MapV<std::int8_t>(clusterIndex, nItems);
2067 size_t GetValueSize() const final {
return sizeof(std::int8_t); }
2068 size_t GetAlignment() const final {
return alignof(std::int8_t); }
2069 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2073class RField<std::uint8_t> final :
public RFieldBase {
2075 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2077 return std::make_unique<RField>(newName);
2080 const RColumnRepresentations &GetColumnRepresentations() const final;
2081 void GenerateColumnsImpl() final;
2082 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2083 void ConstructValue(
void *where) const final {
new (where) uint8_t(0); }
2086 static std::string TypeName() {
return "std::uint8_t"; }
2089 fTraits |= kTraitTrivialType;
2095 std::uint8_t *
Map(NTupleSize_t globalIndex) {
2096 return fPrincipalColumn->Map<std::uint8_t>(globalIndex);
2098 std::uint8_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::uint8_t>(clusterIndex); }
2099 std::uint8_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2100 return fPrincipalColumn->MapV<std::uint8_t>(globalIndex, nItems);
2102 std::uint8_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2104 return fPrincipalColumn->MapV<std::uint8_t>(clusterIndex, nItems);
2107 size_t GetValueSize() const final {
return sizeof(std::uint8_t); }
2108 size_t GetAlignment() const final {
return alignof(std::uint8_t); }
2109 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2113class RField<std::int16_t> final :
public RFieldBase {
2115 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2117 return std::make_unique<RField>(newName);
2120 const RColumnRepresentations &GetColumnRepresentations() const final;
2121 void GenerateColumnsImpl() final;
2122 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2123 void ConstructValue(
void *where) const final {
new (where) int16_t(0); }
2126 static std::string TypeName() {
return "std::int16_t"; }
2129 fTraits |= kTraitTrivialType;
2135 std::int16_t *
Map(NTupleSize_t globalIndex) {
2136 return fPrincipalColumn->Map<std::int16_t>(globalIndex);
2138 std::int16_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::int16_t>(clusterIndex); }
2139 std::int16_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2140 return fPrincipalColumn->MapV<std::int16_t>(globalIndex, nItems);
2142 std::int16_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2144 return fPrincipalColumn->MapV<std::int16_t>(clusterIndex, nItems);
2147 size_t GetValueSize() const final {
return sizeof(std::int16_t); }
2148 size_t GetAlignment() const final {
return alignof(std::int16_t); }
2149 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2153class RField<std::uint16_t> final :
public RFieldBase {
2155 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2157 return std::make_unique<RField>(newName);
2160 const RColumnRepresentations &GetColumnRepresentations() const final;
2161 void GenerateColumnsImpl() final;
2162 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2163 void ConstructValue(
void *where) const final {
new (where) int16_t(0); }
2166 static std::string TypeName() {
return "std::uint16_t"; }
2169 fTraits |= kTraitTrivialType;
2175 std::uint16_t *
Map(NTupleSize_t globalIndex) {
2176 return fPrincipalColumn->Map<std::uint16_t>(globalIndex);
2178 std::uint16_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::uint16_t>(clusterIndex); }
2179 std::uint16_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2180 return fPrincipalColumn->MapV<std::uint16_t>(globalIndex, nItems);
2182 std::uint16_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2184 return fPrincipalColumn->MapV<std::uint16_t>(clusterIndex, nItems);
2187 size_t GetValueSize() const final {
return sizeof(std::uint16_t); }
2188 size_t GetAlignment() const final {
return alignof(std::uint16_t); }
2189 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2193class RField<std::int32_t> final :
public RFieldBase {
2195 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2197 return std::make_unique<RField>(newName);
2200 const RColumnRepresentations &GetColumnRepresentations() const final;
2201 void GenerateColumnsImpl() final;
2202 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2203 void ConstructValue(
void *where) const final {
new (where) int32_t(0); }
2206 static std::string TypeName() {
return "std::int32_t"; }
2209 fTraits |= kTraitTrivialType;
2215 std::int32_t *
Map(NTupleSize_t globalIndex) {
2216 return fPrincipalColumn->Map<std::int32_t>(globalIndex);
2218 std::int32_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::int32_t>(clusterIndex); }
2219 std::int32_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2220 return fPrincipalColumn->MapV<std::int32_t>(globalIndex, nItems);
2222 std::int32_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2224 return fPrincipalColumn->MapV<std::int32_t>(clusterIndex, nItems);
2227 size_t GetValueSize() const final {
return sizeof(std::int32_t); }
2228 size_t GetAlignment() const final {
return alignof(std::int32_t); }
2229 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2233class RField<std::uint32_t> final :
public RFieldBase {
2235 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2237 return std::make_unique<RField>(newName);
2240 const RColumnRepresentations &GetColumnRepresentations() const final;
2241 void GenerateColumnsImpl() final;
2242 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2243 void ConstructValue(
void *where) const final {
new (where) uint32_t(0); }
2246 static std::string TypeName() {
return "std::uint32_t"; }
2249 fTraits |= kTraitTrivialType;
2255 std::uint32_t *
Map(NTupleSize_t globalIndex) {
2256 return fPrincipalColumn->Map<std::uint32_t>(globalIndex);
2258 std::uint32_t *
Map(
const RClusterIndex clusterIndex) {
2259 return fPrincipalColumn->Map<std::uint32_t>(clusterIndex);
2261 std::uint32_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2262 return fPrincipalColumn->MapV<std::uint32_t>(globalIndex, nItems);
2264 std::uint32_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2266 return fPrincipalColumn->MapV<std::uint32_t>(clusterIndex, nItems);
2269 size_t GetValueSize() const final {
return sizeof(std::uint32_t); }
2270 size_t GetAlignment() const final {
return alignof(std::uint32_t); }
2271 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2275class RField<std::uint64_t> final :
public RFieldBase {
2277 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2279 return std::make_unique<RField>(newName);
2282 const RColumnRepresentations &GetColumnRepresentations() const final;
2283 void GenerateColumnsImpl() final;
2284 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2285 void ConstructValue(
void *where) const final {
new (where) uint64_t(0); }
2288 static std::string TypeName() {
return "std::uint64_t"; }
2291 fTraits |= kTraitTrivialType;
2297 std::uint64_t *
Map(NTupleSize_t globalIndex) {
2298 return fPrincipalColumn->Map<std::uint64_t>(globalIndex);
2300 std::uint64_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::uint64_t>(clusterIndex); }
2301 std::uint64_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2302 return fPrincipalColumn->MapV<std::uint64_t>(globalIndex, nItems);
2304 std::uint64_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2306 return fPrincipalColumn->MapV<std::uint64_t>(clusterIndex, nItems);
2309 size_t GetValueSize() const final {
return sizeof(std::uint64_t); }
2310 size_t GetAlignment() const final {
return alignof(std::uint64_t); }
2311 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2315class RField<std::int64_t> final :
public RFieldBase {
2317 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2319 return std::make_unique<RField>(newName);
2322 const RColumnRepresentations &GetColumnRepresentations() const final;
2323 void GenerateColumnsImpl() final;
2324 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2325 void ConstructValue(
void *where) const final {
new (where) int64_t(0); }
2328 static std::string TypeName() {
return "std::int64_t"; }
2331 fTraits |= kTraitTrivialType;
2337 std::int64_t *
Map(NTupleSize_t globalIndex) {
2338 return fPrincipalColumn->Map<std::int64_t>(globalIndex);
2340 std::int64_t *
Map(RClusterIndex clusterIndex) {
return fPrincipalColumn->Map<std::int64_t>(clusterIndex); }
2341 std::int64_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2342 return fPrincipalColumn->MapV<std::int64_t>(globalIndex, nItems);
2344 std::int64_t *MapV(RClusterIndex clusterIndex, NTupleSize_t &nItems)
2346 return fPrincipalColumn->MapV<std::int64_t>(clusterIndex, nItems);
2349 size_t GetValueSize() const final {
return sizeof(std::int64_t); }
2350 size_t GetAlignment() const final {
return alignof(std::int64_t); }
2351 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2355class RField<std::string> final :
public RFieldBase {
2359 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2361 return std::make_unique<RField>(newName);
2364 const RColumnRepresentations &GetColumnRepresentations() const final;
2365 void GenerateColumnsImpl() final;
2366 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2368 void ConstructValue(
void *where) const final {
new (where) std::string(); }
2369 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<std::string>>(); }
2371 std::size_t AppendImpl(
const void *from)
final;
2374 void CommitClusterImpl() final { fIndex = 0; }
2377 static std::string TypeName() {
return "std::string"; }
2386 size_t GetValueSize() const final {
return sizeof(std::string); }
2387 size_t GetAlignment() const final {
return std::alignment_of<std::string>(); }
2388 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2391template <
typename ItemT, std::
size_t N>
2392class RField<std::array<ItemT, N>> :
public RArrayField {
2393 using ContainerT =
typename std::array<ItemT, N>;
2396 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2399 static std::string TypeName() {
2402 explicit RField(std::string_view
name) : RArrayField(
name, std::make_unique<
RField<ItemT>>(
"_0"),
N)
2409template <
typename ItemT, std::
size_t N>
2418template <
typename ItemT>
2420 using ContainerT =
typename std::set<ItemT>;
2423 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2424 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2429 explicit RField(std::string_view
name) : RSetField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
2434 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2435 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2438template <
typename ItemT>
2439class RField<std::unordered_set<ItemT>> final :
public RSetField {
2440 using ContainerT =
typename std::unordered_set<ItemT>;
2443 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2444 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2449 explicit RField(std::string_view
name) : RSetField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
2454 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2455 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2458template <
typename KeyT,
typename ValueT>
2459class RField<std::map<KeyT, ValueT>> final :
public RMapField {
2460 using ContainerT =
typename std::map<KeyT, ValueT>;
2463 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2464 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2467 static std::string TypeName()
2473 : RMapField(
name, TypeName(), std::make_unique<
RField<std::pair<KeyT, ValueT>>>(
"_0"))
2480 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2481 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2484template <
typename KeyT,
typename ValueT>
2485class RField<std::unordered_map<KeyT, ValueT>> final :
public RMapField {
2486 using ContainerT =
typename std::unordered_map<KeyT, ValueT>;
2489 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2490 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2493 static std::string TypeName()
2499 : RMapField(
name, TypeName(), std::make_unique<
RField<std::pair<KeyT, ValueT>>>(
"_0"))
2506 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2507 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2510template <
typename... ItemTs>
2511class RField<std::variant<ItemTs...>> final :
public RVariantField {
2512 using ContainerT =
typename std::variant<ItemTs...>;
2514 template <
typename HeadT,
typename... TailTs>
2515 static std::string BuildItemTypes()
2518 if constexpr(
sizeof...(TailTs) > 0)
2519 result +=
"," + BuildItemTypes<TailTs...>();
2523 template <
typename HeadT,
typename... TailTs>
2524 static std::vector<RFieldBase *> BuildItemFields(
unsigned int index = 0)
2526 std::vector<RFieldBase *>
result;
2528 if constexpr(
sizeof...(TailTs) > 0) {
2529 auto tailFields = BuildItemFields<TailTs...>(
index + 1);
2530 result.insert(
result.end(), tailFields.begin(), tailFields.end());
2536 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2539 static std::string TypeName() {
return "std::variant<" + BuildItemTypes<ItemTs...>() +
">"; }
2540 explicit RField(std::string_view
name) : RVariantField(
name, BuildItemFields<ItemTs...>()) {}
2546template <
typename ItemT>
2547class RField<std::vector<ItemT>> final :
public RVectorField {
2548 using ContainerT =
typename std::vector<ItemT>;
2551 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2556 : RVectorField(
name, std::make_unique<
RField<ItemT>>(
"_0"))
2562 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2567class RField<std::vector<bool>> final :
public RFieldBase {
2572 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2574 return std::make_unique<RField>(newName);
2577 const RColumnRepresentations &GetColumnRepresentations() const final;
2578 void GenerateColumnsImpl() final;
2579 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2581 void ConstructValue(
void *where) const final {
new (where) std::vector<bool>(); }
2582 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<std::vector<bool>>>(); }
2584 std::size_t AppendImpl(
const void *from)
final;
2585 void ReadGlobalImpl(NTupleSize_t globalIndex,
void *to)
final;
2587 void CommitClusterImpl() final { fNWritten = 0; }
2590 static std::string TypeName() {
return "std::vector<bool>"; }
2596 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
2598 size_t GetValueSize() const final {
return sizeof(std::vector<bool>); }
2599 size_t GetAlignment() const final {
return std::alignment_of<std::vector<bool>>(); }
2600 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2601 void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *
size)
const {
2602 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
2604 void GetCollectionInfo(RClusterIndex clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *
size)
const
2606 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
2610template <
typename ItemT>
2614 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
2616 auto newItemField = fSubFields[0]->Clone(fSubFields[0]->GetFieldName());
2617 return std::make_unique<RField<ROOT::VecOps::RVec<ItemT>>>(newName, std::move(newItemField));
2621 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2625 auto typedValue =
static_cast<const ContainerT *
>(from);
2627 auto count = typedValue->size();
2628 for (
unsigned i = 0; i < count; ++i) {
2629 nbytes += CallAppendOn(*fSubFields[0], &typedValue->data()[i]);
2631 this->fNWritten += count;
2632 fColumns[0]->Append(&this->fNWritten);
2633 return nbytes + fColumns[0]->GetElement()->GetPackedSize();
2637 auto typedValue =
static_cast<ContainerT *
>(to);
2640 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &nItems);
2641 typedValue->resize(nItems);
2642 for (
unsigned i = 0; i < nItems; ++i) {
2643 CallReadOn(*fSubFields[0], collectionStart + i, &typedValue->data()[i]);
2648 RField(std::string_view fieldName, std::unique_ptr<RFieldBase> itemField)
2649 :
RRVecField(fieldName, std::move(itemField))
2664 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2667template <
typename T1,
typename T2>
2668class RField<std::pair<T1, T2>> final :
public RPairField {
2669 using ContainerT =
typename std::pair<T1,T2>;
2671 template <
typename Ty1,
typename Ty2>
2672 static std::array<std::unique_ptr<RFieldBase>, 2> BuildItemFields()
2674 return {std::make_unique<RField<Ty1>>(
"_0"), std::make_unique<
RField<Ty2>>(
"_1")};
2677 static std::array<std::size_t, 2> BuildItemOffsets()
2679 auto pair = ContainerT();
2680 auto offsetFirst =
reinterpret_cast<std::uintptr_t
>(&(pair.first)) -
reinterpret_cast<std::uintptr_t
>(&pair);
2681 auto offsetSecond =
reinterpret_cast<std::uintptr_t
>(&(pair.second)) -
reinterpret_cast<std::uintptr_t
>(&pair);
2682 return {offsetFirst, offsetSecond};
2686 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2688 std::array<std::unique_ptr<RFieldBase>, 2> items{fSubFields[0]->Clone(fSubFields[0]->GetFieldName()),
2689 fSubFields[1]->Clone(fSubFields[1]->GetFieldName())};
2690 return std::make_unique<RField<std::pair<T1, T2>>>(newName, std::move(items));
2693 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2694 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2697 static std::string TypeName() {
2700 explicit RField(std::string_view
name, std::array<std::unique_ptr<RFieldBase>, 2> &&itemFields)
2701 : RPairField(
name, std::move(itemFields), BuildItemOffsets())
2703 fMaxAlignment = std::max(
alignof(
T1),
alignof(
T2));
2704 fSize =
sizeof(ContainerT);
2712template <
typename... ItemTs>
2713class RField<std::tuple<ItemTs...>> final :
public RTupleField {
2714 using ContainerT =
typename std::tuple<ItemTs...>;
2716 template <
typename HeadT,
typename... TailTs>
2717 static std::string BuildItemTypes()
2720 if constexpr (
sizeof...(TailTs) > 0)
2721 result +=
"," + BuildItemTypes<TailTs...>();
2725 template <
typename HeadT,
typename... TailTs>
2726 static void _BuildItemFields(std::vector<std::unique_ptr<RFieldBase>> &itemFields,
unsigned int index = 0)
2729 if constexpr (
sizeof...(TailTs) > 0)
2730 _BuildItemFields<TailTs...>(itemFields,
index + 1);
2732 template <
typename... Ts>
2733 static std::vector<std::unique_ptr<RFieldBase>> BuildItemFields()
2735 std::vector<std::unique_ptr<RFieldBase>>
result;
2736 _BuildItemFields<Ts...>(
result);
2740 template <
unsigned Index,
typename HeadT,
typename... TailTs>
2741 static void _BuildItemOffsets(std::vector<std::size_t> &offsets,
const ContainerT &tuple)
2744 reinterpret_cast<std::uintptr_t
>(&std::get<Index>(tuple)) -
reinterpret_cast<std::uintptr_t
>(&tuple);
2745 offsets.emplace_back(
offset);
2746 if constexpr (
sizeof...(TailTs) > 0)
2747 _BuildItemOffsets<
Index + 1, TailTs...>(offsets, tuple);
2749 template <
typename... Ts>
2750 static std::vector<std::size_t> BuildItemOffsets()
2752 std::vector<std::size_t>
result;
2753 _BuildItemOffsets<0, Ts...>(
result, ContainerT());
2758 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
2760 std::vector<std::unique_ptr<RFieldBase>> items;
2761 for (
auto &item : fSubFields)
2762 items.push_back(item->Clone(item->GetFieldName()));
2763 return std::make_unique<
RField<std::tuple<ItemTs...>>>(newName, std::move(items));
2766 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
2767 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
2770 static std::string TypeName() {
return "std::tuple<" + BuildItemTypes<ItemTs...>() +
">"; }
2771 explicit RField(std::string_view
name, std::vector<std::unique_ptr<RFieldBase>> &&itemFields)
2772 : RTupleField(
name, std::move(itemFields), BuildItemOffsets<ItemTs...>())
2774 fMaxAlignment = std::max({
alignof(ItemTs)...});
2775 fSize =
sizeof(ContainerT);
2783template <std::
size_t N>
2784class RField<std::bitset<N>> final :
public RBitsetField {
2786 static std::string TypeName() {
return "std::bitset<" + std::to_string(
N) +
">"; }
2793template <
typename ItemT>
2794class RField<std::unique_ptr<ItemT>> final :
public RUniquePtrField {
2797 explicit RField(std::string_view
name) : RUniquePtrField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
2803template <
typename ItemT>
2804class RField<std::atomic<ItemT>> final :
public RAtomicField {
2807 explicit RField(std::string_view
name) : RAtomicField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
2816template <
typename T>
2817std::unique_ptr<T, typename RFieldBase::RCreateObjectDeleter<T>::deleter> RFieldBase::CreateObject()
const
2823 return std::unique_ptr<T>(
static_cast<T *
>(CreateObjectRawPtr()));
2833std::unique_ptr<void, typename RFieldBase::RCreateObjectDeleter<void>::deleter>
2834ROOT::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 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...
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()
static RResult< std::unique_ptr< RFieldBase > > Create(const std::string &fieldName, const std::string &canonicalType, const std::string &typeAlias)
Factory method to resurrect a field from the stored on-disk type information.
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
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)
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
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...
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