40#include <unordered_map>
52 fTaskGroup = std::make_unique<TTaskGroup>();
58 fTaskGroup->Run(taskFunc);
80 fSource->GetSharedDescriptorGuard()->FindFieldId(field.GetName(), field.GetParent()->GetOnDiskId()));
82 field.ConnectPageSource(*fSource);
90 fUnzipTasks = std::make_unique<RNTupleImtTaskScheduler>();
91 fSource->SetTaskScheduler(fUnzipTasks.get());
95 fMetrics.ObserveMetrics(fSource->GetMetrics());
99 std::unique_ptr<ROOT::Experimental::RNTupleModel> model,
100 std::unique_ptr<ROOT::Experimental::Detail::RPageSource> source)
101 : fSource(std::move(source))
102 , fModel(std::move(model))
103 , fMetrics(
"RNTupleReader")
117 : fSource(std::move(source))
119 , fMetrics(
"RNTupleReader")
130 std::unique_ptr<RNTupleModel> model,
131 std::string_view ntupleName,
132 std::string_view storage,
139 std::string_view ntupleName,
140 std::string_view storage,
146std::unique_ptr<ROOT::Experimental::RNTupleReader>
149 return std::make_unique<RNTupleReader>(ntuple->
MakePageSource(options));
153 std::span<ROpenSpec> ntuples)
155 std::vector<std::unique_ptr<Detail::RPageSource>> sources;
156 for (
const auto &
n : ntuples) {
159 return std::make_unique<RNTupleReader>(std::make_unique<Detail::RPageSourceFriends>(
"_friends", sources));
165 fModel = fSource->GetSharedDescriptorGuard()->GenerateModel();
166 ConnectModel(*fModel);
174 char frameSymbol =
'*';
185 std::unique_ptr<RNTupleModel> fullModel;
187 auto descriptorGuard = fSource->GetSharedDescriptorGuard();
188 name = descriptorGuard->GetName();
189 fullModel = descriptorGuard->GenerateModel();
192 for (
int i = 0; i < (
width/2 +
width%2 - 4); ++i)
195 for (
int i = 0; i < (
width/2 - 4); ++i)
208 fullModel->GetFieldZero()->AcceptVisitor(prepVisitor);
215 for (
int i = 0; i <
width; ++i)
218 fullModel->GetFieldZero()->AcceptVisitor(printVisitor);
219 for (
int i = 0; i <
width; ++i)
238 fDisplayReader = Clone();
239 return fDisplayReader.get();
249 entry = fModel->GetDefaultEntry();
253 reader = GetDisplayReader();
258 output <<
"{}" << std::endl;
264 for (
auto iValue = entry->
begin(); iValue != entry->
end(); ) {
267 iValue->GetField()->AcceptVisitor(visitor);
269 if (++iValue == entry->
end()) {
276 output <<
"}" << std::endl;
286 auto descriptorGuard = fSource->GetSharedDescriptorGuard();
287 if (!fCachedDescriptor || fCachedDescriptor->GetGeneration() != descriptorGuard->GetGeneration())
288 fCachedDescriptor = descriptorGuard->
Clone();
289 return fCachedDescriptor.get();
296 std::unique_ptr<ROOT::Experimental::RNTupleModel> model,
297 std::unique_ptr<ROOT::Experimental::Detail::RPageSink> sink)
298 : fSink(std::move(sink))
299 , fModel(std::move(model))
300 , fMetrics(
"RNTupleWriter")
311 fZipTasks = std::make_unique<RNTupleImtTaskScheduler>();
318 const auto &writeOpts =
fSink->GetWriteOptions();
321 const int scale = writeOpts.GetCompression() ? 2 : 1;
327 CommitCluster(
true );
328 fSink->CommitDataset();
332 std::unique_ptr<RNTupleModel> model,
333 std::string_view ntupleName,
334 std::string_view storage,
341 std::unique_ptr<RNTupleModel> model,
342 std::string_view ntupleName,
346 auto sink = std::make_unique<Detail::RPageSinkFile>(ntupleName,
file, options);
348 auto bufferedSink = std::make_unique<Detail::RPageSinkBuf>(std::move(sink));
349 return std::make_unique<RNTupleWriter>(std::move(model), std::move(bufferedSink));
351 return std::make_unique<RNTupleWriter>(std::move(model), std::move(sink));
356 if (fNEntries == fLastCommittedClusterGroup)
358 fSink->CommitClusterGroup();
359 fLastCommittedClusterGroup = fNEntries;
364 if (fNEntries == fLastCommitted) {
365 if (commitClusterGroup)
366 CommitClusterGroup();
369 for (
auto& field : *fModel->GetFieldZero()) {
371 field.CommitCluster();
373 fNBytesCommitted += fSink->CommitCluster(fNEntries);
374 fNBytesFilled += fUnzippedClusterSize;
377 const float compressionFactor = std::min(1000.f,
378 static_cast<float>(fNBytesFilled) /
static_cast<float>(fNBytesCommitted));
379 fUnzippedClusterSizeEst =
380 compressionFactor *
static_cast<float>(fSink->GetWriteOptions().GetApproxZippedClusterSize());
382 fLastCommitted = fNEntries;
383 fUnzippedClusterSize = 0;
385 if (commitClusterGroup)
386 CommitClusterGroup();
394 : fOffset(0), fDefaultEntry(std::move(defaultEntry))
402 static TClassRef RNTupleAnchorClass(
"ROOT::Experimental::Internal::RFileNTupleAnchor");
413std::unique_ptr<ROOT::Experimental::Detail::RPageSource>
422 auto path = fFile->GetEndpointUrl()->GetFile();
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
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< RPageSourceFile > CreateFromAnchor(const Internal::RFileNTupleAnchor &anchor, std::string_view path, const RNTupleReadOptions &options)
Used from the RNTuple class to build a datasource if the anchor is already available.
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.
The on-storage meta-data of an ntuple.
std::unique_ptr< RNTupleDescriptor > Clone() const
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() const
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()
const RNTupleDescriptor * GetDescriptor()
Returns a cached copy of the page source descriptor.
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
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.
void CommitCluster(bool commitClusterGroup=false)
Ensure that the data from the so far seen Fill calls has been written to storage.
std::unique_ptr< RNTupleModel > fModel
Needs to be destructed before fSink.
void CommitClusterGroup()
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.
Representation of an RNTuple data set in a ROOT file.
std::unique_ptr< Detail::RPageSource > MakePageSource(const RNTupleReadOptions &options=RNTupleReadOptions())
Create a page source from the RNTuple object.
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.
Buffer base class used for serializing objects.
TObject * GetParent() const
Return pointer to parent of this buffer.
TClassRef is used to implement a permanent reference to a TClass object.
Int_t ReadBuffer(TBuffer &b, void *pointer, Int_t version, UInt_t start, UInt_t count)
Function called by the Streamer functions to deserialize information from buffer b into object at p.
Int_t WriteBuffer(TBuffer &b, void *pointer, const char *info="")
Function called by the Streamer functions to serialize object at p to buffer b.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
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.
Entry point for an RNTuple in a ROOT file.