38#include <unordered_map>
50 fTaskGroup = std::make_unique<TTaskGroup>();
56 fTaskGroup->Run(taskFunc);
71 const auto &desc = fSource->GetDescriptor();
77 field.SetOnDiskId(desc.FindFieldId(field.GetName(), field.GetParent()->GetOnDiskId()));
79 field.ConnectPageSource(*fSource);
87 fUnzipTasks = std::make_unique<RNTupleImtTaskScheduler>();
88 fSource->SetTaskScheduler(fUnzipTasks.get());
92 fMetrics.ObserveMetrics(fSource->GetMetrics());
96 std::unique_ptr<ROOT::Experimental::RNTupleModel> model,
97 std::unique_ptr<ROOT::Experimental::Detail::RPageSource> source)
98 : fSource(std::move(source))
99 , fModel(std::move(model))
100 , fMetrics(
"RNTupleReader")
113 : fSource(std::move(source))
115 , fMetrics(
"RNTupleReader")
126 std::unique_ptr<RNTupleModel> model,
127 std::string_view ntupleName,
128 std::string_view storage,
135 std::string_view ntupleName,
136 std::string_view storage,
143 std::span<ROpenSpec> ntuples)
145 std::vector<std::unique_ptr<Detail::RPageSource>> sources;
146 for (
const auto &
n : ntuples) {
149 return std::make_unique<RNTupleReader>(std::make_unique<Detail::RPageSourceFriends>(
"_friends", sources));
155 fModel = fSource->GetDescriptor().GenerateModel();
156 ConnectModel(*fModel);
164 char frameSymbol =
'*';
172 std::string
name = fSource->GetDescriptor().GetName();
175 for (
int i = 0; i < (
width/2 +
width%2 - 4); ++i)
178 for (
int i = 0; i < (
width/2 - 4); ++i)
191 auto fullModel = fSource->GetDescriptor().GenerateModel();
192 fullModel->GetFieldZero()->AcceptVisitor(prepVisitor);
199 for (
int i = 0; i <
width; ++i)
202 fullModel->GetFieldZero()->AcceptVisitor(printVisitor);
203 for (
int i = 0; i <
width; ++i)
209 fSource->GetDescriptor().PrintInfo(
output);
224 fDisplayReader = Clone();
225 return fDisplayReader.get();
235 entry = fModel->GetDefaultEntry();
239 reader = GetDisplayReader();
244 output <<
"{}" << std::endl;
250 for (
auto iValue = entry->
begin(); iValue != entry->
end(); ) {
253 iValue->GetField()->AcceptVisitor(visitor);
255 if (++iValue == entry->
end()) {
262 output <<
"}" << std::endl;
275 std::unique_ptr<ROOT::Experimental::RNTupleModel> model,
276 std::unique_ptr<ROOT::Experimental::Detail::RPageSink> sink)
277 : fSink(std::move(sink))
278 , fModel(std::move(model))
279 , fMetrics(
"RNTupleWriter")
289 fZipTasks = std::make_unique<RNTupleImtTaskScheduler>();
296 const auto &writeOpts =
fSink->GetWriteOptions();
299 const int scale = writeOpts.GetCompression() ? 2 : 1;
306 fSink->CommitDataset();
310 std::unique_ptr<RNTupleModel> model,
311 std::string_view ntupleName,
312 std::string_view storage,
319 std::unique_ptr<RNTupleModel> model,
320 std::string_view ntupleName,
324 auto sink = std::make_unique<Detail::RPageSinkFile>(ntupleName,
file, options);
326 auto bufferedSink = std::make_unique<Detail::RPageSinkBuf>(std::move(sink));
327 return std::make_unique<RNTupleWriter>(std::move(model), std::move(bufferedSink));
329 return std::make_unique<RNTupleWriter>(std::move(model), std::move(sink));
335 if (fNEntries == fLastCommitted)
return;
336 for (
auto& field : *fModel->GetFieldZero()) {
338 field.CommitCluster();
340 fNBytesCommitted += fSink->CommitCluster(fNEntries);
341 fNBytesFilled += fUnzippedClusterSize;
344 const float compressionFactor = std::min(1000.f,
345 static_cast<float>(fNBytesFilled) /
static_cast<float>(fNBytesCommitted));
346 fUnzippedClusterSizeEst =
347 compressionFactor *
static_cast<float>(fSink->GetWriteOptions().GetApproxZippedClusterSize());
349 fLastCommitted = fNEntries;
350 fUnzippedClusterSize = 0;
358 : fOffset(0), fDefaultEntry(std::move(defaultEntry))
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
include TDocParser_001 C image html pict1_TDocParser_001 png width
void SetOnDiskId(DescriptorId_t id)
void ObserveMetrics(RNTupleMetrics &observee)
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 file name (location)
static std::unique_ptr< RPageSource > Create(std::string_view ntupleName, std::string_view location, const RNTupleReadOptions &options=RNTupleReadOptions())
Guess the concrete derived page source from the file name (location)
RCollectionNTupleWriter(std::unique_ptr< REntry > defaultEntry)
The REntry is a collection of values in an ntuple corresponding to a complete row in the data set.
Base class for all ROOT issued exceptions.
void Reset() final
Start a new set of tasks.
void AddTask(const std::function< void(void)> &taskFunc) final
Take a callable that represents a task.
RNTupleImtTaskScheduler()
void Wait() final
Blocks until all scheduled tasks finished.
The RNTupleModel encapulates the schema of an ntuple.
REntry * GetDefaultEntry()
RFieldZero * GetFieldZero() const
Common user-tunable settings for reading ntuples.
An RNTuple that is used to read data from storage.
static std::unique_ptr< RNTupleReader > OpenFriends(std::span< ROpenSpec > ntuples)
Open RNTuples as one virtual, horizontally combined ntuple.
RNTupleReader * GetDisplayReader()
static std::unique_ptr< RNTupleReader > Open(std::unique_ptr< RNTupleModel > model, std::string_view ntupleName, std::string_view storage, const RNTupleReadOptions &options=RNTupleReadOptions())
Throws an exception if the model is null.
std::unique_ptr< Detail::RPageSource > fSource
void ConnectModel(const RNTupleModel &model)
RNTupleReader(std::unique_ptr< RNTupleModel > model, std::unique_ptr< Detail::RPageSource > source)
The user imposes an ntuple model, which must be compatible with the model found in the data on storag...
RNTupleModel * GetModel()
void LoadEntry(NTupleSize_t index)
Analogous to Fill(), fills the default entry of the model.
void PrintInfo(const ENTupleInfo what=ENTupleInfo::kSummary, std::ostream &output=std::cout)
Prints a detailed summary of the ntuple, including a list of fields.
std::unique_ptr< RNTupleModel > fModel
Needs to be destructed before fSource.
void Show(NTupleSize_t index, const ENTupleShowFormat format=ENTupleShowFormat::kCurrentModelJSON, std::ostream &output=std::cout)
Shows the values of the i-th entry/row, starting with 0 for the first entry.
Common user-tunable settings for storing ntuples.
bool GetUseBufferedWrite() const
void CommitCluster()
Ensure that the data from the so far seen Fill calls has been written to storage.
NTupleSize_t fUnzippedClusterSizeEst
Estimator of uncompressed cluster size, taking into account the estimated compression ratio.
RNTupleWriter(std::unique_ptr< RNTupleModel > model, std::unique_ptr< Detail::RPageSink > sink)
Throws an exception if the model or the sink is null.
std::size_t fMaxUnzippedClusterSize
Limit for committing cluster no matter the other tunables.
std::unique_ptr< RNTupleModel > fModel
Needs to be destructed before fSink.
Detail::RNTupleMetrics fMetrics
std::unique_ptr< Detail::RPageSink > fSink
static std::unique_ptr< RNTupleWriter > Recreate(std::unique_ptr< RNTupleModel > model, std::string_view ntupleName, std::string_view storage, const RNTupleWriteOptions &options=RNTupleWriteOptions())
Throws an exception if the model is null.
std::unique_ptr< Detail::RPageStorage::RTaskScheduler > fZipTasks
The page sink's parallel page compression scheduler if IMT is on.
static std::unique_ptr< RNTupleWriter > Append(std::unique_ptr< RNTupleModel > model, std::string_view ntupleName, TFile &file, const RNTupleWriteOptions &options=RNTupleWriteOptions())
Throws an exception if the model is null.
Visitor used for a pre-processing run to collect information needed by another visitor class.
unsigned int GetDeepestLevel() const
unsigned int GetNumFields() const
Contains settings for printing and prints a summary of an RField instance.
void SetDeepestLevel(int d)
void SetFrameSymbol(char s)
Renders a JSON value corresponding to the field.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
ENTupleInfo
Listing of the different options that can be printed by RNTupleReader::GetInfo()
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
ENTupleShowFormat
Listing of the different entry output formats of RNTupleReader::Show()
constexpr DescriptorId_t kInvalidDescriptorId
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
static void output(int code)