57namespace Experimental {
59class RCollectionField;
60class RCollectionNTupleWriter;
65struct RFieldCallbackInjector;
167 std::swap(
fField, other.fField);
168 std::swap(
fObjPtr, other.fObjPtr);
176 template <
typename T>
182 return static_cast<T *
>(
result);
189 template <
typename T>
192 return static_cast<T *
>(
fObjPtr);
325 static const std::size_t
kAllSet = std::size_t(-1);
379 virtual std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const = 0;
385 virtual void DestroyValue(
void *objPtr,
bool dtorOnly =
false)
const;
395 virtual std::size_t
AppendImpl(
const void *from);
445 virtual std::size_t
ReadBulkImpl(
const RBulkSpec &bulkSpec);
466 other.
Read(clusterIndex, to);
483 void Attach(std::unique_ptr<Detail::RFieldBase>
child);
494 Create(
const std::string &fieldName,
const std::string &canonicalType,
const std::string &typeAlias);
498 template <
bool IsConstT>
502 using FieldPtr_t = std::conditional_t<IsConstT, const RFieldBase *, RFieldBase *>;
514 using value_type = std::conditional_t<IsConstT, const RFieldBase, RFieldBase>;
515 using pointer = std::conditional_t<IsConstT, const RFieldBase *, RFieldBase *>;
516 using reference = std::conditional_t<IsConstT, const RFieldBase &, RFieldBase &>;
525 auto itr =
fStack.rbegin();
526 if (!itr->fFieldPtr->fSubFields.empty()) {
527 fStack.emplace_back(
Position(itr->fFieldPtr->fSubFields[0].get(), 0));
531 unsigned int nextIdxInParent = ++(itr->fIdxInParent);
532 while (nextIdxInParent >= itr->fFieldPtr->fParent->fSubFields.size()) {
534 itr->fFieldPtr = itr->fFieldPtr->fParent;
535 itr->fIdxInParent = -1;
540 nextIdxInParent = ++(itr->fIdxInParent);
542 itr->fFieldPtr = itr->fFieldPtr->fParent->fSubFields[nextIdxInParent].get();
559 std::size_t nRepetitions = 0);
567 std::unique_ptr<RFieldBase>
Clone(std::string_view newName)
const;
571 Create(
const std::string &fieldName,
const std::string &typeName);
659 std::unique_ptr<Detail::RFieldBase>
CloneImpl(std::string_view newName)
const override;
695 RClassField(std::string_view fieldName, std::string_view className,
TClass *classp);
702 std::unique_ptr<Detail::RFieldBase>
CloneImpl(std::string_view newName)
const final;
707 void DestroyValue(
void *objPtr,
bool dtorOnly =
false) const final;
709 std::
size_t AppendImpl(const
void *from) final;
715 RClassField(std::string_view fieldName, std::string_view className);
725 void AcceptVisitor(Detail::RFieldVisitor &visitor) const override;
731 REnumField(std::string_view fieldName, std::string_view enumName,
TEnum *enump);
732 REnumField(std::string_view fieldName, std::string_view enumName, std::unique_ptr<RFieldBase> intField);
735 std::unique_ptr<Detail::RFieldBase>
CloneImpl(std::string_view newName)
const final;
745 REnumField(std::string_view fieldName, std::string_view enumName);
782 void *fIterator =
nullptr;
783 void *fElementPtr =
nullptr;
787 auto fnNext_Contig = [&]() {
790 auto &iter =
reinterpret_cast<unsigned char *&
>(fIterator),
p = iter;
819 void *fBegin = &fBeginSmallBuf;
820 void *fEnd = &fEndSmallBuf;
826 std::size_t stride = 0U)
827 : fIFuncs(ifuncs), fStride(stride)
837 std::unique_ptr<TVirtualCollectionProxy>
fProxy;
852 std::unique_ptr<Detail::RFieldBase> itemField);
855 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const override;
857 void GenerateColumnsImpl() final;
860 void GenerateValue(
void *where) const override;
861 void DestroyValue(
void *objPtr,
bool dtorOnly = false) const override;
863 std::
size_t AppendImpl(const
void *from) override;
864 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) override;
866 void CommitClusterImpl() final { fNWritten = 0; }
874 using Detail::RFieldBase::GenerateValue;
875 std::vector<RValue> SplitValue(
const RValue &
value)
const override;
877 size_t GetAlignment()
const override {
return alignof(std::max_align_t); }
881 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
885 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
893 std::size_t fMaxAlignment = 1;
897 std::size_t GetItemPadding(std::size_t baseOffset, std::size_t itemAlignment)
const;
899 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const override;
904 void GenerateValue(
void *where)
const override;
905 void DestroyValue(
void *objPtr,
bool dtorOnly =
false)
const override;
907 std::size_t AppendImpl(
const void *from)
final;
908 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
909 void ReadInClusterImpl(
const RClusterIndex &clusterIndex,
void *to)
final;
911 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<Detail::RFieldBase>> &&itemFields,
912 const std::vector<std::size_t> &offsets, std::string_view typeName =
"");
914 template <std::
size_t N>
915 RRecordField(std::string_view fieldName, std::array<std::unique_ptr<Detail::RFieldBase>,
N> &&itemFields,
916 const std::array<std::size_t, N> &offsets, std::string_view typeName =
"")
919 fTraits |= kTraitTrivialType;
920 for (
unsigned i = 0; i <
N; ++i) {
921 fOffsets.push_back(offsets[i]);
922 fMaxAlignment = std::max(fMaxAlignment, itemFields[i]->GetAlignment());
923 fSize += GetItemPadding(
fSize, itemFields[i]->GetAlignment()) + itemFields[i]->GetValueSize();
924 fTraits &= itemFields[i]->GetTraits();
925 Attach(std::move(itemFields[i]));
931 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<Detail::RFieldBase>> &&itemFields);
932 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<Detail::RFieldBase>> &itemFields);
937 using Detail::RFieldBase::GenerateValue;
938 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
951 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final;
954 void GenerateColumnsImpl() final;
957 void DestroyValue(
void *objPtr,
bool dtorOnly = false) const final;
958 void GenerateValue(
void *where)
const override {
new (where) std::vector<char>(); }
960 std::size_t AppendImpl(
const void *from)
final;
961 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
966 RVectorField(std::string_view fieldName, std::unique_ptr<Detail::RFieldBase> itemField);
971 using Detail::RFieldBase::GenerateValue;
972 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
973 size_t GetValueSize()
const override {
return sizeof(std::vector<char>); }
974 size_t GetAlignment() const final {
return std::alignment_of<std::vector<char>>(); }
977 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
980 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
989 std::size_t EvalValueSize()
const;
996 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const override;
998 void GenerateColumnsImpl() final;
1001 void GenerateValue(
void *where) const override;
1002 void DestroyValue(
void *objPtr,
bool dtorOnly = false) const override;
1004 std::
size_t AppendImpl(const
void *from) override;
1005 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) override;
1006 std::
size_t ReadBulkImpl(const
RBulkSpec &bulkSpec) final;
1008 void CommitClusterImpl() final { fNWritten = 0; }
1011 RRVecField(std::string_view fieldName, std::unique_ptr<Detail::RFieldBase> itemField);
1018 using Detail::RFieldBase::GenerateValue;
1019 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1020 size_t GetValueSize()
const override;
1021 size_t GetAlignment()
const override;
1025 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
1029 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
1040 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final;
1045 void GenerateValue(
void *where)
const override;
1046 void DestroyValue(
void *objPtr,
bool dtorOnly =
false) const final;
1048 std::
size_t AppendImpl(const
void *from) final;
1049 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1050 void ReadInClusterImpl(const
RClusterIndex &clusterIndex,
void *to) final;
1053 RArrayField(std::string_view fieldName, std::unique_ptr<Detail::RFieldBase> itemField, std::
size_t arrayLength);
1058 using Detail::RFieldBase::GenerateValue;
1060 size_t GetLength()
const {
return fArrayLength; }
1062 size_t GetAlignment() const final {
return fSubFields[0]->GetAlignment(); }
1071 static constexpr std::size_t kWordSize =
sizeof(
Word_t);
1072 static constexpr std::size_t kBitsPerWord = kWordSize * 8;
1078 std::unique_ptr<Detail::RFieldBase>
CloneImpl(std::string_view newName)
const final
1080 return std::make_unique<RBitsetField>(newName, fN);
1082 const RColumnRepresentations &GetColumnRepresentations() const final;
1083 void GenerateColumnsImpl() final;
1085 void GenerateValue(
void *where) const final { memset(where, 0, GetValueSize()); }
1086 std::size_t AppendImpl(
const void *from)
final;
1087 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
1095 using Detail::RFieldBase::GenerateValue;
1096 size_t GetValueSize() const final {
return kWordSize * ((fN + kBitsPerWord - 1) / kBitsPerWord); }
1101 std::size_t
GetN()
const {
return fN; }
1107 size_t fMaxItemSize = 0;
1108 size_t fMaxAlignment = 1;
1110 size_t fTagOffset = 0;
1113 static std::string GetTypeList(
const std::vector<Detail::RFieldBase *> &itemFields);
1115 std::uint32_t GetTag(
const void *variantPtr)
const;
1116 void SetTag(
void *variantPtr, std::uint32_t tag)
const;
1119 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final;
1122 void GenerateColumnsImpl() final;
1125 void GenerateValue(
void *where) const override;
1126 void DestroyValue(
void *objPtr,
bool dtorOnly = false) const final;
1128 std::
size_t AppendImpl(const
void *from) final;
1129 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1131 void CommitClusterImpl() final;
1135 RVariantField(std::string_view fieldName, const std::vector<Detail::RFieldBase *> &itemFields);
1140 using Detail::RFieldBase::GenerateValue;
1141 size_t GetValueSize() const final;
1142 size_t GetAlignment() const final {
return fMaxAlignment; }
1148 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final;
1151 RSetField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<Detail::RFieldBase> itemField);
1156 size_t GetAlignment()
const override {
return std::alignment_of<std::set<std::max_align_t>>(); }
1165 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final;
1167 std::size_t AppendImpl(
const void *from)
final;
1168 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to)
final;
1171 RMapField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<Detail::RFieldBase> itemField);
1176 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1178 size_t GetAlignment()
const override {
return std::alignment_of<std::map<std::max_align_t, std::max_align_t>>(); }
1197 void GenerateColumnsImpl() final;
1200 std::
size_t AppendNull();
1201 std::
size_t AppendValue(const
void *from);
1202 void CommitClusterImpl() final { fNWritten = 0; }
1208 RNullableField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<Detail::RFieldBase> itemField);
1215 bool IsDense()
const {
return GetColumnRepresentative()[0] == EColumnType::kBit; }
1217 void SetDense() { SetColumnRepresentative({EColumnType::kBit}); }
1218 void SetSparse() { SetColumnRepresentative({EColumnType::kSplitIndex32}); }
1225 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final;
1227 void GenerateValue(
void *where)
const final {
new (where) std::unique_ptr<char>(); }
1228 void DestroyValue(
void *objPtr,
bool dtorOnly =
false) const final;
1230 std::
size_t AppendImpl(const
void *from) final;
1231 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
1234 RUniquePtrField(std::string_view fieldName, std::string_view typeName,
1235 std::unique_ptr<Detail::RFieldBase> itemField);
1240 using Detail::RFieldBase::GenerateValue;
1242 size_t GetValueSize() const final {
return sizeof(std::unique_ptr<char>); }
1243 size_t GetAlignment() const final {
return alignof(std::unique_ptr<char>); }
1248 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final;
1252 void GenerateValue(
void *where)
const final { CallGenerateValueOn(*fSubFields[0], where); }
1255 CallDestroyValueOn(*fSubFields[0], objPtr, dtorOnly);
1258 std::size_t
AppendImpl(
const void *from)
final {
return CallAppendOn(*fSubFields[0], from); }
1262 CallReadOn(*fSubFields[0], clusterIndex, to);
1266 RAtomicField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<Detail::RFieldBase> itemField);
1271 using Detail::RFieldBase::GenerateValue;
1272 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
1274 size_t GetValueSize() const final {
return fSubFields[0]->GetValueSize(); }
1275 size_t GetAlignment() const final {
return fSubFields[0]->GetAlignment(); }
1281template <
typename T,
typename=
void>
1286 if constexpr (std::is_default_constructible_v<T>) {
1290 new (where) T(
static_cast<TRootIOCtor *
>(
nullptr));
1297 static_assert(std::is_class_v<T>,
"no I/O support for this basic C++ type");
1303 using Detail::RFieldBase::GenerateValue;
1306template <
typename T>
1316template <
typename T,
typename =
void>
1319template <
typename T>
1321 T, typename std::enable_if<std::is_same<typename T::IsCollectionProxy, std::true_type>::value>
::type>
1362template <
typename T,
typename =
void>
1380template <
typename T>
1383 void GenerateValue(
void *where)
const final {
new (where) T(); }
1387 RField(std::string_view
name) : RProxiedCollectionField(
name, TypeName())
1389 static_assert(std::is_class<T>::value,
"collection proxy unsupported for fundamental types");
1395 using Detail::RFieldBase::GenerateValue;
1405 std::unique_ptr<Detail::RFieldBase>
CloneImpl(std::string_view newName)
const final;
1414 static std::
string TypeName() {
return ""; }
1416 std::shared_ptr<RCollectionNTupleWriter> collectionNTuple,
1417 std::unique_ptr<RNTupleModel> collectionModel);
1431 static std::string
GetTypeList(
const std::array<std::unique_ptr<Detail::RFieldBase>, 2> &itemFields);
1434 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const override;
1436 void GenerateValue(
void *where)
const override;
1437 void DestroyValue(
void *objPtr,
bool dtorOnly =
false)
const override;
1439 RPairField(std::string_view fieldName, std::array<std::unique_ptr<Detail::RFieldBase>, 2> &&itemFields,
1440 const std::array<std::size_t, 2> &offsets);
1443 RPairField(std::string_view fieldName, std::array<std::unique_ptr<Detail::RFieldBase>, 2> &itemFields);
1448 using Detail::RFieldBase::GenerateValue;
1455 static std::string
GetTypeList(
const std::vector<std::unique_ptr<Detail::RFieldBase>> &itemFields);
1458 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const override;
1460 void GenerateValue(
void *where)
const override;
1461 void DestroyValue(
void *objPtr,
bool dtorOnly =
false)
const override;
1463 RTupleField(std::string_view fieldName, std::vector<std::unique_ptr<Detail::RFieldBase>> &&itemFields,
1464 const std::vector<std::size_t> &offsets);
1467 RTupleField(std::string_view fieldName, std::vector<std::unique_ptr<Detail::RFieldBase>> &itemFields);
1472 using Detail::RFieldBase::GenerateValue;
1487 const RColumnRepresentations &GetColumnRepresentations() const final;
1489 void GenerateColumnsImpl() final {
throw RException(
R__FAIL(
"Cardinality fields must only be used for reading")); }
1510 std::unique_ptr<Detail::RFieldBase>
CloneImpl(std::string_view newName)
const final {
1511 return std::make_unique<RField>(newName);
1515 void GenerateColumnsImpl() final;
1520 static std::string
TypeName() {
return "ROOT::Experimental::ClusterSize_t"; }
1524 fTraits |= kTraitTrivialType;
1537 return fPrincipalColumn->MapV<
ClusterSize_t>(globalIndex, nItems);
1540 return fPrincipalColumn->MapV<
ClusterSize_t>(clusterIndex, nItems);
1543 using Detail::RFieldBase::GenerateValue;
1549 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
1552 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
1557template <
typename SizeT>
1560 std::unique_ptr<ROOT::Experimental::Detail::RFieldBase>
CloneImpl(std::string_view newName)
const final
1562 return std::make_unique<RField<RNTupleCardinality<SizeT>>>(newName);
1573 using Detail::RFieldBase::GenerateValue;
1582 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &
size);
1591 fPrincipalColumn->GetCollectionInfo(clusterIndex, &collectionStart, &
size);
1599 fPrincipalColumn->GetCollectionInfo(bulkSpec.fFirstIndex, &collectionStart, &collectionSize);
1602 typedValues[0] = collectionSize;
1604 auto lastOffset = collectionStart.
GetIndex() + collectionSize;
1606 std::size_t nEntries = 1;
1607 while (nRemainingEntries > 0) {
1609 auto offsets = fPrincipalColumn->MapV<
ClusterSize_t>(bulkSpec.fFirstIndex + nEntries, nItemsUntilPageEnd);
1610 std::size_t nBatch = std::min(nRemainingEntries, nItemsUntilPageEnd);
1611 for (std::size_t i = 0; i < nBatch; ++i) {
1612 typedValues[nEntries + i] = offsets[i] - lastOffset;
1613 lastOffset = offsets[i];
1615 nRemainingEntries -= nBatch;
1618 return RBulkSpec::kAllSet;
1625 std::unique_ptr<Detail::RFieldBase>
CloneImpl(std::string_view newName)
const final {
1626 return std::make_unique<RField>(newName);
1629 const RColumnRepresentations &GetColumnRepresentations() const final;
1630 void GenerateColumnsImpl() final;
1632 void GenerateValue(
void *where) const final {
new (where)
bool(
false); }
1639 fTraits |= kTraitTrivialType;
1646 return fPrincipalColumn->Map<
bool>(globalIndex);
1649 return fPrincipalColumn->Map<
bool>(clusterIndex);
1652 return fPrincipalColumn->MapV<
bool>(globalIndex, nItems);
1655 return fPrincipalColumn->MapV<
bool>(clusterIndex, nItems);
1658 using Detail::RFieldBase::GenerateValue;
1667 std::unique_ptr<Detail::RFieldBase>
CloneImpl(std::string_view newName)
const final {
1668 return std::make_unique<RField>(newName);
1671 const RColumnRepresentations &GetColumnRepresentations() const final;
1672 void GenerateColumnsImpl() final;
1674 void GenerateValue(
void *where) const final {
new (where)
float(0.0); }
1681 fTraits |= kTraitTrivialType;
1688 return fPrincipalColumn->Map<
float>(globalIndex);
1691 return fPrincipalColumn->Map<
float>(clusterIndex);
1694 return fPrincipalColumn->MapV<
float>(globalIndex, nItems);
1697 return fPrincipalColumn->MapV<
float>(clusterIndex, nItems);
1700 using Detail::RFieldBase::GenerateValue;
1705 void SetHalfPrecision();
1711 std::unique_ptr<Detail::RFieldBase>
CloneImpl(std::string_view newName)
const final {
1712 return std::make_unique<RField>(newName);
1715 const RColumnRepresentations &GetColumnRepresentations() const final;
1716 void GenerateColumnsImpl() final;
1718 void GenerateValue(
void *where) const final {
new (where)
double(0.0); }
1725 fTraits |= kTraitTrivialType;
1732 return fPrincipalColumn->Map<
double>(globalIndex);
1735 return fPrincipalColumn->Map<
double>(clusterIndex);
1738 return fPrincipalColumn->MapV<
double>(globalIndex, nItems);
1741 return fPrincipalColumn->MapV<
double>(clusterIndex, nItems);
1744 using Detail::RFieldBase::GenerateValue;
1754class RField<std::
byte> :
public Detail::RFieldBase {
1756 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final
1758 return std::make_unique<RField>(newName);
1761 const RColumnRepresentations &GetColumnRepresentations() const final;
1762 void GenerateColumnsImpl() final;
1763 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
1764 void GenerateValue(
void *where) const final {
new (where) std::byte{0}; }
1767 static std::string TypeName() {
return "std::byte"; }
1771 fTraits |= kTraitTrivialType;
1777 std::byte *
Map(NTupleSize_t globalIndex) {
return fPrincipalColumn->Map<std::byte>(globalIndex); }
1778 std::byte *
Map(
const RClusterIndex &clusterIndex) {
return fPrincipalColumn->Map<std::byte>(clusterIndex); }
1779 std::byte *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
1781 return fPrincipalColumn->MapV<std::byte>(globalIndex, nItems);
1783 std::byte *MapV(
const RClusterIndex &clusterIndex, NTupleSize_t &nItems)
1785 return fPrincipalColumn->MapV<std::byte>(clusterIndex, nItems);
1788 using Detail::RFieldBase::GenerateValue;
1789 size_t GetValueSize() const final {
return sizeof(std::byte); }
1790 size_t GetAlignment() const final {
return alignof(std::byte); }
1791 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
1797 std::unique_ptr<Detail::RFieldBase>
CloneImpl(std::string_view newName)
const final {
1798 return std::make_unique<RField>(newName);
1801 const RColumnRepresentations &GetColumnRepresentations() const final;
1802 void GenerateColumnsImpl() final;
1804 void GenerateValue(
void *where) const final {
new (where)
char(0); }
1811 fTraits |= kTraitTrivialType;
1818 return fPrincipalColumn->Map<
char>(globalIndex);
1821 return fPrincipalColumn->Map<
char>(clusterIndex);
1824 return fPrincipalColumn->MapV<
char>(globalIndex, nItems);
1827 return fPrincipalColumn->MapV<
char>(clusterIndex, nItems);
1830 using Detail::RFieldBase::GenerateValue;
1837class RField<std::int8_t> :
public Detail::RFieldBase {
1839 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final {
1840 return std::make_unique<RField>(newName);
1843 const RColumnRepresentations &GetColumnRepresentations() const final;
1844 void GenerateColumnsImpl() final;
1845 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
1846 void GenerateValue(
void *where) const final {
new (where) int8_t(0); }
1849 static std::string TypeName() {
return "std::int8_t"; }
1853 fTraits |= kTraitTrivialType;
1859 std::int8_t *
Map(NTupleSize_t globalIndex) {
1860 return fPrincipalColumn->Map<std::int8_t>(globalIndex);
1862 std::int8_t *
Map(
const RClusterIndex &clusterIndex) {
1863 return fPrincipalColumn->Map<std::int8_t>(clusterIndex);
1865 std::int8_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
1866 return fPrincipalColumn->MapV<std::int8_t>(globalIndex, nItems);
1868 std::int8_t *MapV(
const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
1869 return fPrincipalColumn->MapV<std::int8_t>(clusterIndex, nItems);
1872 using Detail::RFieldBase::GenerateValue;
1873 size_t GetValueSize() const final {
return sizeof(std::int8_t); }
1874 size_t GetAlignment() const final {
return alignof(std::int8_t); }
1875 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
1879class RField<std::uint8_t> :
public Detail::RFieldBase {
1881 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final {
1882 return std::make_unique<RField>(newName);
1885 const RColumnRepresentations &GetColumnRepresentations() const final;
1886 void GenerateColumnsImpl() final;
1887 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
1888 void GenerateValue(
void *where) const final {
new (where) uint8_t(0); }
1891 static std::string TypeName() {
return "std::uint8_t"; }
1895 fTraits |= kTraitTrivialType;
1901 std::uint8_t *
Map(NTupleSize_t globalIndex) {
1902 return fPrincipalColumn->Map<std::uint8_t>(globalIndex);
1904 std::uint8_t *
Map(
const RClusterIndex &clusterIndex) {
1905 return fPrincipalColumn->Map<std::uint8_t>(clusterIndex);
1907 std::uint8_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
1908 return fPrincipalColumn->MapV<std::uint8_t>(globalIndex, nItems);
1910 std::uint8_t *MapV(
const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
1911 return fPrincipalColumn->MapV<std::uint8_t>(clusterIndex, nItems);
1914 using Detail::RFieldBase::GenerateValue;
1915 size_t GetValueSize() const final {
return sizeof(std::uint8_t); }
1916 size_t GetAlignment() const final {
return alignof(std::uint8_t); }
1917 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
1921class RField<std::int16_t> :
public Detail::RFieldBase {
1923 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final {
1924 return std::make_unique<RField>(newName);
1927 const RColumnRepresentations &GetColumnRepresentations() const final;
1928 void GenerateColumnsImpl() final;
1929 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
1930 void GenerateValue(
void *where) const final {
new (where) int16_t(0); }
1933 static std::string TypeName() {
return "std::int16_t"; }
1937 fTraits |= kTraitTrivialType;
1943 std::int16_t *
Map(NTupleSize_t globalIndex) {
1944 return fPrincipalColumn->Map<std::int16_t>(globalIndex);
1946 std::int16_t *
Map(
const RClusterIndex &clusterIndex) {
1947 return fPrincipalColumn->Map<std::int16_t>(clusterIndex);
1949 std::int16_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
1950 return fPrincipalColumn->MapV<std::int16_t>(globalIndex, nItems);
1952 std::int16_t *MapV(
const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
1953 return fPrincipalColumn->MapV<std::int16_t>(clusterIndex, nItems);
1956 using Detail::RFieldBase::GenerateValue;
1957 size_t GetValueSize() const final {
return sizeof(std::int16_t); }
1958 size_t GetAlignment() const final {
return alignof(std::int16_t); }
1959 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
1963class RField<std::uint16_t> :
public Detail::RFieldBase {
1965 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final {
1966 return std::make_unique<RField>(newName);
1969 const RColumnRepresentations &GetColumnRepresentations() const final;
1970 void GenerateColumnsImpl() final;
1971 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
1972 void GenerateValue(
void *where) const final {
new (where) int16_t(0); }
1975 static std::string TypeName() {
return "std::uint16_t"; }
1979 fTraits |= kTraitTrivialType;
1985 std::uint16_t *
Map(NTupleSize_t globalIndex) {
1986 return fPrincipalColumn->Map<std::uint16_t>(globalIndex);
1988 std::uint16_t *
Map(
const RClusterIndex &clusterIndex) {
1989 return fPrincipalColumn->Map<std::uint16_t>(clusterIndex);
1991 std::uint16_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
1992 return fPrincipalColumn->MapV<std::uint16_t>(globalIndex, nItems);
1994 std::uint16_t *MapV(
const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
1995 return fPrincipalColumn->MapV<std::uint16_t>(clusterIndex, nItems);
1998 using Detail::RFieldBase::GenerateValue;
1999 size_t GetValueSize() const final {
return sizeof(std::uint16_t); }
2000 size_t GetAlignment() const final {
return alignof(std::uint16_t); }
2001 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2005class RField<std::int32_t> :
public Detail::RFieldBase {
2007 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final {
2008 return std::make_unique<RField>(newName);
2011 const RColumnRepresentations &GetColumnRepresentations() const final;
2012 void GenerateColumnsImpl() final;
2013 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2014 void GenerateValue(
void *where) const final {
new (where) int32_t(0); }
2017 static std::string TypeName() {
return "std::int32_t"; }
2021 fTraits |= kTraitTrivialType;
2027 std::int32_t *
Map(NTupleSize_t globalIndex) {
2028 return fPrincipalColumn->Map<std::int32_t>(globalIndex);
2030 std::int32_t *
Map(
const RClusterIndex &clusterIndex) {
2031 return fPrincipalColumn->Map<std::int32_t>(clusterIndex);
2033 std::int32_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2034 return fPrincipalColumn->MapV<std::int32_t>(globalIndex, nItems);
2036 std::int32_t *MapV(
const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
2037 return fPrincipalColumn->MapV<std::int32_t>(clusterIndex, nItems);
2040 using Detail::RFieldBase::GenerateValue;
2041 size_t GetValueSize() const final {
return sizeof(std::int32_t); }
2042 size_t GetAlignment() const final {
return alignof(std::int32_t); }
2043 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2047class RField<std::uint32_t> :
public Detail::RFieldBase {
2049 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final {
2050 return std::make_unique<RField>(newName);
2053 const RColumnRepresentations &GetColumnRepresentations() const final;
2054 void GenerateColumnsImpl() final;
2055 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2056 void GenerateValue(
void *where) const final {
new (where) uint32_t(0); }
2059 static std::string TypeName() {
return "std::uint32_t"; }
2063 fTraits |= kTraitTrivialType;
2069 std::uint32_t *
Map(NTupleSize_t globalIndex) {
2070 return fPrincipalColumn->Map<std::uint32_t>(globalIndex);
2072 std::uint32_t *
Map(
const RClusterIndex clusterIndex) {
2073 return fPrincipalColumn->Map<std::uint32_t>(clusterIndex);
2075 std::uint32_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2076 return fPrincipalColumn->MapV<std::uint32_t>(globalIndex, nItems);
2078 std::uint32_t *MapV(
const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
2079 return fPrincipalColumn->MapV<std::uint32_t>(clusterIndex, nItems);
2082 using Detail::RFieldBase::GenerateValue;
2083 size_t GetValueSize() const final {
return sizeof(std::uint32_t); }
2084 size_t GetAlignment() const final {
return alignof(std::uint32_t); }
2085 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2089class RField<std::uint64_t> :
public Detail::RFieldBase {
2091 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final {
2092 return std::make_unique<RField>(newName);
2095 const RColumnRepresentations &GetColumnRepresentations() const final;
2096 void GenerateColumnsImpl() final;
2097 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2098 void GenerateValue(
void *where) const final {
new (where) uint64_t(0); }
2101 static std::string TypeName() {
return "std::uint64_t"; }
2105 fTraits |= kTraitTrivialType;
2111 std::uint64_t *
Map(NTupleSize_t globalIndex) {
2112 return fPrincipalColumn->Map<std::uint64_t>(globalIndex);
2114 std::uint64_t *
Map(
const RClusterIndex &clusterIndex) {
2115 return fPrincipalColumn->Map<std::uint64_t>(clusterIndex);
2117 std::uint64_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2118 return fPrincipalColumn->MapV<std::uint64_t>(globalIndex, nItems);
2120 std::uint64_t *MapV(
const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
2121 return fPrincipalColumn->MapV<std::uint64_t>(clusterIndex, nItems);
2124 using Detail::RFieldBase::GenerateValue;
2125 size_t GetValueSize() const final {
return sizeof(std::uint64_t); }
2126 size_t GetAlignment() const final {
return alignof(std::uint64_t); }
2127 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2131class RField<std::int64_t> :
public Detail::RFieldBase {
2133 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final {
2134 return std::make_unique<RField>(newName);
2137 const RColumnRepresentations &GetColumnRepresentations() const final;
2138 void GenerateColumnsImpl() final;
2139 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2140 void GenerateValue(
void *where) const final {
new (where) int64_t(0); }
2143 static std::string TypeName() {
return "std::int64_t"; }
2147 fTraits |= kTraitTrivialType;
2153 std::int64_t *
Map(NTupleSize_t globalIndex) {
2154 return fPrincipalColumn->Map<std::int64_t>(globalIndex);
2156 std::int64_t *
Map(
const RClusterIndex &clusterIndex) {
2157 return fPrincipalColumn->Map<std::int64_t>(clusterIndex);
2159 std::int64_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
2160 return fPrincipalColumn->MapV<std::int64_t>(globalIndex, nItems);
2162 std::int64_t *MapV(
const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
2163 return fPrincipalColumn->MapV<std::int64_t>(clusterIndex, nItems);
2166 using Detail::RFieldBase::GenerateValue;
2167 size_t GetValueSize() const final {
return sizeof(std::int64_t); }
2168 size_t GetAlignment() const final {
return alignof(std::int64_t); }
2169 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2173class RField<std::string> :
public Detail::RFieldBase {
2177 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final {
2178 return std::make_unique<RField>(newName);
2181 const RColumnRepresentations &GetColumnRepresentations() const final;
2182 void GenerateColumnsImpl() final;
2183 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2185 void GenerateValue(
void *where) const final {
new (where) std::string(); }
2186 void DestroyValue(
void *objPtr,
bool dtorOnly =
false)
const override;
2188 std::size_t AppendImpl(
const void *from)
final;
2191 void CommitClusterImpl() final { fIndex = 0; }
2194 static std::string TypeName() {
return "std::string"; }
2203 using Detail::RFieldBase::GenerateValue;
2204 size_t GetValueSize() const final {
return sizeof(std::string); }
2205 size_t GetAlignment() const final {
return std::alignment_of<std::string>(); }
2206 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2210template <
typename ItemT, std::
size_t N>
2211class RField<std::array<ItemT, N>> :
public RArrayField {
2212 using ContainerT =
typename std::array<ItemT, N>;
2215 void GenerateValue(
void *where)
const final {
new (where) ContainerT(); }
2218 static std::string TypeName() {
2221 explicit RField(std::string_view
name) : RArrayField(
name, std::make_unique<
RField<ItemT>>(
"_0"),
N)
2227 using Detail::RFieldBase::GenerateValue;
2230template <
typename ItemT, std::
size_t N>
2239template <
typename ItemT>
2241 using ContainerT =
typename std::set<ItemT>;
2244 void GenerateValue(
void *where)
const final {
new (where) ContainerT(); }
2245 void DestroyValue(
void *objPtr,
bool dtorOnly =
false) const final
2247 std::destroy_at(
static_cast<ContainerT *
>(objPtr));
2248 Detail::RFieldBase::DestroyValue(objPtr, dtorOnly);
2254 explicit RField(std::string_view
name) : RSetField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
2259 using Detail::RFieldBase::GenerateValue;
2260 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2261 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2264template <
typename ItemT>
2265class RField<std::unordered_set<ItemT>> :
public RSetField {
2266 using ContainerT =
typename std::unordered_set<ItemT>;
2269 void GenerateValue(
void *where)
const final {
new (where) ContainerT(); }
2270 void DestroyValue(
void *objPtr,
bool dtorOnly =
false) const final
2272 std::destroy_at(
static_cast<ContainerT *
>(objPtr));
2273 Detail::RFieldBase::DestroyValue(objPtr, dtorOnly);
2279 explicit RField(std::string_view
name) : RSetField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
2284 using Detail::RFieldBase::GenerateValue;
2285 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2286 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2289template <
typename KeyT,
typename ValueT>
2290class RField<std::map<KeyT, ValueT>> :
public RMapField {
2291 using ContainerT =
typename std::map<KeyT, ValueT>;
2294 void GenerateValue(
void *where)
const final {
new (where) ContainerT(); }
2295 void DestroyValue(
void *objPtr,
bool dtorOnly =
false) const final
2297 std::destroy_at(
static_cast<ContainerT *
>(objPtr));
2298 Detail::RFieldBase::DestroyValue(objPtr, dtorOnly);
2302 static std::string TypeName()
2308 : RMapField(
name, TypeName(), std::make_unique<
RField<std::pair<KeyT, ValueT>>>(
"_0"))
2315 using Detail::RFieldBase::GenerateValue;
2316 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2317 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2320template <
typename KeyT,
typename ValueT>
2321class RField<std::unordered_map<KeyT, ValueT>> :
public RMapField {
2322 using ContainerT =
typename std::unordered_map<KeyT, ValueT>;
2325 void GenerateValue(
void *where)
const final {
new (where) ContainerT(); }
2326 void DestroyValue(
void *objPtr,
bool dtorOnly =
false) const final
2328 std::destroy_at(
static_cast<ContainerT *
>(objPtr));
2329 Detail::RFieldBase::DestroyValue(objPtr, dtorOnly);
2333 static std::string TypeName()
2339 : RMapField(
name, TypeName(), std::make_unique<
RField<std::pair<KeyT, ValueT>>>(
"_0"))
2346 using Detail::RFieldBase::GenerateValue;
2347 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2348 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2351template <
typename... ItemTs>
2352class RField<std::variant<ItemTs...>> :
public RVariantField {
2353 using ContainerT =
typename std::variant<ItemTs...>;
2355 template <
typename HeadT,
typename... TailTs>
2356 static std::string BuildItemTypes()
2359 if constexpr(
sizeof...(TailTs) > 0)
2360 result +=
"," + BuildItemTypes<TailTs...>();
2364 template <
typename HeadT,
typename... TailTs>
2365 static std::vector<Detail::RFieldBase *> BuildItemFields(
unsigned int index = 0)
2367 std::vector<Detail::RFieldBase *>
result;
2369 if constexpr(
sizeof...(TailTs) > 0) {
2370 auto tailFields = BuildItemFields<TailTs...>(
index + 1);
2371 result.insert(
result.end(), tailFields.begin(), tailFields.end());
2377 void GenerateValue(
void *where)
const final {
new (where) ContainerT(); }
2380 static std::string TypeName() {
return "std::variant<" + BuildItemTypes<ItemTs...>() +
">"; }
2381 explicit RField(std::string_view
name) : RVariantField(
name, BuildItemFields<ItemTs...>()) {}
2386 using Detail::RFieldBase::GenerateValue;
2389template <
typename ItemT>
2390class RField<std::vector<ItemT>> :
public RVectorField {
2391 using ContainerT =
typename std::vector<ItemT>;
2394 void GenerateValue(
void *where)
const final {
new (where) ContainerT(); }
2399 : RVectorField(
name, std::make_unique<
RField<ItemT>>(
"_0"))
2405 using Detail::RFieldBase::GenerateValue;
2406 size_t GetValueSize() const final {
return sizeof(ContainerT); }
2411class RField<std::vector<bool>> :
public Detail::RFieldBase {
2416 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final {
2417 return std::make_unique<RField>(newName);
2420 const RColumnRepresentations &GetColumnRepresentations() const final;
2421 void GenerateColumnsImpl() final;
2422 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
2424 void GenerateValue(
void *where) const final {
new (where) std::vector<bool>(); }
2425 void DestroyValue(
void *objPtr,
bool dtorOnly =
false) const final;
2427 std::
size_t AppendImpl(const
void *from) final;
2428 void ReadGlobalImpl(NTupleSize_t globalIndex,
void *to) final;
2430 void CommitClusterImpl() final { fNWritten = 0; }
2433 static std::string TypeName() {
return "std::vector<bool>"; }
2439 using Detail::RFieldBase::GenerateValue;
2440 std::vector<RValue> SplitValue(
const RValue &
value)
const final;
2442 size_t GetValueSize() const final {
return sizeof(std::vector<bool>); }
2443 size_t GetAlignment() const final {
return std::alignment_of<std::vector<bool>>(); }
2444 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
2445 void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *
size)
const {
2446 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart,
size);
2448 void GetCollectionInfo(
const RClusterIndex &clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *
size)
const
2450 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart,
size);
2454template <
typename ItemT>
2458 std::unique_ptr<Detail::RFieldBase>
CloneImpl(std::string_view newName)
const final {
2459 auto newItemField = fSubFields[0]->Clone(fSubFields[0]->GetName());
2460 return std::make_unique<RField<ROOT::VecOps::RVec<ItemT>>>(newName, std::move(newItemField));
2466 std::destroy_at(
static_cast<ContainerT *
>(objPtr));
2467 Detail::RFieldBase::DestroyValue(objPtr, dtorOnly);
2472 auto typedValue =
static_cast<const ContainerT *
>(from);
2474 auto count = typedValue->size();
2475 for (
unsigned i = 0; i < count; ++i) {
2476 nbytes += CallAppendOn(*fSubFields[0], &typedValue->data()[i]);
2478 this->fNWritten += count;
2479 fColumns[0]->Append(&this->fNWritten);
2480 return nbytes + fColumns[0]->GetElement()->GetPackedSize();
2484 auto typedValue =
static_cast<ContainerT *
>(to);
2487 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &nItems);
2488 typedValue->resize(nItems);
2489 for (
unsigned i = 0; i < nItems; ++i) {
2490 CallReadOn(*fSubFields[0], collectionStart + i, &typedValue->data()[i]);
2495 RField(std::string_view fieldName, std::unique_ptr<Detail::RFieldBase> itemField)
2496 :
RRVecField(fieldName, std::move(itemField))
2510 using Detail::RFieldBase::GenerateValue;
2512 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
2515template <
typename T1,
typename T2>
2516class RField<std::pair<T1, T2>> :
public RPairField {
2517 using ContainerT =
typename std::pair<T1,T2>;
2519 template <
typename Ty1,
typename Ty2>
2520 static std::array<std::unique_ptr<Detail::RFieldBase>, 2> BuildItemFields()
2522 return {std::make_unique<RField<Ty1>>(
"_0"), std::make_unique<
RField<Ty2>>(
"_1")};
2525 static std::array<std::size_t, 2> BuildItemOffsets()
2527 auto pair = ContainerT();
2528 auto offsetFirst =
reinterpret_cast<std::uintptr_t
>(&(pair.first)) -
reinterpret_cast<std::uintptr_t
>(&pair);
2529 auto offsetSecond =
reinterpret_cast<std::uintptr_t
>(&(pair.second)) -
reinterpret_cast<std::uintptr_t
>(&pair);
2530 return {offsetFirst, offsetSecond};
2534 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final
2536 std::array<std::unique_ptr<Detail::RFieldBase>, 2> items{fSubFields[0]->Clone(fSubFields[0]->GetName()),
2537 fSubFields[1]->Clone(fSubFields[1]->GetName())};
2538 return std::make_unique<RField<std::pair<T1, T2>>>(newName, std::move(items));
2541 void GenerateValue(
void *where)
const final {
new (where) ContainerT(); }
2542 void DestroyValue(
void *objPtr,
bool dtorOnly =
false) const final
2544 std::destroy_at(
static_cast<ContainerT *
>(objPtr));
2545 Detail::RFieldBase::DestroyValue(objPtr, dtorOnly);
2549 static std::string TypeName() {
2552 explicit RField(std::string_view
name, std::array<std::unique_ptr<Detail::RFieldBase>, 2> &&itemFields)
2553 : RPairField(
name, std::move(itemFields), BuildItemOffsets())
2555 fMaxAlignment = std::max(
alignof(
T1),
alignof(
T2));
2556 fSize =
sizeof(ContainerT);
2563 using Detail::RFieldBase::GenerateValue;
2566template <
typename... ItemTs>
2567class RField<std::tuple<ItemTs...>> :
public RTupleField {
2568 using ContainerT =
typename std::tuple<ItemTs...>;
2570 template <
typename HeadT,
typename... TailTs>
2571 static std::string BuildItemTypes()
2574 if constexpr (
sizeof...(TailTs) > 0)
2575 result +=
"," + BuildItemTypes<TailTs...>();
2579 template <
typename HeadT,
typename... TailTs>
2580 static void _BuildItemFields(std::vector<std::unique_ptr<Detail::RFieldBase>> &itemFields,
unsigned int index = 0)
2583 if constexpr (
sizeof...(TailTs) > 0)
2584 _BuildItemFields<TailTs...>(itemFields,
index + 1);
2586 template <
typename... Ts>
2587 static std::vector<std::unique_ptr<Detail::RFieldBase>> BuildItemFields()
2589 std::vector<std::unique_ptr<Detail::RFieldBase>>
result;
2590 _BuildItemFields<Ts...>(
result);
2594 template <
unsigned Index,
typename HeadT,
typename... TailTs>
2595 static void _BuildItemOffsets(std::vector<std::size_t> &offsets,
const ContainerT &tuple)
2598 reinterpret_cast<std::uintptr_t
>(&std::get<Index>(tuple)) -
reinterpret_cast<std::uintptr_t
>(&tuple);
2599 offsets.emplace_back(
offset);
2600 if constexpr (
sizeof...(TailTs) > 0)
2601 _BuildItemOffsets<
Index + 1, TailTs...>(offsets, tuple);
2603 template <
typename... Ts>
2604 static std::vector<std::size_t> BuildItemOffsets()
2606 std::vector<std::size_t>
result;
2607 _BuildItemOffsets<0, Ts...>(
result, ContainerT());
2612 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName)
const final
2614 std::vector<std::unique_ptr<Detail::RFieldBase>> items;
2615 for (
auto &item : fSubFields)
2616 items.push_back(item->Clone(item->GetName()));
2617 return std::make_unique<
RField<std::tuple<ItemTs...>>>(newName, std::move(items));
2620 void GenerateValue(
void *where)
const final {
new (where) ContainerT(); }
2621 void DestroyValue(
void *objPtr,
bool dtorOnly =
false) const final
2623 std::destroy_at(
static_cast<ContainerT *
>(objPtr));
2624 Detail::RFieldBase::DestroyValue(objPtr, dtorOnly);
2628 static std::string TypeName() {
return "std::tuple<" + BuildItemTypes<ItemTs...>() +
">"; }
2629 explicit RField(std::string_view
name, std::vector<std::unique_ptr<Detail::RFieldBase>> &&itemFields)
2630 : RTupleField(
name, std::move(itemFields), BuildItemOffsets<ItemTs...>())
2632 fMaxAlignment = std::max({
alignof(ItemTs)...});
2633 fSize =
sizeof(ContainerT);
2640 using Detail::RFieldBase::GenerateValue;
2643template <std::
size_t N>
2644class RField<std::bitset<N>> :
public RBitsetField {
2646 static std::string TypeName() {
return "std::bitset<" + std::to_string(
N) +
">"; }
2652 using Detail::RFieldBase::GenerateValue;
2655template <
typename ItemT>
2656class RField<std::unique_ptr<ItemT>> :
public RUniquePtrField {
2659 explicit RField(std::string_view
name) : RUniquePtrField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
2664 using Detail::RFieldBase::GenerateValue;
2667template <
typename ItemT>
2668class RField<std::atomic<ItemT>> :
public RAtomicField {
2671 explicit RField(std::string_view
name) : RAtomicField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
2676 using Detail::RFieldBase::GenerateValue;
#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
Binding & operator=(OUT(*fun)(void))
std::size_t GetPackedSize(std::size_t nElements=1U) const
void ReadV(const NTupleSize_t globalIndex, const ClusterSize_t::ValueType count, void *to)
void Append(const void *from)
RColumnElementBase * GetElement() const
void Read(const NTupleSize_t globalIndex, void *to)
NTupleSize_t GetGlobalIndex(const RClusterIndex &clusterIndex)
NTupleSize_t GetNElements() const
Similar to RValue but manages an array of consecutive values.
std::size_t fNValidValues
The sum of non-zero elements in the fMask.
RClusterIndex fFirstIndex
Index of the first value of the array.
RBulk(const RBulk &)=delete
void * GetValuePtrAt(std::size_t idx) const
void * fValues
Pointer to the start of the array.
std::vector< unsigned char > fAuxData
Reading arrays of complex values may require additional memory, for instance for the elements of arra...
std::unique_ptr< bool[]> fMaskAvail
Masks invalid values in the array.
void Reset(const RClusterIndex &firstIndex, std::size_t size)
Sets a new range for the bulk.
RBulk & operator=(const RBulk &)=delete
void * ReadBulk(const RClusterIndex &firstIndex, const bool *maskReq, std::size_t size)
Reads 'size' values from the associated field, starting from 'firstIndex'.
bool ContainsRange(const RClusterIndex &firstIndex, std::size_t size) const
RFieldBase * fField
The field that created the array of values.
std::size_t fCapacity
The size of the array memory block in number of values.
std::size_t fValueSize
Cached copy of fField->GetValueSize()
std::size_t fSize
The number of available values in the array (provided their mask is set)
Some fields have multiple possible column representations, e.g.
TypesList_t fSerializationTypes
const TypesList_t & GetDeserializationTypes() const
TypesList_t fDeserializationTypes
The union of the serialization types and the deserialization extra types.
const TypesList_t & GetSerializationTypes() const
std::vector< ColumnRepresentation_t > TypesList_t
const ColumnRepresentation_t & GetSerializationDefault() const
The first column list from fSerializationTypes is the default for writing.
Iterates over the sub tree of fields in depth-first search order.
pointer operator->() const
std::conditional_t< IsConstT, const RFieldBase, RFieldBase > value_type
std::conditional_t< IsConstT, const RFieldBase &, RFieldBase & > reference
RSchemaIteratorTemplate()
std::vector< Position > fStack
The stack of nodes visited when walking down the tree of fields.
RSchemaIteratorTemplate(pointer val, int idxInParent)
~RSchemaIteratorTemplate()
bool operator==(const iterator &rh) const
std::conditional_t< IsConstT, const RFieldBase *, RFieldBase * > pointer
std::forward_iterator_tag iterator_category
std::ptrdiff_t difference_type
reference operator*() const
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
Points to an object with RNTuple I/O support and keeps a pointer to the corresponding field.
RFieldBase * GetField() const
void Read(NTupleSize_t globalIndex)
RValue & operator=(RValue &&other)
void Read(const RClusterIndex &clusterIndex)
RValue GetNonOwningCopy()
RValue(const RValue &)=delete
bool fIsOwning
If true, fObjPtr is destroyed in the destructor.
void * fObjPtr
Created by RFieldBase::GenerateValue() or a non-owning pointer from SplitValue() or BindValue()
RFieldBase * fField
The field that created the RValue.
RValue(RFieldBase *field, void *objPtr, bool isOwning)
RValue & operator=(const RValue &)=delete
A field translates read and write calls from/to underlying columns to/from tree values.
virtual std::uint32_t GetFieldVersion() const
Indicates an evolution of the mapping scheme from C++ type to columns.
RFieldBase * GetParent() const
std::string GetDescription() const
Get the field's description.
virtual size_t GetAlignment() const =0
As a rule of thumb, the alignment is equal to the size of the type.
static constexpr std::uint32_t kInvalidTypeVersion
RBulk GenerateBulk()
The returned bulk is initially empty; RBulk::ReadBulk will construct the array of values.
void SetOnDiskId(DescriptorId_t id)
EState fState
Changed by ConnectTo[Sink,Source], reset by Clone()
virtual void GenerateColumnsImpl(const RNTupleDescriptor &desc)=0
Creates the backing columns corresponsing to the field type for reading.
virtual void GenerateColumnsImpl()=0
Creates the backing columns corresponsing to the field type for writing.
virtual void GenerateValue(void *where) const =0
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Gener...
std::vector< std::unique_ptr< RFieldBase > > fSubFields
Collections and classes own sub fields.
RConstSchemaIterator cend() const
std::string fTypeAlias
A typedef or using name that was used when creating the field.
RFieldBase * fParent
Sub fields point to their mother field.
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.
std::string GetTypeAlias() const
static std::size_t CallAppendOn(RFieldBase &other, const void *from)
Allow derived classes to call Append and Read on other (sub) fields.
std::string GetName() const
RFieldBase(std::string_view name, std::string_view type, ENTupleStructure structure, bool isSimple, std::size_t nRepetitions=0)
The constructor creates the underlying column objects and connects them to either a sink or a source.
virtual void CommitClusterImpl()
std::size_t GetNRepetitions() const
void CommitCluster()
Flushes data from active columns to disk and calls CommitClusterImpl.
std::string fDescription
Free text set by the user.
static RColumn * GetPrincipalColumnOf(const RFieldBase &other)
Fields may need direct access to the principal column of their sub fields, e.g. in RRVecField::ReadBu...
virtual std::uint32_t GetTypeVersion() const
Indicates an evolution of the C++ type itself.
int fTraits
Properties of the type that allow for optimizations of collections of that type.
friend struct ROOT::Experimental::Internal::RFieldCallbackInjector
DescriptorId_t GetOnDiskId() const
static constexpr int kTraitTrivialType
Shorthand for types that are both trivially constructible and destructible.
friend class ROOT::Experimental::RCollectionField
std::uint32_t GetOnDiskTypeVersion() const
Return the C++ type version stored in the field descriptor; only valid after a call to ConnectPageSou...
RSchemaIteratorTemplate< false > RSchemaIterator
void RemoveReadCallback(size_t idx)
RValue GenerateValue()
Generates an object of the field type and allocates new initialized memory according to the type.
virtual std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const =0
Called by Clone(), which additionally copies the on-disk ID.
virtual void ReadGlobalImpl(NTupleSize_t globalIndex, void *to)
virtual size_t GetValueSize() const =0
The number of bytes taken by a value of the appropriate type.
void SetDescription(std::string_view description)
void InvokeReadCallbacks(void *target)
RSchemaIteratorTemplate< true > RConstSchemaIterator
std::string GetType() const
static RResult< void > EnsureValidFieldName(std::string_view fieldName)
Check whether a given string is a valid field name.
RFieldBase(RFieldBase &&)=default
bool fIsSimple
A field qualifies as simple if it is both mappable and has no post-read callback.
virtual void ReadInClusterImpl(const RClusterIndex &clusterIndex, void *to)
std::string fType
The C++ type captured by this field.
std::function< void(void *)> ReadCallback_t
virtual std::vector< RValue > SplitValue(const RValue &value) const
Creates the list of direct child values given a value for this field.
std::string fName
The field name relative to its parent field.
static void CallReadOn(RFieldBase &other, const RClusterIndex &clusterIndex, void *to)
const ColumnRepresentation_t * fColumnRepresentative
Points into the static vector GetColumnRepresentations().GetSerializationTypes() when SetColumnRepres...
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 void OnConnectPageSource()
Called by ConnectPageSource() only once connected; derived classes may override this as appropriate.
NTupleSize_t GetNElements() const
static void CallGenerateValueOn(const RFieldBase &other, void *where)
Allow derived classes to call GenerateValue(void *) and DestroyValue on other (sub) fields.
void ConnectPageSource(RPageSource &pageSource)
std::uint32_t fOnDiskTypeVersion
C++ type version cached from the descriptor after a call to ConnectPageSource()
virtual std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec)
General implementation of bulk read.
virtual std::size_t AppendImpl(const void *from)
Operations on values of complex types, e.g.
virtual void DestroyValue(void *objPtr, bool dtorOnly=false) const
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
void Read(NTupleSize_t globalIndex, void *to)
Populate a single value with data from the field.
virtual const RColumnRepresentations & GetColumnRepresentations() const
Implementations in derived classes should return a static RColumnRepresentations object.
std::size_t Append(const void *from)
Write the given value into columns.
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 fNRepetitions
For fixed sized arrays, the array length.
RFieldBase(const RFieldBase &)=delete
virtual void AcceptVisitor(RFieldVisitor &visitor) const
DescriptorId_t fOnDiskId
When the columns are connected to a page source or page sink, the field represents a field id in the ...
ENTupleStructure fStructure
The role of this field in the data model structure.
void AutoAdjustColumnTypes(const RNTupleWriteOptions &options)
When connecting a field to a page sink, the field's default column representation is subject to adjus...
std::vector< std::unique_ptr< RColumn > > fColumns
The columns are connected either to a sink or to a source (not to both); they are owned by the field.
void Read(const RClusterIndex &clusterIndex, void *to)
std::string GetQualifiedFieldName() const
Returns the field name and parent field names separated by dots ("grandparent.parent....
const ColumnRepresentation_t & GetColumnRepresentative() const
Returns the fColumnRepresentative pointee or, if unset, the field's default representative.
static constexpr int kTraitMappable
A field of a fundamental type that can be directly mapped via RField<T>::Map(), i....
EState
During its lifetime, a field undergoes the following possible state transitions:
void Attach(std::unique_ptr< Detail::RFieldBase > child)
Add a new subfield to the list of nested fields.
std::vector< RFieldBase * > GetSubFields() const
bool HasReadCallbacks() const
static void CallReadOn(RFieldBase &other, NTupleSize_t globalIndex, void *to)
RFieldBase & operator=(const RFieldBase &)=delete
void SetColumnRepresentative(const ColumnRepresentation_t &representative)
Fixes a column representative.
ENTupleStructure GetStructure() const
bool HasDefaultColumnRepresentative() const
Whether or not an explicit column representative was set.
void ConnectPageSink(RPageSink &pageSink, NTupleSize_t firstEntry=0)
Fields and their columns live in the void until connected to a physical page storage.
static void CallDestroyValueOn(const RFieldBase &other, void *objPtr, bool dtorOnly=false)
RValue BindValue(void *where)
Creates a value from a memory location with an already constructed object.
RConstSchemaIterator cbegin() const
static constexpr int kTraitTriviallyConstructible
No constructor needs to be called, i.e.
static constexpr int kTraitTriviallyDestructible
The type is cleaned up just by freeing its memory. I.e. DestroyValue() is a no-op.
const ColumnRepresentation_t & EnsureCompatibleColumnTypes(const RNTupleDescriptor &desc) const
Returns the on-disk column types found in the provided descriptor for fOnDiskId.
NTupleSize_t EntryToColumnElementIndex(NTupleSize_t globalIndex) const
Translate an entry index to a column element index of the principal column and viceversa.
std::size_t ReadBulk(const RBulkSpec &bulkSpec)
Returns the number of newly available values, that is the number of bools in bulkSpec....
std::vector< ReadCallback_t > fReadCallbacks
List of functions to be called after reading a value.
std::vector< EColumnType > ColumnRepresentation_t
RColumn * fPrincipalColumn
Points into fColumns.
Abstract base class for classes implementing the visitor design pattern.
Abstract interface to write data into an ntuple.
Abstract interface to read data from an ntuple.
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 DestroyValue(void *objPtr, bool dtorOnly=false) const final
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
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.
void ReadInClusterImpl(const RClusterIndex &clusterIndex, void *to) final
void GenerateValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Gener...
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.
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
~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)
The field for a class with dictionary.
static constexpr const char * kPrefixInherited
Prefix used in the subfield names generated for base classes.
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 Attach(std::unique_ptr< Detail::RFieldBase > child, RSubFieldInfo info)
void DestroyValue(void *objPtr, bool dtorOnly=false) const final
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
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.
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given a value for this field.
void GenerateColumnsImpl(const RNTupleDescriptor &) final
Creates the backing columns corresponsing to the field type for reading.
void ReadInClusterImpl(const RClusterIndex &clusterIndex, void *to) final
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
std::vector< RSubFieldInfo > fSubFieldsInfo
Additional information kept for each entry in fSubFields
std::size_t fMaxAlignment
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 ...
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::shared_ptr< RCollectionNTupleWriter > fCollectionNTuple
Save the link to the collection ntuple in order to reset the offset counter when committing the clust...
~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.
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 GenerateValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Gener...
Base class for all ROOT issued exceptions.
The container field for an ntuple model, which itself has no physical representation.
void GenerateValue(void *) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Gener...
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.
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const override
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.
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 GetCollectionInfo(const RClusterIndex &clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size)
ClusterSize_t * MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
static std::string TypeName()
RField(std::string_view name)
ClusterSize_t * Map(const RClusterIndex &clusterIndex)
~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)
ClusterSize_t * MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems)
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.
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
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.
RField(RField &&other)=default
void ReadInClusterImpl(const RClusterIndex &clusterIndex, void *to) final
Get the number of elements of the collection identified by clusterIndex.
void GenerateValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Gener...
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.
std::unique_ptr< ROOT::Experimental::Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
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
RField(RField &&other)=default
RField(std::string_view fieldName, std::unique_ptr< Detail::RFieldBase > itemField)
std::unique_ptr< Detail::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.
void DestroyValue(void *objPtr, bool dtorOnly=false) const final
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
void GenerateValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Gener...
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.
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
bool * MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems)
~RField() override=default
static std::string TypeName()
RField(RField &&other)=default
bool * Map(const RClusterIndex &clusterIndex)
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.
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
std::unique_ptr< Detail::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(const RClusterIndex &clusterIndex, NTupleSize_t &nItems)
static std::string TypeName()
~RField() override=default
char * Map(const RClusterIndex &clusterIndex)
double * Map(const RClusterIndex &clusterIndex)
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
double * MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
double * MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems)
RField(std::string_view name)
~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.
static std::string TypeName()
RField(RField &&other)=default
float * MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
float * MapV(const RClusterIndex &clusterIndex, 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.
float * Map(NTupleSize_t globalIndex)
float * Map(const RClusterIndex &clusterIndex)
~RField() override=default
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Classes with dictionaries that can be inspected by TClass.
RField(std::string_view name)
void GenerateValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Gener...
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< Detail::RFieldBase >, 2 > &itemFields)
RPairField(RPairField &&other)=default
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.
The field for a class representing a collection of elements via TVirtualCollectionProxy.
void GetCollectionInfo(const RClusterIndex &clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
RCollectionIterableOnce::RIteratorFuncs fIFuncsRead
Two sets of functions to operate on iterators, to be used depending on the access type.
std::unique_ptr< TVirtualCollectionProxy > fProxy
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 type-erased field for a RVec<Type>
RRVecField(RRVecField &&)=default
~RRVecField() override=default
void GetCollectionInfo(const RClusterIndex &clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
RRVecField(const RRVecField &)=delete
RRVecField & operator=(RRVecField &&)=default
RRVecField & operator=(RRVecField &)=delete
void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
The field for an untyped record.
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
RRecordField(std::string_view fieldName, std::array< std::unique_ptr< Detail::RFieldBase >, N > &&itemFields, const std::array< std::size_t, N > &offsets, std::string_view typeName="")
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
The generic field for std::tuple<Ts...> types.
static std::string GetTypeList(const std::vector< std::unique_ptr< Detail::RFieldBase > > &itemFields)
RTupleField & operator=(RTupleField &&other)=default
~RTupleField() override=default
RTupleField(RTupleField &&other)=default
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
void GenerateValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Gener...
The generic field for std::variant types.
std::vector< ClusterSize_t::ValueType > fNWritten
The generic field for a (nested) std::vector<Type> except for std::vector<bool>
~RVectorField() override=default
size_t GetValueSize() const override
The number of bytes taken by a value of the appropriate type.
void GetCollectionInfo(const RClusterIndex &clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
void GetCollectionInfo(NTupleSize_t globalIndex, 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.
void CommitClusterImpl() final
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.
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.
Input parameter to ReadBulk() and ReadBulkImpl(). See RBulk class for more information.
bool * fMaskAvail
A bool array of size fCount, indicating the valid values in fValues.
std::vector< unsigned char > * fAuxData
Reference to memory owned by the RBulk class.
const bool * fMaskReq
A bool array of size fCount, indicating the required values in the requested range.
void * fValues
The destination area, which has to be a big enough array of valid objects of the correct type.
RClusterIndex fFirstIndex
Start of the bulk range.
static const std::size_t kAllSet
As a return value of ReadBulk and ReadBulkImpl(), indicates that the full bulk range was read indepen...
std::size_t fCount
Size of the bulk range.
Position(FieldPtr_t fieldPtr, int idxInParent)
std::conditional_t< IsConstT, const RFieldBase *, RFieldBase * > FieldPtr_t
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::uint32_t.
Helper types to present an offset column as array of collection sizes.
TVirtualCollectionProxy::Next_t fNext
TVirtualCollectionProxy::DeleteTwoIterators_t fDeleteTwoIterators
TVirtualCollectionProxy::CreateIterators_t fCreateIterators