Skip to content

Commit 03a939d

Browse files
committed
[ntuple] Improve documentation of RNTupleParallelWriter
1 parent 017b8bf commit 03a939d

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

tree/ntuple/inc/ROOT/RNTupleFillContext.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public:
172172

173173
void EnableMetrics() { fMetrics.Enable(); }
174174
const Detail::RNTupleMetrics &GetMetrics() const { return fMetrics; }
175-
}; // class RNTupleFillContext
175+
};
176176

177177
} // namespace Experimental
178178
} // namespace ROOT

tree/ntuple/inc/ROOT/RNTupleFillStatus.hxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class RNTupleFillContext;
3030
\ingroup NTuple
3131
\brief A status object after filling an entry
3232
33-
After passing an instance to RNTupleWriter::FillNoFlush or RNTupleFillContext::FillNoFlush, the caller must check
34-
ShouldFlushCluster and call RNTupleWriter::FlushCluster or RNTupleFillContext::FlushCluster if necessary.
33+
After passing an instance to RNTupleWriter::FillNoFlush() or RNTupleFillContext::FillNoFlush(), the caller must check
34+
ShouldFlushCluster() and call RNTupleWriter::FlushCluster() or RNTupleFillContext::FlushCluster() if necessary.
3535
*/
3636
// clang-format on
3737
class RNTupleFillStatus {
@@ -55,7 +55,7 @@ public:
5555
std::size_t GetLastEntrySize() const { return fLastEntrySize; }
5656
/// Return true if the caller should call FlushCluster.
5757
bool ShouldFlushCluster() const { return fShouldFlushCluster; }
58-
}; // class RNTupleFillContext
58+
};
5959

6060
} // namespace ROOT
6161

tree/ntuple/inc/ROOT/RNTupleParallelWriter.hxx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,19 @@ class RNTupleFillContext;
4444
\brief A writer to fill an RNTuple from multiple contexts
4545
4646
Compared to the sequential RNTupleWriter, a parallel writer enables the creation of multiple RNTupleFillContext (see
47-
RNTupleParallelWriter::CreateFillContext). Each fill context prepares independent clusters that are appended to the
48-
common ntuple with internal synchronization. Before destruction, all fill contexts must have flushed their data and
49-
been destroyed (or data could be lost!).
47+
CreateFillContext()). Each fill context prepares independent clusters that are appended to the common RNTuple with
48+
internal synchronization. Before destruction, all fill contexts must have flushed their data and been destroyed (or
49+
data could be lost!).
5050
51-
For user convenience, RNTupleParallelWriter::CreateFillContext is thread-safe and may be called from multiple threads
52-
in parallel at any time, also after some data has already been written. Internally, the original model is cloned and
53-
ownership is passed to a newly created RNTupleFillContext. For that reason, it is recommended to use
54-
RNTupleModel::CreateBare when creating the model for parallel writing and avoid the allocation of a useless default
55-
REntry per context.
51+
For user convenience, CreateFillContext() is thread-safe and may be called from multiple threads in parallel at any
52+
time, also after some data has already been written. Internally, the original model is cloned and ownership is passed
53+
to a newly created RNTupleFillContext. For that reason, it is recommended to use RNTupleModel::CreateBare when creating
54+
the model for parallel writing and avoid the allocation of a useless default REntry per context.
5655
5756
Note that the sequence of independently prepared clusters is indeterminate and therefore entries are only partially
5857
ordered: Entries from one context are totally ordered as they were filled. However, there is no orderering with other
59-
contexts and the entries may be appended to the ntuple either before or after other entries written in parallel into
60-
other contexts. In addition, two consecutive entries in one fill context can end up separated in the final ntuple, if
58+
contexts and the entries may be appended to the RNTuple either before or after other entries written in parallel into
59+
other contexts. In addition, two consecutive entries in one fill context can end up separated in the final RNTuple, if
6160
they happen to fall onto a cluster boundary and other contexts append more entries before the next cluster is full.
6261
6362
At the moment, the parallel writer does not (yet) support incremental updates of the underlying model. Please refer to
@@ -82,11 +81,17 @@ private:
8281
RNTupleParallelWriter &operator=(const RNTupleParallelWriter &) = delete;
8382

8483
public:
85-
/// Recreate a new file and return a writer to write an ntuple.
84+
/// Recreate a new file and return a writer to write an RNTuple.
8685
static std::unique_ptr<RNTupleParallelWriter>
8786
Recreate(std::unique_ptr<ROOT::RNTupleModel> model, std::string_view ntupleName, std::string_view storage,
8887
const ROOT::RNTupleWriteOptions &options = ROOT::RNTupleWriteOptions());
89-
/// Append an ntuple to the existing file, which must not be accessed while data is filled into any created context.
88+
/// Append an RNTuple to the existing file.
89+
///
90+
/// While the writer synchronizes between multiple fill contexts created from the same writer, there is no
91+
/// synchronization with other writers or other clients that write into the same file. The caller must ensure that
92+
/// the underlying file is not be accessed while data is filled into any created context. To improve performance, it
93+
/// is allowed to use special methods that are guaranteed to not interact with the underlying file, such as
94+
/// RNTupleFillContext::FillNoFlush().
9095
static std::unique_ptr<RNTupleParallelWriter>
9196
Append(std::unique_ptr<ROOT::RNTupleModel> model, std::string_view ntupleName, TDirectory &fileOrDirectory,
9297
const ROOT::RNTupleWriteOptions &options = ROOT::RNTupleWriteOptions());
@@ -97,7 +102,7 @@ public:
97102
/// thread-safe and may be called from multiple threads in parallel at any time, also after some data has already
98103
/// been written.
99104
///
100-
/// Note that all fill contexts must be destroyed before RNTupleParallelWriter::CommitDataset() is called.
105+
/// Note that all fill contexts must be destroyed before CommitDataset() is called.
101106
std::shared_ptr<RNTupleFillContext> CreateFillContext();
102107

103108
/// Automatically called by the destructor

0 commit comments

Comments
 (0)