34std::unique_ptr<ROOT::Experimental::RFieldBase>
37 auto result = std::make_unique<RFieldZero>();
39 result->Attach(
f->Clone(
f->GetFieldName()));
56 return representations;
61 GenerateColumnsImpl<ClusterSize_t>(desc);
103 return representations;
119 return representations;
124 visitor.VisitByteField(*
this);
149 return representations;
154 visitor.VisitInt8Field(*
this);
179 return representations;
184 visitor.VisitUInt8Field(*
this);
209 return representations;
230 return representations;
253 return representations;
263 fTypeAlias =
"Double32_t";
288 return representations;
293 visitor.VisitInt16Field(*
this);
318 return representations;
323 visitor.VisitUInt16Field(*
this);
348 return representations;
353 visitor.VisitInt32Field(*
this);
378 return representations;
383 visitor.VisitUInt32Field(*
this);
408 return representations;
413 visitor.VisitUInt64Field(*
this);
438 return representations;
443 visitor.VisitInt64Field(*
this);
456 return representations;
461 GenerateColumnsImpl<ClusterSize_t, char>();
466 GenerateColumnsImpl<ClusterSize_t, char>(desc);
471 auto typedValue =
static_cast<const std::string *
>(from);
472 auto length = typedValue->length();
473 fAuxiliaryColumn->AppendV(typedValue->data(),
length);
475 fPrincipalColumn->Append(&fIndex);
476 return length + fPrincipalColumn->GetElement()->GetPackedSize();
481 auto typedValue =
static_cast<std::string *
>(to);
482 RClusterIndex collectionStart;
484 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &nChars);
488 typedValue->resize(nChars);
489 fAuxiliaryColumn->ReadV(collectionStart, nChars,
const_cast<char *
>(typedValue->data()));
495 visitor.VisitStringField(*
this);
502 fMaxAlignment(source.fMaxAlignment),
504 fOffsets(source.fOffsets)
507 Attach(
f->Clone(
f->GetFieldName()));
516void ROOT::Experimental::RRecordField::RRecordField::AttachItemFields(
517 std::vector<std::unique_ptr<RFieldBase>> itemFields)
519 fTraits |= kTraitTrivialType;
520 for (
auto &item : itemFields) {
521 fMaxAlignment = std::max(fMaxAlignment, item->GetAlignment());
522 fSize += GetItemPadding(
fSize, item->GetAlignment()) + item->GetValueSize();
523 fTraits &= item->GetTraits();
524 Attach(std::move(item));
528 fSize += GetItemPadding(
fSize, fMaxAlignment);
532 std::vector<std::unique_ptr<RFieldBase>> itemFields)
536 fOffsets.reserve(itemFields.size());
537 for (
auto &item : itemFields) {
541 fSize += item->GetValueSize();
552 if (itemAlignment > 1) {
553 auto remainder = baseOffset % itemAlignment;
555 return itemAlignment - remainder;
560std::unique_ptr<ROOT::Experimental::RFieldBase>
563 return std::unique_ptr<RRecordField>(
new RRecordField(newName, *
this));
568 std::size_t nbytes = 0;
569 for (
unsigned i = 0; i < fSubFields.size(); ++i) {
570 nbytes += CallAppendOn(*fSubFields[i],
static_cast<const unsigned char *
>(from) + fOffsets[i]);
577 for (
unsigned i = 0; i < fSubFields.size(); ++i) {
578 CallReadOn(*fSubFields[i], globalIndex,
static_cast<unsigned char *
>(to) + fOffsets[i]);
584 for (
unsigned i = 0; i < fSubFields.size(); ++i) {
585 CallReadOn(*fSubFields[i], clusterIndex,
static_cast<unsigned char *
>(to) + fOffsets[i]);
591 for (
unsigned i = 0; i < fSubFields.size(); ++i) {
592 CallConstructValueOn(*fSubFields[i],
static_cast<unsigned char *
>(where) + fOffsets[i]);
598 for (
unsigned i = 0; i < fItemDeleters.size(); ++i) {
599 fItemDeleters[i]->operator()(
reinterpret_cast<unsigned char *
>(objPtr) + fOffsets[i],
true );
601 RDeleter::operator()(objPtr, dtorOnly);
606 std::vector<std::unique_ptr<RDeleter>> itemDeleters;
607 itemDeleters.reserve(fOffsets.size());
608 for (
const auto &
f : fSubFields) {
609 itemDeleters.emplace_back(GetDeleterOf(*
f));
611 return std::make_unique<RRecordDeleter>(std::move(itemDeleters), fOffsets);
614std::vector<ROOT::Experimental::RFieldBase::RValue>
617 auto basePtr =
value.GetPtr<
unsigned char>().get();
618 std::vector<RValue>
result;
619 result.reserve(fSubFields.size());
620 for (
unsigned i = 0; i < fSubFields.size(); ++i) {
621 result.emplace_back(fSubFields[i]->BindValue(std::shared_ptr<void>(
value.GetPtr<
void>(), basePtr + fOffsets[i])));
645 return representations;
650 GenerateColumnsImpl<bool>();
655 GenerateColumnsImpl<bool>(desc);
660 const auto *asULongArray =
static_cast<const Word_t *
>(from);
663 for (std::size_t word = 0; word < (fN + kBitsPerWord - 1) / kBitsPerWord; ++word) {
664 for (std::size_t
mask = 0; (
mask < kBitsPerWord) && (i < fN); ++
mask, ++i) {
665 elementValue = (asULongArray[word] & (
static_cast<Word_t>(1) <<
mask)) != 0;
666 fPrincipalColumn->Append(&elementValue);
674 auto *asULongArray =
static_cast<Word_t *
>(to);
676 for (std::size_t i = 0; i < fN; ++i) {
677 fPrincipalColumn->Read(globalIndex * fN + i, &elementValue);
679 Word_t bit =
static_cast<Word_t>(elementValue) << (i % kBitsPerWord);
680 asULongArray[i / kBitsPerWord] = (asULongArray[i / kBitsPerWord] & ~mask) | bit;
686 auto *asULongArray =
static_cast<Word_t *
>(to);
688 for (std::size_t i = 0; i < fN; ++i) {
692 Word_t bit =
static_cast<Word_t>(elementValue) << (i % kBitsPerWord);
693 asULongArray[i / kBitsPerWord] = (asULongArray[i / kBitsPerWord] & ~mask) | bit;
705 std::unique_ptr<RFieldBase> itemField)
708 Attach(std::move(itemField));
717 return representations;
722 GenerateColumnsImpl<ClusterSize_t>();
727 GenerateColumnsImpl<ClusterSize_t>(desc);
732 fPrincipalColumn->Append(&fNWritten);
738 auto nbytesItem = CallAppendOn(*fSubFields[0], from);
740 fPrincipalColumn->Append(&fNWritten);
748 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &collectionSize);
749 return (collectionSize == 0) ?
RClusterIndex() : collectionStart;
760 std::unique_ptr<RFieldBase> itemField)
761 :
RNullableField(fieldName, typeName, std::move(itemField)), fItemDeleter(GetDeleterOf(*fSubFields[0]))
765std::unique_ptr<ROOT::Experimental::RFieldBase>
768 auto newItemField = fSubFields[0]->
Clone(fSubFields[0]->GetFieldName());
769 return std::make_unique<RUniquePtrField>(newName, GetTypeName(), std::move(newItemField));
774 auto typedValue =
static_cast<const std::unique_ptr<char> *
>(from);
776 return AppendValue(typedValue->get());
784 auto ptr =
static_cast<std::unique_ptr<char> *
>(to);
785 bool isValidValue =
static_cast<bool>(*ptr);
787 auto itemIndex = GetItemIndex(globalIndex);
790 void *valuePtr =
nullptr;
792 valuePtr = ptr->get();
794 if (isValidValue && !isValidItem) {
796 fItemDeleter->operator()(valuePtr,
false );
804 valuePtr = CallCreateObjectRawPtrOn(*fSubFields[0]);
805 ptr->reset(
reinterpret_cast<char *
>(valuePtr));
808 CallReadOn(*fSubFields[0], itemIndex, valuePtr);
813 auto typedPtr =
static_cast<std::unique_ptr<char> *
>(objPtr);
815 fItemDeleter->operator()(typedPtr->get(),
false );
818 RDeleter::operator()(objPtr, dtorOnly);
823 return std::make_unique<RUniquePtrDeleter>(GetDeleterOf(*fSubFields[0]));
826std::vector<ROOT::Experimental::RFieldBase::RValue>
829 std::vector<RValue>
result;
830 const auto &ptr =
value.GetRef<std::unique_ptr<char>>();
832 result.emplace_back(fSubFields[0]->BindValue(std::shared_ptr<void>(
value.GetPtr<
void>(), ptr.get())));
840 std::unique_ptr<RFieldBase> itemField)
841 :
RNullableField(fieldName, typeName, std::move(itemField)), fItemDeleter(GetDeleterOf(*fSubFields[0]))
849 return reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(optionalPtr) + fSubFields[0]->GetValueSize());
854 return GetEngagementPtr(
const_cast<void *
>(optionalPtr));
857std::unique_ptr<ROOT::Experimental::RFieldBase>
860 auto newItemField = fSubFields[0]->Clone(fSubFields[0]->GetFieldName());
861 return std::make_unique<ROptionalField>(newName, GetTypeName(), std::move(newItemField));
866 if (*GetEngagementPtr(from)) {
867 return AppendValue(from);
875 auto engagementPtr = GetEngagementPtr(to);
876 auto itemIndex = GetItemIndex(globalIndex);
878 if (*engagementPtr && !(fSubFields[0]->GetTraits() & kTraitTriviallyDestructible))
879 fItemDeleter->operator()(to,
true );
880 *engagementPtr =
false;
882 if (!(*engagementPtr) && !(fSubFields[0]->GetTraits() & kTraitTriviallyConstructible))
883 CallConstructValueOn(*fSubFields[0], to);
884 CallReadOn(*fSubFields[0], itemIndex, to);
885 *engagementPtr =
true;
891 *GetEngagementPtr(where) =
false;
897 auto engagementPtr =
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(objPtr) + fEngagementPtrOffset);
899 fItemDeleter->operator()(objPtr,
true );
901 RDeleter::operator()(objPtr, dtorOnly);
906 return std::make_unique<ROptionalDeleter>(
907 (fSubFields[0]->GetTraits() & kTraitTriviallyDestructible) ?
nullptr : GetDeleterOf(*fSubFields[0]),
908 fSubFields[0]->GetValueSize());
911std::vector<ROOT::Experimental::RFieldBase::RValue>
914 std::vector<RValue>
result;
915 const auto valuePtr =
value.GetPtr<
void>().get();
916 if (*GetEngagementPtr(valuePtr)) {
917 result.emplace_back(fSubFields[0]->BindValue(std::shared_ptr<void>(
value.GetPtr<
void>(), valuePtr)));
926 const auto actualSize = fSubFields[0]->GetValueSize() +
sizeof(
bool);
933 return actualSize + padding;
938 return fSubFields[0]->GetAlignment();
944 std::unique_ptr<RFieldBase> itemField)
951 Attach(std::move(itemField));
954std::unique_ptr<ROOT::Experimental::RFieldBase>
957 auto newItemField = fSubFields[0]->Clone(fSubFields[0]->GetFieldName());
958 return std::make_unique<RAtomicField>(newName, GetTypeName(), std::move(newItemField));
961std::vector<ROOT::Experimental::RFieldBase::RValue>
964 std::vector<RValue>
result;
965 result.emplace_back(fSubFields[0]->BindValue(
value.GetPtr<
void>()));
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 mask
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 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 length
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.
virtual void VisitBoolField(const RField< bool > &field)
virtual void VisitBitsetField(const RBitsetField &field)
virtual void VisitNullableField(const RNullableField &field)
virtual void VisitFieldZero(const RFieldZero &field)
virtual void VisitCardinalityField(const RCardinalityField &field)
virtual void VisitDoubleField(const RField< double > &field)
virtual void VisitCharField(const RField< char > &field)
virtual void VisitRecordField(const RRecordField &field)
virtual void VisitFloatField(const RField< float > &field)
virtual void VisitAtomicField(const RAtomicField &field)
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
RAtomicField(std::string_view fieldName, std::string_view typeName, std::unique_ptr< RFieldBase > itemField)
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given a value for this field.
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
RBitsetField(std::string_view fieldName, std::size_t N)
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponsing to the field type ...
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponsing to the field type ...
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
const RField< RNTupleCardinality< std::uint32_t > > * As32Bit() const
const RField< RNTupleCardinality< std::uint64_t > > * As64Bit() const
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 AcceptVisitor(Detail::RFieldVisitor &visitor) const final
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
DescriptorId_t GetClusterId() const
ClusterSize_t::ValueType GetIndex() const
Some fields have multiple possible column representations, e.g.
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.
static constexpr int kTraitTriviallyDestructible
The type is cleaned up just by freeing its memory. I.e. the destructor performs a no-op.
virtual void GenerateColumns()
Implementations in derived classes should create the backing columns corresponsing to the field type ...
void Attach(std::unique_ptr< RFieldBase > child)
Add a new subfield to the list of nested fields.
std::vector< RFieldBase * > GetSubFields()
static constexpr int kTraitTriviallyConstructible
No constructor needs to be called, i.e.
int fTraits
Properties of the type that allow for optimizations of collections of that type.
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::vector< std::unique_ptr< RFieldBase > > fSubFields
Collections and classes own sub fields.
static constexpr int kTraitTrivialType
Shorthand for types that are both trivially constructible and destructible.
virtual const RColumnRepresentations & GetColumnRepresentations() const
Implementations in derived classes should return a static RColumnRepresentations object.
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
std::unique_ptr< 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.
The on-storage meta-data of an ntuple.
Template specializations for C++ std::optional and std::unique_ptr.
const RFieldBase::RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponsing to the field type ...
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
RClusterIndex GetItemIndex(NTupleSize_t globalIndex)
Given the index of the nullable field, returns the corresponding global index of the subfield or,...
RNullableField(std::string_view fieldName, std::string_view typeName, std::unique_ptr< RFieldBase > itemField)
std::size_t AppendValue(const void *from)
void operator()(void *objPtr, bool dtorOnly) final
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
std::unique_ptr< RDeleter > GetDeleter() const final
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
const bool * GetEngagementPtr(const void *optionalPtr) const
Given a pointer to an std::optional<T> in optionalPtr, extract a pointer to the engagement boolean.
ROptionalField(std::string_view fieldName, std::string_view typeName, std::unique_ptr< RFieldBase > itemField)
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given a value for this field.
void operator()(void *objPtr, bool dtorOnly) final
The field for an untyped record.
std::size_t fMaxAlignment
std::vector< std::size_t > fOffsets
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final
RRecordField(std::string_view name, const RRecordField &source)
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given a value for this field.
std::size_t GetItemPadding(std::size_t baseOffset, std::size_t itemAlignment) const
std::unique_ptr< RDeleter > GetDeleter() const final
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
void operator()(void *objPtr, bool dtorOnly) final
std::unique_ptr< 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
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given a value for this field.
RUniquePtrField(std::string_view fieldName, std::string_view typeName, std::unique_ptr< RFieldBase > itemField)
std::unique_ptr< RDeleter > GetDeleter() const final
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
RClusterSize ClusterSize_t
constexpr ClusterSize_t kInvalidClusterIndex(std::uint64_t(-1))
ENTupleStructure
The fields in the ntuple model tree can carry different structural information about the type system.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Wrap the integer in a struct in order to avoid template specialization clash with std::uint64_t.