13#ifndef ROOT_RNTupleView
14#define ROOT_RNTupleView
27#include <unordered_map>
40ROOT::RNTupleGlobalRange
GetFieldRange(
const ROOT::RFieldBase &field,
const ROOT::Internal::RPageSource &pageSource);
84 std::unique_ptr<ROOT::RFieldBase>
fField;
88 static std::unique_ptr<ROOT::RFieldBase>
93 std::unique_ptr<ROOT::RFieldBase> field;
97 if constexpr (std::is_void_v<T>) {
99 field = fieldDesc.CreateField(desc);
103 field = std::make_unique<ROOT::RField<T>>(fieldDesc.GetFieldName());
106 field->SetOnDiskId(fieldId);
107 fieldZero.
Attach(std::move(field));
123 :
fField(std::move(field)),
153 void Bind(std::shared_ptr<T> objPtr) {
fValue.Bind(objPtr); }
190 return *
static_cast<T *
>(ptr);
278 throw RException(
R__FAIL(
"type mismatch for field " + fieldDesc.GetFieldName() +
": " +
328 fField.SetOnDiskId(fieldId);
334 std::string fieldName;
340 R__FAIL(
"invalid attemt to create collection view on non-collection field " + fieldDesc.GetFieldName()));
342 fieldName = fieldDesc.GetFieldName();
349 auto descGuard =
fSource->GetSharedDescriptorGuard();
350 auto fieldId = descGuard->FindFieldId(fieldName,
fField.GetOnDiskId());
352 throw RException(
R__FAIL(
"no field named '" + std::string(fieldName) +
"' in collection '" +
353 descGuard->GetQualifiedFieldName(
fField.GetOnDiskId()) +
"'"));
361 void *ptr =
fValue.GetPtr<
void>().get();
376 std::swap(
fSource, other.fSource);
377 std::swap(
fField, other.fField);
387 fField.GetCollectionInfo(globalIndex, &collectionStart, &
size);
396 fField.GetCollectionInfo(localIndex, &collectionStart, &
size);
406 template <
typename T>
420 template <
typename T>
#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
const ROOT::RNTupleDescriptor & GetRef() const
Abstract interface to read data from an ntuple.
const RSharedDescriptorGuard GetSharedDescriptorGuard() const
Takes the read lock for the descriptor.
Base class for all ROOT issued exceptions.
Points to an array of objects with RNTuple I/O support, used for bulk reading.
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 SetOnDiskId(ROOT::DescriptorId_t id)
static RResult< std::unique_ptr< RFieldBase > > Create(const std::string &fieldName, const std::string &typeName, const ROOT::RCreateFieldOptions &options, const ROOT::RNTupleDescriptor *desc, ROOT::DescriptorId_t fieldId)
Factory method to resurrect a field from the stored on-disk type information.
The container field for an ntuple model, which itself has no physical representation.
std::vector< std::unique_ptr< RFieldBase > > ReleaseSubfields()
Moves all subfields into the returned vector.
void Attach(std::unique_ptr< RFieldBase > child)
A public version of the Attach method that allows piece-wise construction of the zero field.
Classes with dictionaries that can be inspected by TClass.
static std::string TypeName()
ROOT::DescriptorId_t GetFieldId(std::string_view fieldName)
RNTupleCollectionView & operator=(const RNTupleCollectionView &other)=delete
std::uint64_t GetCardinalityValue() const
RNTupleView< T > GetView(std::string_view fieldName)
Provides access to an individual (sub)field.
RNTupleCollectionView(const RNTupleCollectionView &other)=delete
RNTupleCollectionView(ROOT::DescriptorId_t fieldId, const std::string &fieldName, ROOT::Internal::RPageSource *source)
ROOT::Internal::RPageSource * fSource
ROOT::RNTupleLocalRange GetCollectionRange(ROOT::NTupleSize_t globalIndex)
std::uint64_t operator()(ROOT::NTupleSize_t globalIndex)
RNTupleCollectionView GetCollectionView(std::string_view fieldName)
Provides access to a collection field, that can itself generate new RNTupleViews for its nested field...
ROOT::RField< RNTupleCardinality< std::uint64_t > > fField
RNTupleCollectionView & operator=(RNTupleCollectionView &&other)
ROOT::RFieldBase::RValue fValue
static RNTupleCollectionView Create(ROOT::DescriptorId_t fieldId, ROOT::Internal::RPageSource *source)
RNTupleDirectAccessView< T > GetDirectAccessView(std::string_view fieldName)
Provides direct access to the I/O buffers of a mappable (sub)field.
RNTupleCollectionView(RNTupleCollectionView &&other)
std::uint64_t operator()(RNTupleLocalIndex localIndex)
~RNTupleCollectionView()=default
ROOT::RNTupleLocalRange GetCollectionRange(RNTupleLocalIndex localIndex)
const RFieldDescriptor & GetFieldDescriptor(ROOT::DescriptorId_t fieldId) const
A view variant that provides direct access to the I/O buffers.
friend class RNTupleCollectionView
ROOT::RNTupleGlobalRange GetFieldRange() const
~RNTupleDirectAccessView()=default
RNTupleDirectAccessView & operator=(RNTupleDirectAccessView &&other)=default
RNTupleDirectAccessView(ROOT::RField< T > field, ROOT::RNTupleGlobalRange range)
RNTupleDirectAccessView & operator=(const RNTupleDirectAccessView &other)=delete
static ROOT::RField< T > CreateField(ROOT::DescriptorId_t fieldId, ROOT::Internal::RPageSource &pageSource)
ROOT::RNTupleGlobalRange fFieldRange
RNTupleDirectAccessView(const RNTupleDirectAccessView &other)=delete
const T & operator()(RNTupleLocalIndex localIndex)
const T & operator()(ROOT::NTupleSize_t globalIndex)
RNTupleDirectAccessView(RNTupleDirectAccessView &&other)=default
const ROOT::RFieldBase & GetField() const
Used to loop over indexes (entries or collections) between start and end.
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
ROOT::NTupleSize_t GetIndexInCluster() const
ROOT::DescriptorId_t GetClusterId() const
Used to loop over entries of collections in a single cluster.
Reads RNTuple data from storage.
const ROOT::RFieldBase & GetField() const
const ROOT::RFieldBase::RValue & GetValue() const
void BindRawPtr(T *rawPtr)
RNTupleViewBase & operator=(const RNTupleViewBase &other)=delete
static std::unique_ptr< ROOT::RFieldBase > CreateField(ROOT::DescriptorId_t fieldId, Internal::RPageSource &pageSource, std::string_view typeName="")
std::unique_ptr< ROOT::RFieldBase > fField
RNTupleViewBase(RNTupleViewBase &&other)=default
ROOT::RNTupleGlobalRange GetFieldRange() const
Returns the global field range of this view.
ROOT::RFieldBase::RBulkValues CreateBulk()
ROOT::RNTupleGlobalRange fFieldRange
ROOT::RFieldBase::RValue fValue
RNTupleViewBase & operator=(RNTupleViewBase &&other)=default
~RNTupleViewBase()=default
RNTupleViewBase(const RNTupleViewBase &other)=delete
RNTupleViewBase(std::unique_ptr< ROOT::RFieldBase > field, ROOT::RNTupleGlobalRange range)
void Bind(std::shared_ptr< T > objPtr)
RNTupleViewBase(std::unique_ptr< ROOT::RFieldBase > field, ROOT::RNTupleGlobalRange range, std::shared_ptr< T > objPtr)
RNTupleViewBase(std::unique_ptr< ROOT::RFieldBase > field, ROOT::RNTupleGlobalRange range, T *rawPtr)
friend class RNTupleCollectionView
RNTupleView(const RNTupleView &other)=delete
void operator()(ROOT::NTupleSize_t globalIndex)
RNTupleView(std::unique_ptr< ROOT::RFieldBase > field, ROOT::RNTupleGlobalRange range, void *rawPtr)
RNTupleView & operator=(const RNTupleView &other)=delete
RNTupleView(RNTupleView &&other)=default
RNTupleView(std::unique_ptr< ROOT::RFieldBase > field, ROOT::RNTupleGlobalRange range)
void operator()(RNTupleLocalIndex localIndex)
RNTupleView & operator=(RNTupleView &&other)=default
RNTupleView(std::unique_ptr< ROOT::RFieldBase > field, ROOT::RNTupleGlobalRange range, std::shared_ptr< void > objPtr)
An RNTupleView for a known type.
RNTupleView & operator=(const RNTupleView &other)=delete
friend class RNTupleCollectionView
RNTupleView(RNTupleView &&other)=default
RNTupleView(std::unique_ptr< ROOT::RFieldBase > field, ROOT::RNTupleGlobalRange range, T *rawPtr)
RNTupleView(const RNTupleView &other)=delete
const T & GetValueRef() const
const T & operator()(RNTupleLocalIndex localIndex)
Reads the value of this view for the entry with the provided localIndex.
RNTupleView & operator=(RNTupleView &&other)=default
RNTupleView(std::unique_ptr< ROOT::RFieldBase > field, ROOT::RNTupleGlobalRange range)
const T & operator()(ROOT::NTupleSize_t globalIndex)
Reads the value of this view for the entry with the provided globalIndex.
RNTupleView(std::unique_ptr< ROOT::RFieldBase > field, ROOT::RNTupleGlobalRange range, std::shared_ptr< T > objPtr)
void SetAllowFieldSubstitutions(RFieldZero &fieldZero, bool val)
void CallConnectPageSourceOnField(RFieldBase &, ROOT::Internal::RPageSource &)
ROOT::RNTupleGlobalRange GetFieldRange(const ROOT::RFieldBase &field, const ROOT::Internal::RPageSource &pageSource)
Helper to get the iteration space of the given field that needs to be connected to the given page sou...
auto MakeAliasedSharedPtr(T *rawPtr)
bool IsMatchingFieldType(const std::string &actualTypeName)
Helper to check if a given type name is the one expected of Field<T>.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
constexpr DescriptorId_t kInvalidDescriptorId
Helper types to present an offset column as array of collection sizes.