The RNTupleModel encapulates the schema of an ntuple.
The ntuple model comprises a collection of hierarchically organized fields. From a model, "entries" can be extracted. For convenience, the model provides a default entry. Models have a unique model identifier that faciliates checking whether entries are compatible with it (i.e.: have been extracted from that model).
Definition at line 77 of file RNTupleModel.hxx.
Classes | |
struct | NameWithDescription_t |
A wrapper over a field name and an optional description; used in AddField() and RUpdater::AddField() More... | |
class | RProjectedFields |
Projected fields are fields whose columns are reused from existing fields. More... | |
class | RUpdater |
A model is usually immutable after passing it to an RNTupleWriter . More... | |
Public Member Functions | |
RNTupleModel (const RNTupleModel &)=delete | |
~RNTupleModel ()=default | |
template<typename T > | |
void | AddField (const NameWithDescription_t &fieldNameDesc, T *fromWhere) |
Throws an exception if fromWhere is null. | |
void | AddField (std::unique_ptr< Detail::RFieldBase > field) |
Adds a field whose type is not known at compile time. | |
RResult< void > | AddProjectedField (std::unique_ptr< Detail::RFieldBase > field, std::function< std::string(const std::string &)> mapping) |
Adds a top-level field based on existing fields. | |
std::unique_ptr< RNTupleModel > | Clone () const |
std::unique_ptr< REntry > | CreateBareEntry () const |
In a bare entry, all values point to nullptr. | |
std::unique_ptr< REntry > | CreateEntry () const |
void | Freeze () |
template<typename T > | |
T * | Get (std::string_view fieldName) const |
REntry * | GetDefaultEntry () const |
std::string | GetDescription () const |
const Detail::RFieldBase * | GetField (std::string_view fieldName) const |
RFieldZero * | GetFieldZero () const |
std::uint64_t | GetModelId () const |
const RProjectedFields & | GetProjectedFields () const |
bool | IsFrozen () const |
std::shared_ptr< RCollectionNTupleWriter > | MakeCollection (std::string_view fieldName, std::unique_ptr< RNTupleModel > collectionModel) |
Ingests a model for a sub collection and attaches it to the current model. | |
template<typename T , typename... ArgsT> | |
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 tree value that is managed by a shared pointer. | |
RNTupleModel & | operator= (const RNTupleModel &)=delete |
void | SetDescription (std::string_view description) |
void | Unfreeze () |
Static Public Member Functions | |
static std::unique_ptr< RNTupleModel > | Create () |
static std::unique_ptr< RNTupleModel > | CreateBare () |
A bare model has no default entry. | |
Private Member Functions | |
RNTupleModel () | |
void | EnsureNotBare () const |
Throws an RException if fDefaultEntry is nullptr. | |
void | EnsureNotFrozen () const |
Throws an RException if fFrozen is true. | |
void | EnsureValidFieldName (std::string_view fieldName) |
Checks that user-provided field names are valid in the context of this NTuple model. | |
Private Attributes | |
std::unique_ptr< REntry > | fDefaultEntry |
Contains field values corresponding to the created top-level fields. | |
std::string | fDescription |
Free text set by the user. | |
std::unordered_set< std::string > | fFieldNames |
Keeps track of which field names are taken, including projected field names. | |
std::unique_ptr< RFieldZero > | fFieldZero |
Hierarchy of fields consisting of simple types and collections (sub trees) | |
std::uint64_t | fModelId = 0 |
Upon freezing, every model has a unique ID to distingusish it from other models. | |
std::unique_ptr< RProjectedFields > | fProjectedFields |
The set of projected top-level fields. | |
#include <ROOT/RNTupleModel.hxx>
|
private |
Definition at line 194 of file RNTupleModel.cxx.
|
delete |
|
default |
|
inline |
Throws an exception if fromWhere is null.
Definition at line 275 of file RNTupleModel.hxx.
void ROOT::Experimental::RNTupleModel::AddField | ( | std::unique_ptr< Detail::RFieldBase > | field | ) |
Adds a field whose type is not known at compile time.
Thus there is no shared pointer returned.
Throws an exception if the field is null.
Definition at line 231 of file RNTupleModel.cxx.
ROOT::Experimental::RResult< void > ROOT::Experimental::RNTupleModel::AddProjectedField | ( | std::unique_ptr< Detail::RFieldBase > | field, |
std::function< std::string(const std::string &)> | mapping | ||
) |
Adds a top-level field based on existing fields.
The mapping function is called with the qualified field names of the provided field and the subfields. It should return the qualified field names used as a mapping source. Projected fields can only be used for models used to write data.
Definition at line 244 of file RNTupleModel.cxx.
std::unique_ptr< ROOT::Experimental::RNTupleModel > ROOT::Experimental::RNTupleModel::Clone | ( | ) | const |
Definition at line 212 of file RNTupleModel.cxx.
|
static |
Definition at line 205 of file RNTupleModel.cxx.
|
static |
A bare model has no default entry.
Definition at line 198 of file RNTupleModel.cxx.
std::unique_ptr< ROOT::Experimental::REntry > ROOT::Experimental::RNTupleModel::CreateBareEntry | ( | ) | const |
In a bare entry, all values point to nullptr.
The resulting entry shall use CaptureValueUnsafe() in order set memory addresses to be serialized / deserialized
Definition at line 331 of file RNTupleModel.cxx.
std::unique_ptr< ROOT::Experimental::REntry > ROOT::Experimental::RNTupleModel::CreateEntry | ( | ) | const |
Definition at line 319 of file RNTupleModel.cxx.
|
private |
Throws an RException if fDefaultEntry is nullptr.
Definition at line 188 of file RNTupleModel.cxx.
|
private |
Throws an RException if fFrozen is true.
Definition at line 182 of file RNTupleModel.cxx.
|
private |
Checks that user-provided field names are valid in the context of this NTuple model.
Throws an RException for invalid names.
Definition at line 170 of file RNTupleModel.cxx.
void ROOT::Experimental::RNTupleModel::Freeze | ( | ) |
Definition at line 350 of file RNTupleModel.cxx.
|
inline |
Definition at line 295 of file RNTupleModel.hxx.
ROOT::Experimental::REntry * ROOT::Experimental::RNTupleModel::GetDefaultEntry | ( | ) | const |
Definition at line 311 of file RNTupleModel.cxx.
|
inline |
Definition at line 324 of file RNTupleModel.hxx.
const ROOT::Experimental::Detail::RFieldBase * ROOT::Experimental::RNTupleModel::GetField | ( | std::string_view | fieldName | ) | const |
Definition at line 290 of file RNTupleModel.cxx.
|
inline |
Definition at line 321 of file RNTupleModel.hxx.
|
inline |
Definition at line 306 of file RNTupleModel.hxx.
|
inline |
Definition at line 301 of file RNTupleModel.hxx.
|
inline |
Definition at line 305 of file RNTupleModel.hxx.
std::shared_ptr< ROOT::Experimental::RCollectionNTupleWriter > ROOT::Experimental::RNTupleModel::MakeCollection | ( | std::string_view | fieldName, |
std::unique_ptr< RNTupleModel > | collectionModel | ||
) |
Ingests a model for a sub collection and attaches it to the current model.
Throws an exception if collectionModel is null.
Definition at line 273 of file RNTupleModel.cxx.
|
inline |
Creates a new field given a name
or {name, description}
pair and a corresponding tree value that is managed by a shared pointer.
Example: create some fields and fill an RNTuple
Example: create a field with an initial value
Example: create a field with a description
Definition at line 254 of file RNTupleModel.hxx.
|
delete |
void ROOT::Experimental::RNTupleModel::SetDescription | ( | std::string_view | description | ) |
Definition at line 361 of file RNTupleModel.cxx.
void ROOT::Experimental::RNTupleModel::Unfreeze | ( | ) |
Definition at line 343 of file RNTupleModel.cxx.
|
private |
Contains field values corresponding to the created top-level fields.
Definition at line 175 of file RNTupleModel.hxx.
|
private |
Free text set by the user.
Definition at line 179 of file RNTupleModel.hxx.
|
private |
Keeps track of which field names are taken, including projected field names.
Definition at line 177 of file RNTupleModel.hxx.
|
private |
Hierarchy of fields consisting of simple types and collections (sub trees)
Definition at line 173 of file RNTupleModel.hxx.
|
private |
Upon freezing, every model has a unique ID to distingusish it from other models.
Cloning preserves the ID. Entries are linked to models via the ID.
Definition at line 184 of file RNTupleModel.hxx.
|
private |
The set of projected top-level fields.
Definition at line 181 of file RNTupleModel.hxx.