56class RPageSynchronizingSink :
public RPageSink {
59 RPageSink *fInnerSink;
63 explicit RPageSynchronizingSink(RPageSink &inner, std::mutex &mutex)
64 : RPageSink(inner.GetNTupleName(), inner.GetWriteOptions()), fInnerSink(&inner), fMutex(&mutex)
70 RPageSynchronizingSink(
const RPageSynchronizingSink &) =
delete;
71 RPageSynchronizingSink &
operator=(
const RPageSynchronizingSink &) =
delete;
73 const RNTupleDescriptor &GetDescriptor() const final {
return fInnerSink->GetDescriptor(); }
75 ColumnHandle_t AddColumn(DescriptorId_t, RColumn &)
final {
return {}; }
76 void InitImpl(RNTupleModel &)
final {}
77 void UpdateSchema(
const RNTupleModelChangeset &, NTupleSize_t)
final
81 void UpdateExtraTypeInfo(
const RExtraTypeInfoDescriptor &)
final
86 void CommitSuppressedColumn(ColumnHandle_t handle)
final { fInnerSink->CommitSuppressedColumn(handle); }
87 void CommitPage(ColumnHandle_t,
const RPage &)
final
91 void CommitSealedPage(DescriptorId_t,
const RSealedPage &)
final
95 void CommitSealedPageV(std::span<RPageStorage::RSealedPageGroup> ranges)
final
97 fInnerSink->CommitSealedPageV(ranges);
99 std::uint64_t CommitCluster(NTupleSize_t nNewEntries)
final {
return fInnerSink->CommitCluster(nNewEntries); }
100 RStagedCluster StageCluster(NTupleSize_t nNewEntries)
final {
return fInnerSink->StageCluster(nNewEntries); }
101 void CommitStagedClusters(std::span<RStagedCluster> clusters)
final { fInnerSink->CommitStagedClusters(clusters); }
102 void CommitClusterGroup() final
106 void CommitDatasetImpl() final
111 RSinkGuard GetSinkGuard() final {
return RSinkGuard(fMutex); }
117 std::unique_ptr<Internal::RPageSink> sink)
118 : fSink(std::move(sink)), fModel(std::move(model)), fMetrics(
"RNTupleParallelWriter")
120 if (
fModel->GetRegisteredSubfields().size() > 0) {
121 throw RException(
R__FAIL(
"cannot create an RNTupleWriter from a model with registered subfields"));
139 if (fModel->IsExpired())
142 for (
const auto &context : fFillContexts) {
143 if (!context.expired()) {
149 fSink->CommitClusterGroup();
150 fSink->CommitDataset();
154std::unique_ptr<ROOT::Experimental::RNTupleParallelWriter>
164 return std::unique_ptr<RNTupleParallelWriter>(
new RNTupleParallelWriter(std::move(model), std::move(sink)));
167std::unique_ptr<ROOT::Experimental::RNTupleParallelWriter>
175 auto sink = std::make_unique<Internal::RPageSinkFile>(ntupleName, fileOrDirectory, options);
177 return std::unique_ptr<RNTupleParallelWriter>(
new RNTupleParallelWriter(std::move(model), std::move(sink)));
182 std::lock_guard
g(fMutex);
184 auto model = fModel->Clone();
188 auto sink = std::make_unique<Internal::RPageSinkBuf>(std::make_unique<RPageSynchronizingSink>(*fSink, fSinkMutex));
192 std::shared_ptr<RNTupleFillContext> context(
new RNTupleFillContext(std::move(model), std::move(sink)));
193 fFillContexts.push_back(context);
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
#define R__LOG_ERROR(...)
Binding & operator=(OUT(*fun)(void))
void ObserveMetrics(RNTupleMetrics &observee)
A column is a storage-backed array of a simple, fixed-size type, from which pages can be mapped into ...
static std::unique_ptr< RPageSink > Create(std::string_view ntupleName, std::string_view location, const RNTupleWriteOptions &options=RNTupleWriteOptions())
Guess the concrete derived page source from the location.
Abstract interface to write data into an ntuple.
A page is a slice of a column that is mapped into memory.
The on-storage meta-data of an ntuple.
A context for filling entries (data) into clusters of an RNTuple.
The RNTupleModel encapulates the schema of an ntuple.
A writer to fill an RNTuple from multiple contexts.
RNTupleParallelWriter(std::unique_ptr< RNTupleModel > model, std::unique_ptr< Internal::RPageSink > sink)
static std::unique_ptr< RNTupleParallelWriter > Append(std::unique_ptr< RNTupleModel > model, std::string_view ntupleName, TDirectory &fileOrDirectory, const RNTupleWriteOptions &options=RNTupleWriteOptions())
Append an ntuple to the existing file, which must not be accessed while data is filled into any creat...
std::unique_ptr< RNTupleModel > fModel
The original RNTupleModel connected to fSink; needs to be destructed before it.
std::unique_ptr< Internal::RPageSink > fSink
The final RPageSink that represents the synchronization point.
static std::unique_ptr< RNTupleParallelWriter > Recreate(std::unique_ptr< RNTupleModel > model, std::string_view ntupleName, std::string_view storage, const RNTupleWriteOptions &options=RNTupleWriteOptions())
Recreate a new file and return a writer to write an ntuple.
std::shared_ptr< RNTupleFillContext > CreateFillContext()
Create a new RNTupleFillContext that can be used to fill entries and prepare clusters in parallel.
void CommitDataset()
Automatically called by the destructor.
Detail::RNTupleMetrics fMetrics
Common user-tunable settings for storing ntuples.
bool GetUseBufferedWrite() const
std::string GetReport() const
Format a dignostics report, e.g. for an exception message.
Base class for all ROOT issued exceptions.
const RError & GetError() const
Describe directory structure in memory.
RLogChannel & NTupleLog()
Log channel for RNTuple diagnostics.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
The incremental changes to a RNTupleModel