16#ifndef ROOT7_RNTupleModel
17#define ROOT7_RNTupleModel
29#include <unordered_map>
30#include <unordered_set>
34namespace Experimental {
36class RNTupleCollectionWriter;
39class RNTupleWriteOptions;
72std::unique_ptr<RNTupleModel>
92 friend std::unique_ptr<RNTupleModel>
121 using FieldMap_t = std::unordered_map<const RFieldBase *, const RFieldBase *>;
179 template <
typename T,
typename... ArgsT>
184 auto it = std::find_if(fieldZero->begin(), fieldZero->end(),
185 [&](
const auto &
f) { return f.GetFieldName() == fieldNameDesc.fName; });
191 void AddField(std::unique_ptr<RFieldBase> field);
233 std::unique_ptr<RNTupleModel>
Clone()
const;
234 static std::unique_ptr<RNTupleModel>
Create();
235 static std::unique_ptr<RNTupleModel>
Create(std::unique_ptr<RFieldZero> fieldZero);
237 static std::unique_ptr<RNTupleModel>
CreateBare();
238 static std::unique_ptr<RNTupleModel>
CreateBare(std::unique_ptr<RFieldZero> fieldZero);
286 template <
typename T,
typename... ArgsT>
291 auto field = std::make_unique<RField<T>>(fieldNameDesc.
fName);
293 std::shared_ptr<T> ptr;
295 ptr =
fDefaultEntry->AddValue<T>(*field, std::forward<ArgsT>(args)...);
304 void AddField(std::unique_ptr<RFieldBase> field);
319 std::shared_ptr<RNTupleCollectionWriter>
320 MakeCollection(std::string_view fieldName, std::unique_ptr<RNTupleModel> collectionModel);
#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 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 Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
The field token identifies a top-level field in this entry.
The REntry is a collection of values in an ntuple corresponding to a complete row in the data set.
Similar to RValue but manages an array of consecutive values.
A field translates read and write calls from/to underlying columns to/from tree values.
The container field for an ntuple model, which itself has no physical representation.
Projected fields are fields whose columns are reused from existing fields.
FieldMap_t fFieldMap
Maps the source fields from fModel to the target projected fields attached to fFieldZero.
RFieldZero * GetFieldZero() const
RProjectedFields & operator=(RProjectedFields &&)=default
RProjectedFields(std::unique_ptr< RFieldZero > fieldZero)
RResult< void > EnsureValidMapping(const RFieldBase *target, const FieldMap_t &fieldMap)
Asserts that the passed field is a valid target of the source field provided in the field map.
const RNTupleModel * fModel
The model this set of projected fields belongs to.
RProjectedFields(RProjectedFields &&)=default
std::unordered_map< const RFieldBase *, const RFieldBase * > FieldMap_t
The map keys are the projected target fields, the map values are the backing source fields Note that ...
std::unique_ptr< RFieldZero > fFieldZero
The projected fields are attached to this zero field.
RProjectedFields(const RProjectedFields &)=delete
const RFieldBase * GetSourceField(const RFieldBase *target) const
RProjectedFields & operator=(const RProjectedFields &)=delete
RResult< void > Add(std::unique_ptr< RFieldBase > field, const FieldMap_t &fieldMap)
Adds a new projected field.
~RProjectedFields()=default
RProjectedFields(const RNTupleModel *model)
A model is usually immutable after passing it to an RNTupleWriter.
Internal::RNTupleModelChangeset fOpenChangeset
void CommitUpdate()
Commit changes since the last call to BeginUpdate().
void BeginUpdate()
Begin a new set of alterations to the underlying model.
std::uint64_t fNewModelId
The model ID after committing.
std::shared_ptr< T > MakeField(const NameWithDescription_t &fieldNameDesc, ArgsT &&...args)
RResult< void > AddProjectedField(std::unique_ptr< RFieldBase > field, FieldMappingFunc_t mapping)
void AddField(std::unique_ptr< RFieldBase > field)
The RNTupleModel encapulates the schema of an ntuple.
std::unordered_set< std::string > fFieldNames
Keeps track of which field names are taken, including projected field names.
std::string fDescription
Free text set by the user.
void EnsureValidFieldName(std::string_view fieldName)
Checks that user-provided field names are valid in the context of this NTuple model.
std::uint64_t fModelId
Every model has a unique ID to distinguish it from other models.
std::function< std::string(const std::string &)> FieldMappingFunc_t
User provided function that describes the mapping of existing source fields to projected fields in te...
std::uint64_t GetModelId() const
RNTupleModel(const RNTupleModel &)=delete
REntry::RFieldToken GetToken(std::string_view fieldName) const
Creates a token to be used in REntry methods to address a top-level field.
void EnsureNotBare() const
Throws an RException if fDefaultEntry is nullptr.
std::unique_ptr< RNTupleModel > Clone() const
void EnsureNotFrozen() const
Throws an RException if fFrozen is true.
REntry & GetDefaultEntry()
std::size_t EstimateWriteMemoryUsage(const RNTupleWriteOptions &options=RNTupleWriteOptions()) const
Estimate the memory usage for this model during writing.
std::shared_ptr< T > MakeField(const NameWithDescription_t &fieldNameDesc, ArgsT &&...args)
Creates a new field given a name or {name, description} pair and a corresponding value that is manage...
std::shared_ptr< RNTupleCollectionWriter > MakeCollection(std::string_view fieldName, std::unique_ptr< RNTupleModel > collectionModel)
Ingests a model for a sub collection and attaches it to the current model.
const RFieldBase & GetField(std::string_view fieldName) const
std::unique_ptr< REntry > CreateBareEntry() const
In a bare entry, all values point to nullptr.
std::unique_ptr< REntry > CreateEntry() const
RFieldBase::RBulk CreateBulk(std::string_view fieldName) const
Calls the given field's CreateBulk() method. Throws an exception if no field with the given name exis...
static std::unique_ptr< RNTupleModel > Create()
std::unique_ptr< RProjectedFields > fProjectedFields
The set of projected top-level fields.
RResult< void > AddProjectedField(std::unique_ptr< RFieldBase > field, FieldMappingFunc_t mapping)
Adds a top-level field based on existing fields.
const RFieldZero & GetFieldZero() const
void SetDescription(std::string_view description)
std::unique_ptr< REntry > fDefaultEntry
Contains field values corresponding to the created top-level fields.
RFieldBase * FindField(std::string_view fieldName) const
The field name can be a top-level field or a nested field. Returns nullptr if the field is not in the...
static std::unique_ptr< RNTupleModel > CreateBare()
A bare model has no default entry.
const std::string & GetDescription() const
const RProjectedFields & GetProjectedFields() const
void AddField(std::unique_ptr< RFieldBase > field)
Adds a field whose type is not known at compile time.
RFieldZero & GetFieldZero()
Non-const access to the root field is used to commit clusters during writing, and to make adjustments...
RNTupleModel & operator=(const RNTupleModel &)=delete
bool fIsFrozen
Changed by Freeze() / Unfreeze() and by the RUpdater.
std::unique_ptr< RFieldZero > fFieldZero
Hierarchy of fields consisting of simple types and collections (sub trees)
Common user-tunable settings for storing ntuples.
An RNTuple that gets filled with entries (data) and writes them to storage.
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
std::unique_ptr< RNTupleModel > MergeModels(const RNTupleModel &left, const RNTupleModel &right, std::string_view rightFieldPrefix="")
Merge two RNTuple models.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
The incremental changes to a RNTupleModel
std::vector< RFieldBase * > fAddedProjectedFields
Points to the projected fields in fModel that were added as part of an updater transaction.
std::vector< RFieldBase * > fAddedFields
Points to the fields in fModel that were added as part of an updater transaction.
RNTupleModelChangeset(RNTupleModel &model)
A wrapper over a field name and an optional description; used in AddField() and RUpdater::AddField()
NameWithDescription_t(const std::string &name)
NameWithDescription_t(std::string_view name)
NameWithDescription_t(std::string_view name, std::string_view descr)
NameWithDescription_t(const char *name)
std::string_view fDescription