Skip to content

Commit c949817

Browse files
committed
[ntuple] Move RNTupleParallelWriter out of Experimental
1 parent 03a939d commit c949817

15 files changed

+53
-82
lines changed

README/ReleaseNotes/v638/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ The following people have contributed to this new version:
5656

5757
* Behaviour change: the behaviour of `TChain::SetBranchStatus` has been aligned to the one of `TTree::SetBranchStatus`. In particular, when `SetBranchStatus` is called to deactivate all branches, a subsequent call to `TChain::SetBranchAddress` would override the previous instruction and activate that single branch. Instead `TTree::SetBranchAddress` respects the rule imposed by `SetBranchStatus`. If a user needs to activate only one or more branches, they should call `SetBranchStatus("brName", true)` on each branch that needs to be active in the TChain, like it was already necessary for a TTree. See https://github.com/root-project/root/pull/19221 for more details.
5858

59+
### RNTuple
60+
61+
* The parallel writer is now part of the public, stable API. The `RNTupleParallelWriter` and the closely related `RNTupleFillContext` moved from the `ROOT::Experimental` to the `ROOT` namespace.
62+
5963
## Math
6064

6165
### Minuit2

tree/dataframe/inc/ROOT/RDF/SnapshotHelpers.hxx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ class TBranch;
3030
class TFile;
3131

3232
namespace ROOT {
33-
namespace Experimental {
34-
class RNTupleFillContext;
35-
class RNTupleParallelWriter;
36-
} // namespace Experimental
3733
class REntry;
3834
class RFieldToken;
35+
class RNTupleFillContext;
36+
class RNTupleParallelWriter;
3937
class TBufferMerger;
4038
class TBufferMergerFile;
4139
} // namespace ROOT
@@ -54,11 +52,11 @@ class R__CLING_PTRCHECK(off) UntypedSnapshotRNTupleHelper final : public RAction
5452
ROOT::Detail::RDF::RLoopManager *fOutputLoopManager;
5553
ColumnNames_t fInputFieldNames; // This contains the resolved aliases
5654
ColumnNames_t fOutputFieldNames;
57-
std::unique_ptr<ROOT::Experimental::RNTupleParallelWriter> fWriter;
55+
std::unique_ptr<ROOT::RNTupleParallelWriter> fWriter;
5856
std::vector<ROOT::RFieldToken> fFieldTokens;
5957

6058
unsigned int fNSlots;
61-
std::vector<std::shared_ptr<ROOT::Experimental::RNTupleFillContext>> fFillContexts;
59+
std::vector<std::shared_ptr<ROOT::RNTupleFillContext>> fFillContexts;
6260
std::vector<std::unique_ptr<ROOT::REntry>> fEntries;
6361

6462
std::vector<const std::type_info *> fInputColumnTypeIDs; // Types for the input columns

tree/dataframe/src/RDFSnapshotHelpers.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ void ROOT::Internal::RDF::UntypedSnapshotRNTupleHelper::Initialize()
871871

872872
// The RNTupleParallelWriter has exclusive access to the underlying TFile, no further synchronization is needed for
873873
// calls to Fill() (in Exec) and FlushCluster() (in FinalizeTask).
874-
fWriter = ROOT::Experimental::RNTupleParallelWriter::Append(std::move(model), fNTupleName, *outputDir, writeOptions);
874+
fWriter = ROOT::RNTupleParallelWriter::Append(std::move(model), fNTupleName, *outputDir, writeOptions);
875875
}
876876

877877
void ROOT::Internal::RDF::UntypedSnapshotRNTupleHelper::InitTask(TTreeReader *, unsigned int slot)

tree/ntuple/inc/ROOT/REntry.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131

3232
namespace ROOT {
3333

34+
class RNTupleFillContext;
3435
class RNTupleReader;
3536

3637
namespace Experimental {
37-
class RNTupleFillContext;
3838
class RNTupleProcessor;
3939
class RNTupleSingleProcessor;
4040
class RNTupleChainProcessor;
@@ -52,9 +52,9 @@ with values are managed through shared pointers.
5252
*/
5353
// clang-format on
5454
class REntry {
55+
friend class RNTupleFillContext;
5556
friend class RNTupleModel;
5657
friend class RNTupleReader;
57-
friend class Experimental::RNTupleFillContext;
5858
friend class Experimental::RNTupleProcessor;
5959
friend class Experimental::RNTupleSingleProcessor;
6060
friend class Experimental::RNTupleChainProcessor;

tree/ntuple/inc/ROOT/RNTupleFillContext.hxx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
/// \ingroup NTuple
33
/// \author Jakob Blomer <[email protected]>
44
/// \date 2024-02-22
5-
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6-
/// is welcome!
75

86
/*************************************************************************
97
* Copyright (C) 1995-2024, Rene Brun and Fons Rademakers. *
@@ -32,11 +30,10 @@
3230
#include <vector>
3331

3432
namespace ROOT {
35-
namespace Experimental {
3633

3734
// clang-format off
3835
/**
39-
\class ROOT::Experimental::RNTupleFillContext
36+
\class ROOT::RNTupleFillContext
4037
\ingroup NTuple
4138
\brief A context for filling entries (data) into clusters of an RNTuple
4239
@@ -61,7 +58,7 @@ private:
6158
/// Needs to be destructed before fSink
6259
std::unique_ptr<ROOT::RNTupleModel> fModel;
6360

64-
Detail::RNTupleMetrics fMetrics;
61+
Experimental::Detail::RNTupleMetrics fMetrics;
6562

6663
ROOT::NTupleSize_t fLastFlushed = 0;
6764
ROOT::NTupleSize_t fNEntries = 0;
@@ -132,14 +129,14 @@ public:
132129
///
133130
/// This method will check the entry's model ID to ensure it comes from the context's own model or throw an exception
134131
/// otherwise.
135-
void FillNoFlush(Detail::RRawPtrWriteEntry &entry, ROOT::RNTupleFillStatus &status)
132+
void FillNoFlush(Experimental::Detail::RRawPtrWriteEntry &entry, ROOT::RNTupleFillStatus &status)
136133
{
137134
FillNoFlushImpl(entry, status);
138135
}
139136
/// Fill an RRawPtrWriteEntry into this context. This method will check the entry's model ID to ensure it comes
140137
/// from the context's own model or throw an exception otherwise.
141138
/// \return The number of uncompressed bytes written.
142-
std::size_t Fill(Detail::RRawPtrWriteEntry &entry) { return FillImpl(entry); }
139+
std::size_t Fill(Experimental::Detail::RRawPtrWriteEntry &entry) { return FillImpl(entry); }
143140

144141
/// Flush column data, preparing for CommitCluster or to reduce memory usage. This will trigger compression of pages,
145142
/// but not actually write to storage.
@@ -151,7 +148,7 @@ public:
151148

152149
const ROOT::RNTupleModel &GetModel() const { return *fModel; }
153150
std::unique_ptr<ROOT::REntry> CreateEntry() const { return fModel->CreateEntry(); }
154-
std::unique_ptr<Detail::RRawPtrWriteEntry> CreateRawPtrWriteEntry() const
151+
std::unique_ptr<Experimental::Detail::RRawPtrWriteEntry> CreateRawPtrWriteEntry() const
155152
{
156153
return fModel->CreateRawPtrWriteEntry();
157154
}
@@ -171,10 +168,9 @@ public:
171168
bool IsStagedClusterCommittingEnabled() const { return fStagedClusterCommitting; }
172169

173170
void EnableMetrics() { fMetrics.Enable(); }
174-
const Detail::RNTupleMetrics &GetMetrics() const { return fMetrics; }
171+
const Experimental::Detail::RNTupleMetrics &GetMetrics() const { return fMetrics; }
175172
};
176173

177-
} // namespace Experimental
178174
} // namespace ROOT
179175

180176
#endif // ROOT_RNTupleFillContext

tree/ntuple/inc/ROOT/RNTupleFillStatus.hxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020

2121
namespace ROOT {
2222

23-
namespace Experimental {
2423
class RNTupleFillContext;
25-
}
2624

2725
// clang-format off
2826
/**
@@ -35,7 +33,7 @@ ShouldFlushCluster() and call RNTupleWriter::FlushCluster() or RNTupleFillContex
3533
*/
3634
// clang-format on
3735
class RNTupleFillStatus {
38-
friend class Experimental::RNTupleFillContext;
36+
friend class RNTupleFillContext;
3937

4038
private:
4139
/// Number of entries written into the current cluster

tree/ntuple/inc/ROOT/RNTupleParallelWriter.hxx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
/// \ingroup NTuple
33
/// \author Jonas Hahnfeld <[email protected]>
44
/// \date 2024-02-01
5-
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6-
/// is welcome!
75

86
/*************************************************************************
97
* Copyright (C) 1995-2024, Rene Brun and Fons Rademakers. *
@@ -34,12 +32,10 @@ namespace Internal {
3432
class RPageSink;
3533
} // namespace Internal
3634

37-
namespace Experimental {
38-
3935
class RNTupleFillContext;
4036

4137
/**
42-
\class ROOT::Experimental::RNTupleParallelWriter
38+
\class ROOT::RNTupleParallelWriter
4339
\ingroup NTuple
4440
\brief A writer to fill an RNTuple from multiple contexts
4541
@@ -72,7 +68,7 @@ private:
7268
std::unique_ptr<ROOT::Internal::RPageSink> fSink;
7369
/// The original RNTupleModel connected to fSink; needs to be destructed before it.
7470
std::unique_ptr<ROOT::RNTupleModel> fModel;
75-
Detail::RNTupleMetrics fMetrics;
71+
Experimental::Detail::RNTupleMetrics fMetrics;
7672
/// List of all created helpers. They must be destroyed before this RNTupleParallelWriter is destructed.
7773
std::vector<std::weak_ptr<RNTupleFillContext>> fFillContexts;
7874

@@ -109,10 +105,9 @@ public:
109105
void CommitDataset();
110106

111107
void EnableMetrics() { fMetrics.Enable(); }
112-
const Detail::RNTupleMetrics &GetMetrics() const { return fMetrics; }
108+
const Experimental::Detail::RNTupleMetrics &GetMetrics() const { return fMetrics; }
113109
};
114110

115-
} // namespace Experimental
116111
} // namespace ROOT
117112

118113
#endif

tree/ntuple/inc/ROOT/RNTupleWriter.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class RNTupleWriter {
104104
Internal::CreateRNTupleWriter(std::unique_ptr<ROOT::RNTupleModel>, std::unique_ptr<Internal::RPageSink>);
105105

106106
private:
107-
Experimental::RNTupleFillContext fFillContext;
107+
RNTupleFillContext fFillContext;
108108
Experimental::Detail::RNTupleMetrics fMetrics;
109109

110110
ROOT::NTupleSize_t fLastCommittedClusterGroup = 0;

tree/ntuple/inc/ROOT/RRawPtrWriteEntry.hxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ namespace ROOT {
2828

2929
class RNTupleModel;
3030

31-
namespace Experimental {
32-
3331
class RNTupleFillContext;
3432

33+
namespace Experimental {
3534
namespace Detail {
3635

3736
// clang-format off
@@ -46,7 +45,7 @@ provided by REntry, with safe interfaces, type checks, and shared object ownersh
4645
// clang-format on
4746
class RRawPtrWriteEntry {
4847
friend class ROOT::RNTupleModel;
49-
friend class ROOT::Experimental::RNTupleFillContext;
48+
friend class ROOT::RNTupleFillContext;
5049

5150
private:
5251
/// The entry must be linked to a specific model, identified by a model ID

tree/ntuple/src/RNTupleFillContext.cxx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
/// \ingroup NTuple
33
/// \author Jakob Blomer <[email protected]>
44
/// \date 2024-02-22
5-
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6-
/// is welcome!
75

86
/*************************************************************************
97
* Copyright (C) 1995-2024, Rene Brun and Fons Rademakers. *
@@ -27,8 +25,8 @@
2725
#include <algorithm>
2826
#include <utility>
2927

30-
ROOT::Experimental::RNTupleFillContext::RNTupleFillContext(std::unique_ptr<ROOT::RNTupleModel> model,
31-
std::unique_ptr<ROOT::Internal::RPageSink> sink)
28+
ROOT::RNTupleFillContext::RNTupleFillContext(std::unique_ptr<ROOT::RNTupleModel> model,
29+
std::unique_ptr<ROOT::Internal::RPageSink> sink)
3230
: fSink(std::move(sink)), fModel(std::move(model)), fMetrics("RNTupleFillContext")
3331
{
3432
fModel->Freeze();
@@ -42,7 +40,7 @@ ROOT::Experimental::RNTupleFillContext::RNTupleFillContext(std::unique_ptr<ROOT:
4240
fUnzippedClusterSizeEst = scale * writeOpts.GetApproxZippedClusterSize();
4341
}
4442

45-
ROOT::Experimental::RNTupleFillContext::~RNTupleFillContext()
43+
ROOT::RNTupleFillContext::~RNTupleFillContext()
4644
{
4745
try {
4846
FlushCluster();
@@ -56,14 +54,14 @@ ROOT::Experimental::RNTupleFillContext::~RNTupleFillContext()
5654
}
5755
}
5856

59-
void ROOT::Experimental::RNTupleFillContext::FlushColumns()
57+
void ROOT::RNTupleFillContext::FlushColumns()
6058
{
6159
for (auto &field : ROOT::Internal::GetFieldZeroOfModel(*fModel)) {
6260
ROOT::Internal::CallFlushColumnsOnField(field);
6361
}
6462
}
6563

66-
void ROOT::Experimental::RNTupleFillContext::FlushCluster()
64+
void ROOT::RNTupleFillContext::FlushCluster()
6765
{
6866
if (fNEntries == fLastFlushed) {
6967
return;
@@ -91,7 +89,7 @@ void ROOT::Experimental::RNTupleFillContext::FlushCluster()
9189
fUnzippedClusterSize = 0;
9290
}
9391

94-
void ROOT::Experimental::RNTupleFillContext::CommitStagedClusters()
92+
void ROOT::RNTupleFillContext::CommitStagedClusters()
9593
{
9694
if (fStagedClusters.empty()) {
9795
return;

0 commit comments

Comments
 (0)