18 "std::array<" +
itemField->GetTypeName() +
"," +
30 auto newItemField = fSubfields[0]->Clone(fSubfields[0]->GetFieldName());
37 if (fSubfields[0]->IsSimple()) {
38 GetPrincipalColumnOf(*fSubfields[0])->AppendV(from, fArrayLength);
39 nbytes += fArrayLength * GetPrincipalColumnOf(*fSubfields[0])->GetElement()->GetPackedSize();
41 auto arrayPtr =
static_cast<const unsigned char *
>(from);
42 for (
unsigned i = 0; i < fArrayLength; ++i) {
43 nbytes += CallAppendOn(*fSubfields[0],
arrayPtr + (i * fItemSize));
51 if (fSubfields[0]->IsSimple()) {
52 GetPrincipalColumnOf(*fSubfields[0])->ReadV(
globalIndex * fArrayLength, fArrayLength, to);
54 auto arrayPtr =
static_cast<unsigned char *
>(to);
55 for (
unsigned i = 0; i < fArrayLength; ++i) {
63 if (fSubfields[0]->IsSimple()) {
64 GetPrincipalColumnOf(*fSubfields[0])
68 auto arrayPtr =
static_cast<unsigned char *
>(to);
69 for (
unsigned i = 0; i < fArrayLength; ++i) {
70 CallReadOn(*fSubfields[0],
79 static const std::vector<std::string>
prefixes = {
"std::array<"};
82 EnsureMatchingOnDiskField(
fieldDesc, kDiffTypeName);
88 if (fSubfields[0]->GetTraits() & kTraitTriviallyConstructible)
92 for (
unsigned i = 0; i < fArrayLength; ++i) {
93 CallConstructValueOn(*fSubfields[0],
arrayPtr + (i * fItemSize));
100 for (
unsigned i = 0; i < fArrayLength; ++i) {
101 fItemDeleter->operator()(
reinterpret_cast<unsigned char *
>(
objPtr) + i * fItemSize,
true );
109 if (!(fSubfields[0]->GetTraits() & kTraitTriviallyDestructible))
110 return std::make_unique<RArrayDeleter>(fItemSize, fArrayLength, GetDeleterOf(*fSubfields[0]));
111 return std::make_unique<RDeleter>();
118 std::vector<RValue>
result;
119 result.reserve(fArrayLength);
120 for (
unsigned i = 0; i < fArrayLength; ++i) {
121 result.emplace_back(fSubfields[0]->BindValue(std::shared_ptr<void>(
valuePtr,
arrayPtr + (i * fItemSize))));
128 visitor.VisitArrayField(*
this);
139 void **begin =
reinterpret_cast<void **
>(
rvecPtr);
141 std::int32_t *
size =
reinterpret_cast<std::int32_t *
>(begin + 1);
144 std::int32_t *capacity =
size + 1;
146 return {begin,
size, capacity};
168 constexpr auto dataMemberSz =
sizeof(
void *) + 2 *
sizeof(std::int32_t);
174 constexpr unsigned maxInlineByteSize = 1024;
176 elementsPerCacheLine >= 8 ? elementsPerCacheLine : (
sizeOfT * 8 > maxInlineByteSize ? 0 : 8);
198 return std::max({
alignof(
void *),
alignof(std::int32_t),
alignOfSubfield});
205 constexpr auto dataMemberSz =
sizeof(
void *) + 2 *
sizeof(std::int32_t);
212 if (!isSmall &&
owns)
232 auto newItemField = fSubfields[0]->Clone(fSubfields[0]->GetFieldName());
241 if (fSubfields[0]->IsSimple() && *
sizePtr) {
243 nbytes += *
sizePtr * GetPrincipalColumnOf(*fSubfields[0])->GetElement()->GetPackedSize();
245 auto begin =
reinterpret_cast<const char *
>(*beginPtr);
246 for (std::int32_t i = 0; i < *
sizePtr; ++i) {
247 nbytes += CallAppendOn(*fSubfields[0], begin + i * fItemSize);
252 fPrincipalColumn->Append(&fNWritten);
253 return nbytes + fPrincipalColumn->GetElement()->GetPackedSize();
267 char *begin =
reinterpret_cast<char *
>(*beginPtr);
273 const bool needsConstruct = !(fSubfields[0]->GetTraits() & kTraitTriviallyConstructible);
279 fItemDeleter->operator()(begin + (i * fItemSize),
true );
288 for (std::size_t i = 0
u; i <
oldSize; ++i) {
289 fItemDeleter->operator()(begin + (i * fItemSize),
true );
302 begin =
reinterpret_cast<char *
>(*beginPtr);
307 for (std::size_t i = 0
u; i <
oldSize; ++i)
308 CallConstructValueOn(*fSubfields[0], begin + (i * fItemSize));
316 CallConstructValueOn(*fSubfields[0], begin + (i * fItemSize));
319 if (fSubfields[0]->IsSimple() &&
nItems) {
325 for (std::size_t i = 0; i <
nItems; ++i) {
326 CallReadOn(*fSubfields[0],
collectionStart + i, begin + (i * fItemSize));
332 if (!fSubfields[0]->IsSimple())
338 bulkSpec.fAuxData->resize(
sizeof(std::size_t));
339 *
reinterpret_cast<std::size_t *
>(
bulkSpec.fAuxData->data()) = fSubfields[0]->GetValueSize();
365 for (std::size_t i = 0; i <
nBatch; ++i) {
385 for (std::size_t i = 0; i <
bulkSpec.fCount; ++i) {
392 return RBulkSpec::kAllSet;
425 std::int32_t *
sizePtr =
new (
reinterpret_cast<void *
>(
beginPtr + 1)) std::int32_t(0);
426 new (
sizePtr + 1) std::int32_t(-1);
433 char *begin =
reinterpret_cast<char *
>(*beginPtr);
435 for (std::int32_t i = 0; i < *
sizePtr; ++i) {
436 fItemDeleter->operator()(begin + i * fItemSize,
true );
447 return std::make_unique<RRVecDeleter>(fSubfields[0]->GetAlignment(), fItemSize, GetDeleterOf(*fSubfields[0]));
448 return std::make_unique<RRVecDeleter>(fSubfields[0]->GetAlignment());
455 std::vector<RValue>
result;
456 char *begin =
reinterpret_cast<char *
>(*beginPtr);
458 for (std::int32_t i = 0; i < *
sizePtr; ++i) {
459 result.emplace_back(fSubfields[0]->BindValue(std::shared_ptr<void>(
value.GetPtr<
void>(), begin + i * fItemSize)));
501std::unique_ptr<ROOT::RVectorField>
509 auto newItemField = fSubfields[0]->Clone(fSubfields[0]->GetFieldName());
510 auto isUntyped = GetTypeName().empty() || ((fTraits & kTraitEmulatedField) != 0);
517 auto typedValue =
static_cast<const std::vector<char> *
>(from);
526 if (fSubfields[0]->IsSimple() && count) {
527 GetPrincipalColumnOf(*fSubfields[0])->AppendV(
typedValue->data(), count);
528 nbytes += count * GetPrincipalColumnOf(*fSubfields[0])->GetElement()->GetPackedSize();
530 for (
unsigned i = 0; i < count; ++i) {
531 nbytes += CallAppendOn(*fSubfields[0],
typedValue->data() + (i * fItemSize));
536 fPrincipalColumn->Append(&fNWritten);
537 return nbytes + fPrincipalColumn->GetElement()->GetPackedSize();
542 auto typedValue =
static_cast<std::vector<char> *
>(to);
548 if (fSubfields[0]->IsSimple()) {
563 fItemDeleter->operator()(
typedValue->data() + (i * fItemSize),
true );
567 if (!(fSubfields[0]->GetTraits() & kTraitTriviallyConstructible)) {
569 CallConstructValueOn(*fSubfields[0],
typedValue->data() + (i * fItemSize));
573 for (std::size_t i = 0; i <
nItems; ++i) {
610 for (std::size_t i = 0; i <
nItems; ++i) {
611 fItemDeleter->operator()(
vecPtr->data() + (i * fItemSize),
true );
621 return std::make_unique<RVectorDeleter>(fItemSize, GetDeleterOf(*fSubfields[0]));
622 return std::make_unique<RVectorDeleter>();
628 auto *
vec =
static_cast<std::vector<char> *
>(
valuePtr.get());
632 std::vector<RValue>
result;
634 for (
unsigned i = 0; i <
nItems; ++i) {
635 result.emplace_back(fSubfields[0]->BindValue(std::shared_ptr<void>(
valuePtr,
vec->data() + (i * fItemSize))));
642 visitor.VisitVectorField(*
this);
655 auto typedValue =
static_cast<const std::vector<bool> *
>(from);
657 for (
unsigned i = 0; i < count; ++i) {
658 bool bval = (*typedValue)[i];
659 CallAppendOn(*fSubfields[0], &
bval);
662 fPrincipalColumn->Append(&fNWritten);
663 return count + fPrincipalColumn->GetElement()->GetPackedSize();
668 auto typedValue =
static_cast<std::vector<bool> *
>(to);
675 for (
unsigned i = 0; i <
nItems; ++i) {
678 (*typedValue)[i] =
bval;
704 EnsureMatchingOnDiskField(desc.GetFieldDescriptor(GetOnDiskId()), kDiffTypeName);
711 std::vector<RValue>
result;
713 for (
unsigned i = 0; i < count; ++i) {
715 result.emplace_back(fSubfields[0]->BindValue(std::shared_ptr<bool>(
new bool(
true))));
717 result.emplace_back(fSubfields[0]->BindValue(std::shared_ptr<bool>(
new bool(
false))));
724 visitor.VisitVectorBoolField(*
this);
744 auto newItemField = fSubfields[0]->Clone(fSubfields[0]->GetFieldName());
745 return std::make_unique<RArrayAsRVecField>(
newName, std::move(
newItemField), fArrayLength);
752 std::int32_t *
sizePtr =
new (
reinterpret_cast<void *
>(
beginPtr + 1)) std::int32_t(0);
757 char *begin =
reinterpret_cast<char *
>(*beginPtr);
760 if (*
sizePtr == std::int32_t(fArrayLength))
767 const bool needsConstruct = !(fSubfields[0]->GetTraits() & kTraitTriviallyConstructible);
773 for (std::int32_t i = 0; i < *
sizePtr; ++i) {
774 fItemDeleter->operator()(begin + (i * fItemSize),
true );
787 begin =
reinterpret_cast<char *
>(*beginPtr);
794 for (std::size_t i = 0; i < fArrayLength; ++i)
795 CallConstructValueOn(*fSubfields[0], begin + (i * fItemSize));
802 return std::make_unique<RRVecField::RRVecDeleter>(fSubfields[0]->GetAlignment(), fItemSize,
803 GetDeleterOf(*fSubfields[0]));
805 return std::make_unique<RRVecField::RRVecDeleter>(fSubfields[0]->GetAlignment());
812 auto rvecBeginPtr =
reinterpret_cast<char *
>(*beginPtr);
814 if (fSubfields[0]->IsSimple()) {
820 for (std::size_t i = 0; i < fArrayLength; ++i) {
828 auto rvecBeginPtr =
reinterpret_cast<char *
>(*beginPtr);
833 if (fSubfields[0]->IsSimple()) {
834 GetPrincipalColumnOf(*fSubfields[0])
840 for (std::size_t i = 0; i < fArrayLength; ++i) {
849 EnsureMatchingOnDiskField(
fieldDesc, kDiffTypeName | kDiffTypeVersion | kDiffStructure | kDiffNRepetitions);
850 if (
fieldDesc.GetTypeName().rfind(
"std::array<", 0) != 0) {
851 throw RException(
R__FAIL(
"RArrayAsRVecField " + GetQualifiedFieldName() +
" expects an on-disk array field"));
863 std::vector<ROOT::RFieldBase::RValue>
result;
864 result.reserve(fArrayLength);
865 for (
unsigned i = 0; i < fArrayLength; ++i) {
867 fSubfields[0]->BindValue(std::shared_ptr<void>(
value.GetPtr<
void>(),
arrayPtr + (i * fItemSize))));
874 visitor.VisitArrayAsRVecField(*
this);
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
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 value
Abstract base class for classes implementing the visitor design pattern.
The in-memory representation of a 32bit or 64bit on-disk index column.
std::unique_ptr< RDeleter > fItemDeleter
void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final
RArrayAsRVecField(std::string_view fieldName, std::unique_ptr< RFieldBase > itemField, std::size_t arrayLength)
Constructor of the field.
std::size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::unique_ptr< RDeleter > GetDeleter() const final
Returns an RRVecField::RRVecDeleter.
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
The size of a value of this field, i.e. an RVec.
std::vector< RFieldBase::RValue > SplitValue(const RFieldBase::RValue &value) const final
Creates the list of direct child values given an existing value for this field.
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
std::size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
std::size_t fValueSize
The length of the arrays in this field.
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
void operator()(void *objPtr, bool dtorOnly) final
std::unique_ptr< RDeleter > GetDeleter() const final
RArrayField(std::string_view fieldName, std::unique_ptr< RFieldBase > itemField, std::size_t arrayLength)
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given an existing value for this field.
Base class for all ROOT issued exceptions.
The list of column representations a field can have.
Points to an object with RNTuple I/O support and keeps a pointer to the corresponding field.
A field translates read and write calls from/to underlying columns to/from tree values.
void Attach(std::unique_ptr< RFieldBase > child)
Add a new subfield to the list of nested fields.
std::vector< std::unique_ptr< RFieldBase > > fSubfields
Collections and classes own subfields.
static std::unique_ptr< RDeleter > GetDeleterOf(const RFieldBase &other)
std::uint32_t fTraits
Properties of the type that allow for optimizations of collections of that type.
std::uint32_t GetTraits() const
@ kTraitEmulatedField
This field is a user defined type that was missing dictionaries and was reconstructed from the on-dis...
@ kTraitTriviallyDestructible
The type is cleaned up just by freeing its memory. I.e. the destructor performs a no-op.
virtual std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec)
General implementation of bulk read.
Classes with dictionaries that can be inspected by TClass.
The on-storage metadata of an RNTuple.
const RFieldDescriptor & GetFieldDescriptor(ROOT::DescriptorId_t fieldId) const
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
void operator()(void *objPtr, bool dtorOnly) final
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given an existing value for this field.
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponding to the field type ...
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec) final
General implementation of bulk read.
RRVecField(std::string_view fieldName, std::unique_ptr< RFieldBase > itemField)
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
std::unique_ptr< RDeleter > fItemDeleter
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
std::unique_ptr< RDeleter > GetDeleter() const final
void operator()(void *objPtr, bool dtorOnly) final
Template specializations for C++ std::vector.
static std::unique_ptr< RVectorField > CreateUntyped(std::string_view fieldName, std::unique_ptr< RFieldBase > itemField)
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponding to the field type ...
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
RVectorField(std::string_view fieldName, std::unique_ptr< RFieldBase > itemField, std::optional< std::string_view > emulatedFromType)
Creates a possibly-untyped VectorField.
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given an existing value for this field.
std::unique_ptr< RDeleter > fItemDeleter
std::unique_ptr< RDeleter > GetDeleter() const final
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
std::string GetNormalizedInteger(const std::string &intTemplateArg)
Appends 'll' or 'ull' to the where necessary and strips the suffix if not needed.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
ENTupleStructure
The fields in the RNTuple data model tree can carry different structural information about the type s...
Input parameter to RFieldBase::ReadBulk() and RFieldBase::ReadBulkImpl().