Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tree/ntuple/doc/Architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ During its lifetime, a field undergoes the following possible state transitions:

The RField class hierarchy is fixed and not meant to be extended by user classes.

### RField::RValue
### RFieldBase::RValue
The `RValue` class makes the connection between an object in memory and the corresponding field used for I/O.
It contains a shared pointer of the object, i.e. RNTuple and the application share ownership of objects.
The object in an RValue can either be created by an RNTuple field (cf. `RField<T>::CreateValue()` method)
Expand Down
26 changes: 15 additions & 11 deletions tree/ntuple/inc/ROOT/RField.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public:
template <typename T>
class RField<T, typename std::enable_if<std::is_enum_v<T>>::type> final : public REnumField {
public:
static std::string TypeName() { return ROOT::Internal::GetDemangledTypeName(typeid(T)); }
static std::string TypeName() { return ROOT::Internal::GetRenormalizedTypeName(typeid(T)); }
RField(std::string_view name) : REnumField(name, TypeName()) {}
RField(RField &&other) = default;
RField &operator=(RField &&other) = default;
Expand Down Expand Up @@ -352,12 +352,13 @@ protected:

void ConstructValue(void *where) const final { new (where) T{0}; }

public:
RSimpleField(std::string_view name, std::string_view type)
: RFieldBase(name, type, ROOT::ENTupleStructure::kLeaf, true /* isSimple */)
{
fTraits |= kTraitTrivialType;
}

public:
RSimpleField(RSimpleField &&other) = default;
RSimpleField &operator=(RSimpleField &&other) = default;
~RSimpleField() override = default;
Expand Down Expand Up @@ -393,20 +394,22 @@ namespace ROOT {

template <typename SizeT>
class RField<RNTupleCardinality<SizeT>> final : public RCardinalityField {
using CardinalityType = RNTupleCardinality<SizeT>;

protected:
std::unique_ptr<ROOT::RFieldBase> CloneImpl(std::string_view newName) const final
{
return std::make_unique<RField<RNTupleCardinality<SizeT>>>(newName);
return std::make_unique<RField>(newName);
}
void ConstructValue(void *where) const final { new (where) RNTupleCardinality<SizeT>(0); }
void ConstructValue(void *where) const final { new (where) CardinalityType(0); }

/// Get the number of elements of the collection identified by globalIndex
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
{
RNTupleLocalIndex collectionStart;
ROOT::NTupleSize_t size;
fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &size);
*static_cast<RNTupleCardinality<SizeT> *>(to) = size;
*static_cast<CardinalityType *>(to) = size;
}

/// Get the number of elements of the collection identified by clusterIndex
Expand All @@ -415,7 +418,7 @@ protected:
RNTupleLocalIndex collectionStart;
ROOT::NTupleSize_t size;
fPrincipalColumn->GetCollectionInfo(localIndex, &collectionStart, &size);
*static_cast<RNTupleCardinality<SizeT> *>(to) = size;
*static_cast<CardinalityType *>(to) = size;
}

std::size_t ReadBulkImpl(const RBulkSpec &bulkSpec) final
Expand All @@ -424,7 +427,7 @@ protected:
ROOT::NTupleSize_t collectionSize;
fPrincipalColumn->GetCollectionInfo(bulkSpec.fFirstIndex, &collectionStart, &collectionSize);

auto typedValues = static_cast<RNTupleCardinality<SizeT> *>(bulkSpec.fValues);
auto typedValues = static_cast<CardinalityType *>(bulkSpec.fValues);
typedValues[0] = collectionSize;

auto lastOffset = collectionStart.GetIndexInCluster() + collectionSize;
Expand Down Expand Up @@ -452,8 +455,8 @@ public:
RField &operator=(RField &&other) = default;
~RField() final = default;

size_t GetValueSize() const final { return sizeof(RNTupleCardinality<SizeT>); }
size_t GetAlignment() const final { return alignof(RNTupleCardinality<SizeT>); }
size_t GetValueSize() const final { return sizeof(CardinalityType); }
size_t GetAlignment() const final { return alignof(CardinalityType); }
};

/// TObject requires special handling of the fBits and fUniqueID members
Expand Down Expand Up @@ -495,8 +498,7 @@ public:
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final;
};

// Has to be implemented after the definition of all RField<T> types
// The void type is specialized in RField.cxx
// Have to be implemented after the definition of all RField<T> types

namespace Internal {

Expand Down Expand Up @@ -527,6 +529,8 @@ std::unique_ptr<T, typename RFieldBase::RCreateObjectDeleter<T>::deleter> RField
return std::unique_ptr<T>(static_cast<T *>(CreateObjectRawPtr()));
}

// The void type is specialized in RField.cxx

template <>
struct RFieldBase::RCreateObjectDeleter<void> {
using deleter = RCreateObjectDeleter<void>;
Expand Down
10 changes: 8 additions & 2 deletions tree/ntuple/inc/ROOT/RFieldBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

namespace ROOT {

class REntry;
class RFieldBase;
class RClassField;

Expand Down Expand Up @@ -697,8 +698,9 @@ public:
/// Points to an object with RNTuple I/O support and keeps a pointer to the corresponding field.
/// Fields can create RValue objects through RFieldBase::CreateValue(), RFieldBase::BindValue()) or
/// RFieldBase::SplitValue().
class RFieldBase::RValue {
class RFieldBase::RValue final {
friend class RFieldBase;
friend class ROOT::REntry;

private:
RFieldBase *fField = nullptr; ///< The field that created the RValue
Expand All @@ -713,9 +715,13 @@ public:
RValue &operator=(RValue &&other) = default;
~RValue() = default;

private:
std::size_t Append() { return fField->Append(fObjPtr.get()); }

public:
void Read(ROOT::NTupleSize_t globalIndex) { fField->Read(globalIndex, fObjPtr.get()); }
void Read(RNTupleLocalIndex localIndex) { fField->Read(localIndex, fObjPtr.get()); }

void Bind(std::shared_ptr<void> objPtr) { fObjPtr = objPtr; }
void BindRawPtr(void *rawPtr);
/// Replace the current object pointer by a pointer to a new object constructed by the field
Expand Down Expand Up @@ -769,7 +775,7 @@ on the same range, where in each read operation a different subset of values is
The memory of the value array is managed by the RBulkValues class.
*/
// clang-format on
class RFieldBase::RBulkValues {
class RFieldBase::RBulkValues final {
private:
friend class RFieldBase;

Expand Down
Loading