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();
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)
99 : fFillContext(std::move(metaModel), std::move(sink)),
100 fMainFillContext(&mainFillContext),
101 fUserModel(std::move(userModel)),
102 fRangeStartPtr(std::move(rangeStartPtr)),
103 fRangeLenPtr(std::move(rangeLenPtr))
109 const auto start = fMainFillContext->GetNEntries();
123 if (pendingRange.
GetModelId() != fFillContext.GetModel().GetModelId())
125 "' was not created by it or was already committed."));
128 const auto end = fMainFillContext->GetNEntries();
129 auto &metaEntry = fFillContext.fModel->GetDefaultEntry();
131 *fRangeStartPtr = pendingRange.
GetStart();
132 *fRangeLenPtr = end - pendingRange.
GetStart();
134 fFillContext.FillImpl(pair);
139 CommitRange(std::move(pendingRange), fUserModel->GetDefaultEntry());
144 fFillContext.FlushCluster();
145 if (fFillContext.GetNEntries() > 0)
146 fFillContext.fSink->CommitClusterGroup();
147 return fFillContext.fSink->CommitDataset();
#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.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
A not-yet-finalized Attribute Range used for writing.
ROOT::NTupleSize_t GetStart() const
ROOT::DescriptorId_t GetModelId() const
Class used to write an RNTupleAttrSet in the context of an RNTupleWriter.
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...
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)
void CommitRange(RNTupleAttrPendingRange range)
Ends an attribute range and associates the current values of the fields of the attribute model's defa...
The REntry is a collection of values in an RNTuple corresponding to a complete row in the data set.
std::vector< ROOT::RFieldBase::RValue > fValues
Corresponds to the fields of the linked model.
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...
constexpr const char * kMetaFieldNames[]
@ kMetaFieldIndex_RangeLen
@ kMetaFieldIndex_UserData
@ kMetaFieldIndex_RangeStart
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