19 "std::array<" +
itemField->GetTypeName() +
"," +
31 auto newItemField = fSubfields[0]->Clone(fSubfields[0]->GetFieldName());
38 if (fSubfields[0]->IsSimple()) {
39 GetPrincipalColumnOf(*fSubfields[0])->AppendV(from, fArrayLength);
40 nbytes += fArrayLength * GetPrincipalColumnOf(*fSubfields[0])->GetElement()->GetPackedSize();
42 auto arrayPtr =
static_cast<const unsigned char *
>(from);
43 for (
unsigned i = 0; i < fArrayLength; ++i) {
44 nbytes += CallAppendOn(*fSubfields[0],
arrayPtr + (i * fItemSize));
52 if (fSubfields[0]->IsSimple()) {
53 GetPrincipalColumnOf(*fSubfields[0])->ReadV(
globalIndex * fArrayLength, fArrayLength, to);
55 auto arrayPtr =
static_cast<unsigned char *
>(to);
56 for (
unsigned i = 0; i < fArrayLength; ++i) {
64 if (fSubfields[0]->IsSimple()) {
65 GetPrincipalColumnOf(*fSubfields[0])->ReadV(
localIndex * fArrayLength, fArrayLength, to);
67 auto arrayPtr =
static_cast<unsigned char *
>(to);
68 for (
unsigned i = 0; i < fArrayLength; ++i) {
76 if (!fSubfields[0]->IsSimple())
79 GetPrincipalColumnOf(*fSubfields[0])
81 return RBulkSpec::kAllSet;
86 static const std::vector<std::string>
prefixes = {
"std::array<"};
89 EnsureMatchingOnDiskField(
fieldDesc, kDiffTypeName).ThrowOnError();
95 if (fSubfields[0]->GetTraits() & kTraitTriviallyConstructible)
99 for (
unsigned i = 0; i < fArrayLength; ++i) {
100 CallConstructValueOn(*fSubfields[0],
arrayPtr + (i * fItemSize));
107 for (
unsigned i = 0; i < fArrayLength; ++i) {
108 fItemDeleter->operator()(
reinterpret_cast<unsigned char *
>(
objPtr) + i * fItemSize,
true );
116 if (!(fSubfields[0]->GetTraits() & kTraitTriviallyDestructible))
117 return std::make_unique<RArrayDeleter>(fItemSize, fArrayLength, GetDeleterOf(*fSubfields[0]));
118 return std::make_unique<RDeleter>();
125 std::vector<RValue>
result;
126 result.reserve(fArrayLength);
127 for (
unsigned i = 0; i < fArrayLength; ++i) {
128 result.emplace_back(fSubfields[0]->BindValue(std::shared_ptr<void>(
valuePtr,
arrayPtr + (i * fItemSize))));
135 visitor.VisitArrayField(*
this);
146 unsigned char **
beginPtr =
reinterpret_cast<unsigned char **
>(
rvecPtr);
148 std::int32_t *
size =
reinterpret_cast<std::int32_t *
>(
beginPtr + 1);
151 std::int32_t *capacity =
size + 1;
156std::tuple<const unsigned char *const *, const std::int32_t *, const std::int32_t *>
176 constexpr auto dataMemberSz =
sizeof(
void *) + 2 *
sizeof(std::int32_t);
182 constexpr unsigned maxInlineByteSize = 1024;
184 elementsPerCacheLine >= 8 ? elementsPerCacheLine : (
sizeOfT * 8 > maxInlineByteSize ? 0 : 8);
206 return std::max({
alignof(
void *),
alignof(std::int32_t),
alignOfSubfield});
213 constexpr auto dataMemberSz =
sizeof(
void *) + 2 *
sizeof(std::int32_t);
220 if (!isSmall &&
owns)
253 auto newItemField = fSubfields[0]->Clone(fSubfields[0]->GetFieldName());
262 if (fSubfields[0]->IsSimple() && *
sizePtr) {
264 nbytes += *
sizePtr * GetPrincipalColumnOf(*fSubfields[0])->GetElement()->GetPackedSize();
266 for (std::int32_t i = 0; i < *
sizePtr; ++i) {
267 nbytes += CallAppendOn(*fSubfields[0], *
beginPtr + i * fItemSize);
272 fPrincipalColumn->Append(&fNWritten);
273 return nbytes + fPrincipalColumn->GetElement()->GetPackedSize();
280 if (
nItems >
static_cast<std::size_t
>(std::numeric_limits<std::int32_t>::max())) {
305 for (std::size_t i = 0
u; i <
oldSize; ++i) {
323 for (std::size_t i = 0
u; i <
oldSize; ++i)
348 auto begin = ResizeRVec(to,
nItems, fItemSize, fSubfields[0].get(), fItemDeleter.get());
350 if (fSubfields[0]->IsSimple() &&
nItems) {
356 for (std::size_t i = 0; i <
nItems; ++i) {
357 CallReadOn(*fSubfields[0],
collectionStart + i, begin + (i * fItemSize));
369 bulkSpec.fAuxData->resize(
sizeof(std::size_t));
370 *
reinterpret_cast<std::size_t *
>(
bulkSpec.fAuxData->data()) = fBulkNRepetition * fBulkSubfield->GetValueSize();
396 for (std::size_t i = 0; i <
nBatch; ++i) {
416 for (std::size_t i = 0; i <
bulkSpec.fCount; ++i) {
422 GetPrincipalColumnOf(*fBulkSubfield)
424 return RBulkSpec::kAllSet;
454 if (
fieldDesc.GetTypeName().rfind(
"std::array<", 0) == 0) {
455 auto substitute = std::make_unique<RArrayAsRVecField>(
456 GetFieldName(), fSubfields[0]->Clone(fSubfields[0]->GetFieldName()),
fieldDesc.GetNRepetitions());
465 EnsureMatchingOnDiskField(desc.
GetFieldDescriptor(GetOnDiskId()), kDiffTypeName).ThrowOnError();
473 std::int32_t *
sizePtr =
new (
reinterpret_cast<void *
>(
beginPtr + 1)) std::int32_t(0);
474 new (
sizePtr + 1) std::int32_t(-1);
482 for (std::int32_t i = 0; i < *
sizePtr; ++i) {
483 fItemDeleter->operator()(*
beginPtr + i * fItemSize,
true );
494 return std::make_unique<RRVecDeleter>(fSubfields[0]->GetAlignment(), fItemSize, GetDeleterOf(*fSubfields[0]));
495 return std::make_unique<RRVecDeleter>(fSubfields[0]->GetAlignment());
502 std::vector<RValue>
result;
504 for (std::int32_t i = 0; i < *
sizePtr; ++i) {
506 fSubfields[0]->BindValue(std::shared_ptr<void>(
value.GetPtr<
void>(), *
beginPtr + i * fItemSize)));
548std::unique_ptr<ROOT::RVectorField>
556 auto newItemField = fSubfields[0]->Clone(fSubfields[0]->GetFieldName());
557 auto isUntyped = GetTypeName().empty() || ((fTraits & kTraitEmulatedField) != 0);
564 auto typedValue =
static_cast<const std::vector<char> *
>(from);
573 if (fSubfields[0]->IsSimple() && count) {
574 GetPrincipalColumnOf(*fSubfields[0])->AppendV(
typedValue->data(), count);
575 nbytes += count * GetPrincipalColumnOf(*fSubfields[0])->GetElement()->GetPackedSize();
577 for (
unsigned i = 0; i < count; ++i) {
578 nbytes += CallAppendOn(*fSubfields[0],
typedValue->data() + (i * fItemSize));
583 fPrincipalColumn->Append(&fNWritten);
584 return nbytes + fPrincipalColumn->GetElement()->GetPackedSize();
589 auto typedValue =
static_cast<std::vector<char> *
>(to);
595 if (fSubfields[0]->IsSimple()) {
610 fItemDeleter->operator()(
typedValue->data() + (i * fItemSize),
true );
614 if (!(fSubfields[0]->GetTraits() & kTraitTriviallyConstructible)) {
616 CallConstructValueOn(*fSubfields[0],
typedValue->data() + (i * fItemSize));
620 for (std::size_t i = 0; i <
nItems; ++i) {
647 EnsureMatchingOnDiskField(desc.
GetFieldDescriptor(GetOnDiskId()), kDiffTypeName).ThrowOnError();
657 for (std::size_t i = 0; i <
nItems; ++i) {
658 fItemDeleter->operator()(
vecPtr->data() + (i * fItemSize),
true );
668 return std::make_unique<RVectorDeleter>(fItemSize, GetDeleterOf(*fSubfields[0]));
669 return std::make_unique<RVectorDeleter>();
675 auto *
vec =
static_cast<std::vector<char> *
>(
valuePtr.get());
679 std::vector<RValue>
result;
681 for (
unsigned i = 0; i <
nItems; ++i) {
682 result.emplace_back(fSubfields[0]->BindValue(std::shared_ptr<void>(
valuePtr,
vec->data() + (i * fItemSize))));
689 visitor.VisitVectorField(*
this);
702 auto typedValue =
static_cast<const std::vector<bool> *
>(from);
704 for (
unsigned i = 0; i < count; ++i) {
705 bool bval = (*typedValue)[i];
706 CallAppendOn(*fSubfields[0], &
bval);
709 fPrincipalColumn->Append(&fNWritten);
710 return count + fPrincipalColumn->GetElement()->GetPackedSize();
715 auto typedValue =
static_cast<std::vector<bool> *
>(to);
722 for (
unsigned i = 0; i <
nItems; ++i) {
725 (*typedValue)[i] =
bval;
751 EnsureMatchingOnDiskField(desc.GetFieldDescriptor(GetOnDiskId()), kDiffTypeName).ThrowOnError();
758 std::vector<RValue>
result;
760 for (
unsigned i = 0; i < count; ++i) {
762 result.emplace_back(fSubfields[0]->BindValue(std::shared_ptr<bool>(
new bool(
true))));
764 result.emplace_back(fSubfields[0]->BindValue(std::shared_ptr<bool>(
new bool(
false))));
771 visitor.VisitVectorBoolField(*
this);
791 auto newItemField = fSubfields[0]->Clone(fSubfields[0]->GetFieldName());
792 return std::make_unique<RArrayAsRVecField>(
newName, std::move(
newItemField), fArrayLength);
800 std::int32_t *
sizePtr =
new (
static_cast<void *
>(
beginPtr + 1)) std::int32_t(0);
801 new (
sizePtr + 1) std::int32_t(-1);
807 return std::make_unique<RRVecField::RRVecDeleter>(fSubfields[0]->GetAlignment(), fItemSize,
808 GetDeleterOf(*fSubfields[0]));
810 return std::make_unique<RRVecField::RRVecDeleter>(fSubfields[0]->GetAlignment());
815 auto begin =
RRVecField::ResizeRVec(to, fArrayLength, fItemSize, fSubfields[0].get(), fItemDeleter.get());
817 if (fSubfields[0]->IsSimple()) {
818 GetPrincipalColumnOf(*fSubfields[0])->ReadV(
globalIndex * fArrayLength, fArrayLength, begin);
823 for (std::size_t i = 0; i < fArrayLength; ++i) {
824 CallReadOn(*fSubfields[0],
globalIndex * fArrayLength + i, begin + (i * fItemSize));
830 auto begin =
RRVecField::ResizeRVec(to, fArrayLength, fItemSize, fSubfields[0].get(), fItemDeleter.get());
832 if (fSubfields[0]->IsSimple()) {
833 GetPrincipalColumnOf(*fSubfields[0])->ReadV(
localIndex * fArrayLength, fArrayLength, begin);
838 for (std::size_t i = 0; i < fArrayLength; ++i) {
839 CallReadOn(*fSubfields[0],
localIndex * fArrayLength + i, begin + (i * fItemSize));
846 EnsureMatchingOnDiskField(
fieldDesc, kDiffTypeName | kDiffTypeVersion | kDiffStructure | kDiffNRepetitions)
848 if (
fieldDesc.GetTypeName().rfind(
"std::array<", 0) != 0) {
849 throw RException(
R__FAIL(
"RArrayAsRVecField " + GetQualifiedFieldName() +
" expects an on-disk array field"));
861 std::vector<ROOT::RFieldBase::RValue>
result;
862 result.reserve(fArrayLength);
863 for (
unsigned i = 0; i < fArrayLength; ++i) {
865 fSubfields[0]->BindValue(std::shared_ptr<void>(
value.GetPtr<
void>(),
arrayPtr + (i * fItemSize))));
872 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.
Abstract interface to read data from an ntuple.
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
Template specializations for C++ std::array and C-style arrays.
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.
std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec) final
General implementation of bulk read.
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.
A functor to release the memory acquired by CreateValue() (memory and constructor).
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 fBulkNRepetition
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.
std::unique_ptr< RFieldBase > BeforeConnectPageSource(ROOT::Internal::RPageSource &pageSource) final
Called by ConnectPageSource() before connecting; derived classes may override this as appropriate,...
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.
static unsigned char * ResizeRVec(void *rvec, std::size_t nItems, std::size_t itemSize, const RFieldBase *itemField, RDeleter *itemDeleter)
std::unique_ptr< RDeleter > fItemDeleter
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
RFieldBase * fBulkSubfield
May be a direct PoD subfield or a sub-subfield of a fixed-size array of PoD.
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.
constexpr DescriptorId_t kInvalidDescriptorId
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().