19 if (!projFields.IsEmpty())
20 return R__FAIL(
"The Model used to create an AttributeSet cannot contain projected fields.");
22 for (
const auto &field : model.GetConstFieldZero()) {
24 return R__FAIL(std::string(
"The Model used to create an AttributeSet cannot contain Streamer field '") +
25 field.GetQualifiedFieldName() +
"'");
35 std::size_t bytesWritten = 0;
43 ->GetMutableSubfields();
44 assert(userFields.size() ==
fScopedEntry.fValues.size());
45 for (std::size_t i = 0; i <
fScopedEntry.fValues.size(); ++i) {
46 std::shared_ptr<void> userPtr =
fScopedEntry.fValues[i].GetPtr<
void>();
47 auto value = userFields[i]->BindValue(userPtr);
48 bytesWritten += value.Append();
56std::unique_ptr<ROOT::Experimental::RNTupleAttrSetWriter>
58 std::unique_ptr<ROOT::Internal::RPageSink> sink,
59 std::unique_ptr<RNTupleModel> userModel)
72 metaModel->SetDescription(userModel->GetDescription());
75 std::vector<std::unique_ptr<RFieldBase>> fields;
76 const auto subfields = userModel->GetConstFieldZero().GetConstSubfields();
77 fields.reserve(subfields.size());
78 for (
const auto *field : subfields) {
79 fields.push_back(field->Clone(field->GetFieldName()));
83 metaModel->AddField(std::move(userRootField));
88 return std::unique_ptr<RNTupleAttrSetWriter>(
89 new RNTupleAttrSetWriter(mainFillContext, std::move(sink), std::move(metaModel), std::move(userModel),
90 std::move(rangeStartPtr), std::move(rangeLenPtr)));
94 std::unique_ptr<ROOT::Internal::RPageSink> sink,
95 std::unique_ptr<RNTupleModel> metaModel,
96 std::unique_ptr<RNTupleModel> userModel,
97 std::shared_ptr<ROOT::NTupleSize_t> rangeStartPtr,
98 std::shared_ptr<ROOT::NTupleSize_t> rangeLenPtr)
125 "' was not created by it or was already committed."));
129 auto &metaEntry =
fFillContext.fModel->GetDefaultEntry();
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
static ROOT::RResult< void > ValidateAttributeModel(const ROOT::RNTupleModel &model)
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
A not-yet-finalized Attribute Range used for writing.
ROOT::NTupleSize_t GetStart() const
ROOT::DescriptorId_t GetModelId() const
static std::unique_ptr< RNTupleAttrSetWriter > Create(const RNTupleFillContext &mainFillContext, std::unique_ptr< ROOT::Internal::RPageSink > sink, std::unique_ptr< RNTupleModel > userModel)
Creates an RNTupleAttrSetWriter associated to the RNTupleWriter owning mainFillContext and writing us...
std::shared_ptr< ROOT::NTupleSize_t > fRangeLenPtr
std::unique_ptr< RNTupleModel > fUserModel
The model that the user provided on creation. Used to create user-visible entries.
const RNTupleFillContext * fMainFillContext
Fill context of the main RNTuple being written (i.e. the RNTuple whose attributes we are).
ROOT::Internal::RNTupleLink Commit()
Commits the attributes written so far to disk and disables writing any new ones.
RNTupleAttrPendingRange BeginRange()
Begins an attribute range.
RNTupleAttrSetWriter(const RNTupleFillContext &mainFillContext, std::unique_ptr< ROOT::Internal::RPageSink > sink, std::unique_ptr< RNTupleModel > metaModel, std::unique_ptr< RNTupleModel > userModel, std::shared_ptr< ROOT::NTupleSize_t > rangeStartPtr, std::shared_ptr< ROOT::NTupleSize_t > rangeLenPtr)
std::shared_ptr< ROOT::NTupleSize_t > fRangeStartPtr
void CommitRange(RNTupleAttrPendingRange range)
Ends an attribute range and associates the current values of the fields of the attribute model's defa...
RNTupleFillContext fFillContext
Our own fill context.
const ROOT::RNTupleDescriptor & GetDescriptor() const
Returns the descriptor of the underlying attribute RNTuple.
The REntry is a collection of values in an RNTuple corresponding to a complete row in the data set.
Base class for all ROOT issued exceptions.
std::vector< RFieldBase * > GetMutableSubfields()
A context for filling entries (data) into clusters of an RNTuple.
The RNTupleModel encapulates the schema of an RNTuple.
static std::unique_ptr< RNTupleModel > Create()
void ThrowOnError()
Short-hand method to throw an exception in the case of errors.
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
@ kMetaFieldIndex_RangeLen
@ kMetaFieldIndex_UserData
@ kMetaFieldIndex_RangeStart
constexpr const char * kMetaFieldNames[]
ROOT::RFieldZero & GetFieldZeroOfModel(RNTupleModel &model)
RProjectedFields & GetProjectedFieldsOfModel(RNTupleModel &model)
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
A pair of scoped + meta entry used by the RNTupleAttrSetWriter.
ROOT::RNTupleModel & fMetaModel