52namespace Experimental {
54class RCollectionField;
55class RCollectionNTupleWriter;
60struct RFieldCallbackInjector;
243 std::size_t nRepetitions = 0);
286 return value.fMappedElement.GetSize();
323 void Attach(std::unique_ptr<Detail::RFieldBase>
child);
361 RSchemaIterator
begin();
362 RSchemaIterator
end();
438 void AcceptVisitor(Detail::RFieldVisitor &visitor) const override;
452 static constexpr const std::size_t kReadChunkSize = 64 * 1024;
453 std::unique_ptr<TVirtualCollectionProxy>
fProxy;
479 size_t GetAlignment() const final {
return alignof(std::max_align_t); }
481 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
500 std::size_t GetItemPadding(std::size_t baseOffset, std::size_t itemAlignment)
const;
512 template <std::
size_t N>
518 for (
unsigned i = 0; i <
N; ++i) {
519 fOffsets.push_back(offsets[i]);
522 fTraits &= itemFields[i]->GetTraits();
523 Attach(std::move(itemFields[i]));
570 size_t GetValueSize()
const override {
return sizeof(std::vector<char>); }
571 size_t GetAlignment() const final {
return std::alignment_of<std::vector<char>>(); }
573 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
587 std::size_t EvalValueSize()
const;
617 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
653 size_t GetLength()
const {
return fArrayLength; }
662 size_t fMaxItemSize = 0;
665 size_t fTagOffset = 0;
668 static std::string GetTypeList(
const std::vector<Detail::RFieldBase *> &itemFields);
670 std::uint32_t GetTag(
void *variantPtr)
const;
671 void SetTag(
void *variantPtr, std::uint32_t tag)
const;
699template <typename
T, typename=
void>
711 template <
typename... ArgsT>
719template <
typename T,
typename =
void>
724 T, typename std::enable_if<std::is_same<typename T::IsCollectionProxy, std::true_type>::value>
::type>
765template <
typename T,
typename =
void>
796 template <
typename... ArgsT>
799 return Detail::RFieldValue(
this,
static_cast<T*
>(where), std::forward<ArgsT>(args)...);
817 static std::
string TypeName() {
return ""; }
819 std::shared_ptr<RCollectionNTupleWriter> collectionNTuple,
820 std::unique_ptr<RNTupleModel> collectionModel);
843 static std::string
GetTypeList(
const std::array<std::unique_ptr<Detail::RFieldBase>, 2> &itemFields);
849 const std::array<std::size_t, 2> &offsets);
866 static std::string
GetTypeList(
const std::vector<std::unique_ptr<Detail::RFieldBase>> &itemFields);
872 const std::vector<std::size_t> &offsets);
892 return std::make_unique<RField>(newName);
900 static std::
string TypeName() {
return "ROOT::Experimental::ClusterSize_t"; }
924 template <
typename... ArgsT>
929 this,
static_cast<ClusterSize_t*
>(where), std::forward<ArgsT>(args)...);
956 return std::make_unique<RField<RNTupleCardinality>>(newName);
965 static std::string
TypeName() {
return "ROOT::Experimental::RNTupleCardinality"; }
975 template <
typename... ArgsT>
1012 return std::make_unique<RField>(newName);
1020 static std::
string TypeName() {
return "bool"; }
1044 template <
typename... ArgsT>
1049 this,
static_cast<bool*
>(where), std::forward<ArgsT>(args)...);
1064 return std::make_unique<RField>(newName);
1072 static std::
string TypeName() {
return "float"; }
1096 template <
typename... ArgsT>
1101 this,
static_cast<float*
>(where), std::forward<ArgsT>(args)...);
1117 return std::make_unique<RField>(newName);
1125 static std::
string TypeName() {
return "double"; }
1149 template <
typename... ArgsT>
1154 this,
static_cast<double*
>(where), std::forward<ArgsT>(args)...);
1169 return std::make_unique<RField>(newName);
1177 static std::
string TypeName() {
return "char"; }
1201 template <
typename... ArgsT>
1206 this,
static_cast<char*
>(where), std::forward<ArgsT>(args)...);
1218class RField<std::int8_t> :
public Detail::RFieldBase {
1221 return std::make_unique<RField>(newName);
1229 static std::
string TypeName() {
return "std::int8_t"; }
1242 std::int8_t *
Map(
const RClusterIndex &clusterIndex) {
1248 std::int8_t *MapV(
const RClusterIndex &clusterIndex,
NTupleSize_t &nItems) {
1253 template <
typename... ArgsT>
1256 return Detail::RFieldValue(
1257 Detail::RColumnElement<std::int8_t>(
static_cast<std::int8_t*
>(where)),
1258 this,
static_cast<std::int8_t*
>(where), std::forward<ArgsT>(args)...);
1262 return Detail::RFieldValue(
true ,
1263 Detail::RColumnElement<std::int8_t>(
static_cast<std::int8_t*
>(where)),
this, where);
1265 size_t GetValueSize() const final {
return sizeof(std::int8_t); }
1266 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
1270class RField<std::uint8_t> :
public Detail::RFieldBase {
1273 return std::make_unique<RField>(newName);
1281 static std::
string TypeName() {
return "std::uint8_t"; }
1294 std::uint8_t *
Map(
const RClusterIndex &clusterIndex) {
1300 std::uint8_t *MapV(
const RClusterIndex &clusterIndex,
NTupleSize_t &nItems) {
1305 template <
typename... ArgsT>
1308 return Detail::RFieldValue(
1309 Detail::RColumnElement<std::uint8_t>(
static_cast<std::uint8_t*
>(where)),
1310 this,
static_cast<std::uint8_t*
>(where), std::forward<ArgsT>(args)...);
1314 return Detail::RFieldValue(
true ,
1315 Detail::RColumnElement<std::uint8_t>(
static_cast<std::uint8_t*
>(where)),
this, where);
1317 size_t GetValueSize() const final {
return sizeof(std::uint8_t); }
1318 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
1322class RField<std::int16_t> :
public Detail::RFieldBase {
1325 return std::make_unique<RField>(newName);
1333 static std::
string TypeName() {
return "std::int16_t"; }
1346 std::int16_t *
Map(
const RClusterIndex &clusterIndex) {
1352 std::int16_t *MapV(
const RClusterIndex &clusterIndex,
NTupleSize_t &nItems) {
1357 template <
typename... ArgsT>
1360 return Detail::RFieldValue(
1361 Detail::RColumnElement<std::int16_t>(
static_cast<std::int16_t*
>(where)),
1362 this,
static_cast<std::int16_t*
>(where), std::forward<ArgsT>(args)...);
1366 return Detail::RFieldValue(
true ,
1367 Detail::RColumnElement<std::int16_t>(
static_cast<std::int16_t*
>(where)),
this, where);
1369 size_t GetValueSize() const final {
return sizeof(std::int16_t); }
1370 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
1374class RField<std::uint16_t> :
public Detail::RFieldBase {
1377 return std::make_unique<RField>(newName);
1385 static std::
string TypeName() {
return "std::uint16_t"; }
1398 std::uint16_t *
Map(
const RClusterIndex &clusterIndex) {
1404 std::uint16_t *MapV(
const RClusterIndex &clusterIndex,
NTupleSize_t &nItems) {
1409 template <
typename... ArgsT>
1412 return Detail::RFieldValue(
1413 Detail::RColumnElement<std::uint16_t>(
static_cast<std::uint16_t*
>(where)),
1414 this,
static_cast<std::uint16_t*
>(where), std::forward<ArgsT>(args)...);
1418 return Detail::RFieldValue(
true ,
1419 Detail::RColumnElement<std::uint16_t>(
static_cast<std::uint16_t*
>(where)),
this, where);
1421 size_t GetValueSize() const final {
return sizeof(std::uint16_t); }
1422 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
1426class RField<std::int32_t> :
public Detail::RFieldBase {
1429 return std::make_unique<RField>(newName);
1437 static std::
string TypeName() {
return "std::int32_t"; }
1450 std::int32_t *
Map(
const RClusterIndex &clusterIndex) {
1456 std::int32_t *MapV(
const RClusterIndex &clusterIndex,
NTupleSize_t &nItems) {
1461 template <
typename... ArgsT>
1464 return Detail::RFieldValue(
1465 Detail::RColumnElement<std::int32_t>(
static_cast<std::int32_t*
>(where)),
1466 this,
static_cast<std::int32_t*
>(where), std::forward<ArgsT>(args)...);
1470 return Detail::RFieldValue(
true ,
1471 Detail::RColumnElement<std::int32_t>(
static_cast<std::int32_t*
>(where)),
this, where);
1473 size_t GetValueSize() const final {
return sizeof(std::int32_t); }
1474 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
1478class RField<std::uint32_t> :
public Detail::RFieldBase {
1481 return std::make_unique<RField>(newName);
1489 static std::
string TypeName() {
return "std::uint32_t"; }
1502 std::uint32_t *
Map(
const RClusterIndex clusterIndex) {
1508 std::uint32_t *MapV(
const RClusterIndex &clusterIndex,
NTupleSize_t &nItems) {
1513 template <
typename... ArgsT>
1516 return Detail::RFieldValue(
1517 Detail::RColumnElement<std::uint32_t>(
static_cast<std::uint32_t*
>(where)),
1518 this,
static_cast<std::uint32_t*
>(where), std::forward<ArgsT>(args)...);
1522 return Detail::RFieldValue(
true ,
1523 Detail::RColumnElement<std::uint32_t>(
static_cast<std::uint32_t*
>(where)),
this, where);
1525 size_t GetValueSize() const final {
return sizeof(std::uint32_t); }
1526 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
1530class RField<std::uint64_t> :
public Detail::RFieldBase {
1533 return std::make_unique<RField>(newName);
1541 static std::
string TypeName() {
return "std::uint64_t"; }
1554 std::uint64_t *
Map(
const RClusterIndex &clusterIndex) {
1560 std::uint64_t *MapV(
const RClusterIndex &clusterIndex,
NTupleSize_t &nItems) {
1565 template <
typename... ArgsT>
1568 return Detail::RFieldValue(
1569 Detail::RColumnElement<std::uint64_t>(
static_cast<std::uint64_t*
>(where)),
1570 this,
static_cast<std::uint64_t*
>(where), std::forward<ArgsT>(args)...);
1574 return Detail::RFieldValue(
true ,
1575 Detail::RColumnElement<std::uint64_t>(
static_cast<std::uint64_t*
>(where)),
this, where);
1577 size_t GetValueSize() const final {
return sizeof(std::uint64_t); }
1578 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
1582class RField<std::int64_t> :
public Detail::RFieldBase {
1585 return std::make_unique<RField>(newName);
1593 static std::
string TypeName() {
return "std::int64_t"; }
1606 std::int64_t *
Map(
const RClusterIndex &clusterIndex) {
1612 std::int64_t *MapV(
const RClusterIndex &clusterIndex,
NTupleSize_t &nItems) {
1617 template <
typename... ArgsT>
1620 return Detail::RFieldValue(
1621 Detail::RColumnElement<std::int64_t>(
static_cast<std::int64_t*
>(where)),
1622 this,
static_cast<std::int64_t*
>(where), std::forward<ArgsT>(args)...);
1626 return Detail::RFieldValue(
true ,
1627 Detail::RColumnElement<std::int64_t>(
static_cast<std::int64_t*
>(where)),
this, where);
1629 size_t GetValueSize() const final {
return sizeof(std::int64_t); }
1630 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
1634class RField<std::string> :
public Detail::RFieldBase {
1637 Detail::RColumnElement<ClusterSize_t, EColumnType::kIndex> fElemIndex;
1640 return std::make_unique<RField>(newName);
1650 static std::
string TypeName() {
return "std::string"; }
1661 template <
typename... ArgsT>
1664 return Detail::RFieldValue(
this,
static_cast<std::string*
>(where), std::forward<ArgsT>(args)...);
1667 void DestroyValue(
const Detail::RFieldValue&
value,
bool dtorOnly =
false)
override {
1668 auto str =
value.Get<std::string>();
1669 str->~basic_string();
1673 Detail::RFieldValue
CaptureValue(
void *where)
override {
1674 return Detail::RFieldValue(
true ,
this, where);
1676 size_t GetValueSize() const final {
return sizeof(std::string); }
1677 size_t GetAlignment() const final {
return std::alignment_of<std::string>(); }
1679 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
1683template <typename ItemT, std::
size_t N>
1684class
RField<std::array<ItemT,
N>> : public RArrayField {
1685 using ContainerT =
typename std::array<ItemT, N>;
1687 static std::string TypeName() {
1691 : RArrayField(
name, std::make_unique<
RField<ItemT>>(
RField<ItemT>::TypeName()),
N)
1698 template <
typename... ArgsT>
1701 return Detail::RFieldValue(
this,
static_cast<ContainerT*
>(where), std::forward<ArgsT>(args)...);
1708template <
typename ItemT, std::
size_t N>
1717template <
typename... ItemTs>
1719 using ContainerT =
typename std::variant<ItemTs...>;
1721 template <
typename HeadT,
typename... TailTs>
1722 static std::string BuildItemTypes()
1725 if constexpr(
sizeof...(TailTs) > 0)
1726 result +=
"," + BuildItemTypes<TailTs...>();
1730 template <
typename HeadT,
typename... TailTs>
1731 static std::vector<Detail::RFieldBase *> BuildItemFields(
unsigned int index = 0)
1733 std::vector<Detail::RFieldBase *>
result;
1735 if constexpr(
sizeof...(TailTs) > 0) {
1736 auto tailFields = BuildItemFields<TailTs...>(
index + 1);
1737 result.insert(
result.end(), tailFields.begin(), tailFields.end());
1743 static std::string TypeName() {
return "std::variant<" + BuildItemTypes<ItemTs...>() +
">"; }
1750 template <
typename... ArgsT>
1753 return Detail::RFieldValue(
this,
static_cast<ContainerT*
>(where), std::forward<ArgsT>(args)...);
1760template <
typename ItemT>
1761class RField<std::vector<ItemT>> :
public RVectorField {
1762 using ContainerT =
typename std::vector<ItemT>;
1766 : RVectorField(
name, std::make_unique<
RField<ItemT>>(
"_0"))
1773 template <
typename... ArgsT>
1776 return Detail::RFieldValue(
this,
static_cast<ContainerT*
>(where), std::forward<ArgsT>(args)...);
1782 return Detail::RFieldValue(
true ,
this, where);
1784 size_t GetValueSize() const final {
return sizeof(ContainerT); }
1789class RField<std::vector<bool>> :
public Detail::RFieldBase {
1795 return std::make_unique<RField>(newName);
1805 static std::
string TypeName() {
return "std::vector<bool>"; }
1812 template <
typename... ArgsT>
1815 return Detail::RFieldValue(
this,
static_cast<std::vector<bool>*
>(where), std::forward<ArgsT>(args)...);
1821 return Detail::RFieldValue(
true ,
this, where);
1823 std::vector<Detail::RFieldValue>
SplitValue(
const Detail::RFieldValue &
value)
const final;
1824 void DestroyValue(
const Detail::RFieldValue&
value,
bool dtorOnly =
false) final;
1826 size_t GetValueSize() const final {
return sizeof(std::vector<bool>); }
1827 size_t GetAlignment() const final {
return std::alignment_of<std::vector<bool>>(); }
1829 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
1833 void GetCollectionInfo(
const RClusterIndex &clusterIndex, RClusterIndex *collectionStart,
ClusterSize_t *
size)
const
1839template <
typename ItemT>
1845 return std::make_unique<RField<ROOT::VecOps::RVec<ItemT>>>(newName, std::move(newItemField));
1850 auto count = typedValue->size();
1851 for (
unsigned i = 0; i < count; ++i) {
1852 auto itemValue =
fSubFields[0]->CaptureValue(&typedValue->data()[i]);
1856 this->fNWritten += count;
1858 return nbytes +
sizeof(elemIndex);
1865 typedValue->resize(nItems);
1866 for (
unsigned i = 0; i < nItems; ++i) {
1867 auto itemValue =
fSubFields[0]->CaptureValue(&typedValue->data()[i]);
1868 fSubFields[0]->Read(collectionStart + i, &itemValue);
1874 :
RRVecField(fieldName, std::move(itemField))
1896 template <
typename... ArgsT>
1908 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
1911template <
typename T1,
typename T2>
1912class RField<std::pair<T1, T2>> :
public RPairField {
1913 using ContainerT =
typename std::pair<T1,T2>;
1915 template <
typename Ty1,
typename Ty2>
1916 static std::array<std::unique_ptr<Detail::RFieldBase>, 2> BuildItemFields()
1918 return {std::make_unique<RField<Ty1>>(
"_0"), std::make_unique<
RField<Ty2>>(
"_1")};
1926 return std::make_unique<RField<std::pair<T1, T2>>>(newName, std::move(items));
1930 static std::string TypeName() {
1934 : RPairField(
name, std::move(itemFields), {offsetof(ContainerT,
first), offsetof(ContainerT,
second)})
1937 fSize =
sizeof(ContainerT);
1945 template <
typename... ArgsT>
1948 return Detail::RFieldValue(
this,
static_cast<ContainerT*
>(where), std::forward<ArgsT>(args)...);
1953 void DestroyValue(
const Detail::RFieldValue &
value,
bool dtorOnly =
false) final
1955 reinterpret_cast<ContainerT *
>(
value.GetRawPtr())->~pair();
1957 free(
reinterpret_cast<ContainerT *
>(
value.GetRawPtr()));
1961template <
typename... ItemTs>
1962class RField<std::tuple<ItemTs...>> :
public RTupleField {
1963 using ContainerT =
typename std::tuple<ItemTs...>;
1965 template <
typename HeadT,
typename... TailTs>
1966 static std::string BuildItemTypes()
1969 if constexpr (
sizeof...(TailTs) > 0)
1970 result +=
"," + BuildItemTypes<TailTs...>();
1974 template <
typename HeadT,
typename... TailTs>
1975 static void _BuildItemFields(std::vector<std::unique_ptr<Detail::RFieldBase>> &itemFields,
unsigned int index = 0)
1978 if constexpr (
sizeof...(TailTs) > 0)
1979 _BuildItemFields<TailTs...>(itemFields,
index + 1);
1981 template <
typename... Ts>
1982 static std::vector<std::unique_ptr<Detail::RFieldBase>> BuildItemFields()
1984 std::vector<std::unique_ptr<Detail::RFieldBase>>
result;
1985 _BuildItemFields<Ts...>(
result);
1989 template <
unsigned Index,
typename HeadT,
typename... TailTs>
1990 static void _BuildItemOffsets(std::vector<std::size_t> &offsets,
const ContainerT &tuple)
1993 reinterpret_cast<std::uintptr_t
>(&std::get<Index>(tuple)) -
reinterpret_cast<std::uintptr_t
>(&tuple);
1994 offsets.emplace_back(
offset);
1995 if constexpr (
sizeof...(TailTs) > 0)
1996 _BuildItemOffsets<
Index + 1, TailTs...>(offsets, tuple);
1998 template <
typename... Ts>
1999 static std::vector<std::size_t> BuildItemOffsets()
2001 std::vector<std::size_t>
result;
2002 _BuildItemOffsets<0, Ts...>(
result, ContainerT());
2009 std::vector<std::unique_ptr<Detail::RFieldBase>> items;
2011 items.push_back(item->Clone(item->GetName()));
2012 return std::make_unique<
RField<std::tuple<ItemTs...>>>(newName, std::move(items));
2016 static std::string TypeName() {
return "std::tuple<" + BuildItemTypes<ItemTs...>() +
">"; }
2018 : RTupleField(
name, std::move(itemFields), BuildItemOffsets<ItemTs...>())
2021 fSize =
sizeof(ContainerT);
2029 template <
typename... ArgsT>
2032 return Detail::RFieldValue(
this,
static_cast<ContainerT *
>(where), std::forward<ArgsT>(args)...);
2038 void DestroyValue(
const Detail::RFieldValue &
value,
bool dtorOnly =
false) final
2040 reinterpret_cast<ContainerT *
>(
value.GetRawPtr())->~tuple();
2042 free(
reinterpret_cast<ContainerT *
>(
value.GetRawPtr()));
#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
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 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 id
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
Pairs of C++ type and column type, like float and EColumnType::kReal32.
void Append(const RColumnElementBase &element)
CppT * MapV(const NTupleSize_t globalIndex, NTupleSize_t &nItems)
CppT * Map(const NTupleSize_t globalIndex)
void Read(const NTupleSize_t globalIndex, RColumnElementBase *element)
NTupleSize_t GetGlobalIndex(const RClusterIndex &clusterIndex)
NTupleSize_t GetNElements() const
void GetCollectionInfo(const NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *collectionSize)
For offset columns only, look at the two adjacent values that define a collection's coordinates.
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.
void Advance()
Given that the iterator points to a valid field which is not the end iterator, go to the next field i...
std::vector< Position > fStack
The stack of nodes visited when walking down the tree of fields.
std::ptrdiff_t difference_type
pointer operator->() const
bool operator!=(const iterator &rh) const
reference operator*() const
std::forward_iterator_tag iterator_category
RSchemaIterator(pointer val, int idxInParent)
bool operator==(const iterator &rh) const
virtual std::uint32_t GetFieldVersion() const
Indicates an evolution of the mapping scheme from C++ type to columns.
RFieldBase * GetParent() const
virtual RFieldValue CaptureValue(void *where)=0
Creates a value from a memory location with an already constructed object.
std::string GetDescription() const
Get the field's description.
static constexpr std::uint32_t kInvalidTypeVersion
void SetOnDiskId(DescriptorId_t id)
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.
std::vector< std::unique_ptr< RFieldBase > > fSubFields
Collections and classes own sub fields.
RFieldBase * fParent
Sub fields point to their mother field.
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.
std::size_t GetNRepetitions() const
std::string fDescription
Free text set by the user.
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
virtual void DestroyValue(const RFieldValue &value, bool dtorOnly=false)
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
DescriptorId_t GetOnDiskId() const
static constexpr int kTraitTrivialType
Shorthand for types that are both trivially constructible and destructible.
void ConnectPageSink(RPageSink &pageSink)
Fields and their columns live in the void until connected to a physical page storage.
std::uint32_t GetOnDiskTypeVersion() const
Return the C++ type version stored in the field descriptor; only valid after a call to ConnectPageSou...
void RemoveReadCallback(size_t idx)
void Flush() const
Ensure that all received items are written from page buffers to the storage.
virtual void ReadInClusterImpl(const RClusterIndex &clusterIndex, RFieldValue *value)
virtual void CommitCluster()
Perform housekeeping tasks for global to cluster-local index translation.
virtual size_t GetAlignment() const
For many types, the alignment requirement is equal to the size; otherwise override.
virtual std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const =0
Called by Clone(), which additionally copies the on-disk ID.
virtual size_t GetValueSize() const =0
The number of bytes taken by a value of the appropriate type.
void SetDescription(std::string_view description)
virtual std::vector< RFieldValue > SplitValue(const RFieldValue &value) const
Creates the list of direct child values given a value for this field.
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.
std::string fType
The C++ type captured by this field.
static RResult< std::unique_ptr< RFieldBase > > Create(const std::string &fieldName, const std::string &typeName)
Factory method to resurrect a field from the stored on-disk type information.
std::string fName
The field name relative to its parent field.
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
void ConnectPageSource(RPageSource &pageSource)
std::uint32_t fOnDiskTypeVersion
C++ type version cached from the descriptor after a call to ConnectPageSource()
std::size_t Append(const RFieldValue &value)
Write the given value into columns.
virtual std::size_t AppendImpl(const RFieldValue &value)
Operations on values of complex types, e.g.
std::function< void(RFieldValue &)> ReadCallback_t
virtual const RColumnRepresentations & GetColumnRepresentations() const
Implementations in derived classes should return a static RColumnRepresentations object.
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 ...
virtual void ReadGlobalImpl(NTupleSize_t globalIndex, RFieldValue *value)
ENTupleStructure fStructure
The role of this field in the data model structure.
void Read(const RClusterIndex &clusterIndex, RFieldValue *value)
void InvokeReadCallbacks(RFieldValue &value)
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.
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....
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
virtual RFieldValue GenerateValue(void *where)=0
Generates a tree value in a given location of size at least GetValueSize().
RFieldBase & operator=(const RFieldBase &)=delete
void SetColumnRepresentative(const ColumnRepresentation_t &representative)
Fixes a column representative.
ENTupleStructure GetStructure() const
void Read(NTupleSize_t globalIndex, RFieldValue *value)
Populate a single value with data from the tree, which needs to be of the fitting type.
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.
RFieldValue GenerateValue()
Generates an object of the field type and allocates new initialized memory according to the type.
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.
RArrayField(RArrayField &&other)=default
size_t GetAlignment() const final
For many types, the alignment requirement is equal to the size; otherwise override.
~RArrayField() override=default
The field for a class with dictionary.
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
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)
std::vector< Detail::RFieldValue > SplitValue(const Detail::RFieldValue &value) const final
Creates the list of direct child values given a value for this field.
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
std::size_t AppendImpl(const Detail::RFieldValue &value) final
Operations on values of complex types, e.g.
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.
RClassField & operator=(RClassField &&other)=default
void AcceptVisitor(Detail::RFieldVisitor &visitor) const override
size_t GetAlignment() const final
For many types, the alignment requirement is equal to the size; otherwise override.
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 ReadInClusterImpl(const RClusterIndex &clusterIndex, Detail::RFieldValue *value) final
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
RClassField(std::string_view fieldName, std::string_view className, TClass *classp)
std::vector< RSubFieldInfo > fSubFieldsInfo
Additional information kept for each entry in fSubFields
std::size_t fMaxAlignment
void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) final
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
The field for a class representing a collection of elements via TVirtualCollectionProxy.
std::unique_ptr< TVirtualCollectionProxy > fProxy
size_t GetAlignment() const final
For many types, the alignment requirement is equal to the size; otherwise override.
void GetCollectionInfo(const RClusterIndex &clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
The collection field is only used for writing; when reading, untyped collections are projected to an ...
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
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.
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
RCollectionField(RCollectionField &&other)=default
Base class for all ROOT issued exceptions.
A field translates read and write calls from/to underlying columns to/from tree values.
Represents transient storage of simple or complex C++ values.
The container field for an ntuple model, which itself has no physical representation.
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
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.
Detail::RFieldValue GenerateValue(void *) override
Generates a tree value in a given location of size at least GetValueSize().
Detail::RFieldValue CaptureValue(void *) final
Creates a value from a memory location with an already constructed object.
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)
RField(std::string_view name)
ClusterSize_t * Map(const RClusterIndex &clusterIndex)
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
~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.
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
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)
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
void ReadInClusterImpl(const RClusterIndex &clusterIndex, Detail::RFieldValue *value) final
Get the number of elements of the collection identified by clusterIndex.
RField & operator=(RField &&other)=default
RField(RField &&other)=default
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
void GenerateColumnsImpl(const RNTupleDescriptor &) final
Creates the backing columns corresponsing to the field type for reading.
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
Detail::RFieldValue CaptureValue(void *where) override
Creates a value from a memory location with an already constructed object.
std::unique_ptr< ROOT::Experimental::Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
static std::string TypeName()
RField(std::string_view name)
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&...args)
void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final
Get the number of elements of the collection identified by globalIndex.
RField(std::string_view name)
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
std::size_t AppendImpl(const Detail::RFieldValue &value) final
Operations on values of complex types, e.g.
typename ROOT::VecOps::RVec< ItemT > ContainerT
static std::string TypeName()
~RField() override=default
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
For many types, the alignment requirement is equal to the size; otherwise override.
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) final
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
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< 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
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
RField(RField &&other)=default
bool * Map(const RClusterIndex &clusterIndex)
bool * Map(NTupleSize_t globalIndex)
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
char * 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.
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
char * Map(NTupleSize_t globalIndex)
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
RField(RField &&other)=default
char * MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems)
~RField() override=default
char * Map(const RClusterIndex &clusterIndex)
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
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)
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
RField(RField &&other)=default
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
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)
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
float * Map(NTupleSize_t globalIndex)
float * Map(const RClusterIndex &clusterIndex)
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
~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)
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&...args)
RField & operator=(RField &&other)=default
RField(RField &&other)=default
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
static std::string TypeName()
~RField() override=default
The on-storage meta-data of an ntuple.
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
The type-erased field for a RVec<Type>
void GetCollectionInfo(const RClusterIndex &clusterIndex, 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
For many types, the alignment requirement is equal to the size; otherwise override.
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.
RResult<void> has no data member and no Inspect() method but instead a Success() factory method.
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 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
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>
void GetCollectionInfo(const RClusterIndex &clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
size_t GetAlignment() const final
For many types, the alignment requirement is equal to the size; otherwise override.
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.
RooCmdArg Index(RooCategory &icat)
auto Map(Args &&... args)
Create new collection applying a callable to the elements of the input collection.
basic_string_view< char > string_view
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
void(off) SmallVectorTemplateBase< T
std::string GetDemangledTypeName(const std::type_info &t)
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
static constexpr double second
Position(RFieldBase *fieldPtr, int idxInParent)
The point here is that we can only tell at run time if a class has an associated collection proxy.
Wrap the 32bit integer in a struct in order to avoid template specialization clash with std::uint32_t...
Helper type to present an offset column as array of collection sizes. See RField<RNTupleCardinality> ...