29 const auto descGuard =
fPtrControlBlock->fPageSource->GetSharedDescriptorGuard();
32 throw RException(
R__FAIL(std::string(
"entry number ") + std::to_string(entryNumber) +
" out of range"));
35 if (itr->second++ == 0)
41 const auto descGuard =
fPtrControlBlock->fPageSource->GetSharedDescriptorGuard();
45 throw RException(
R__FAIL(std::string(
"entry number ") + std::to_string(entryNumber) +
" out of range"));
50 if (--(itr->second) == 0) {
93 assert(!other.fPtrControlBlock);
122 fieldZero.SetOnDiskId(fieldZeroId);
125 for (
auto &field : fieldZero.GetMutableSubfields()) {
129 field->SetOnDiskId(
fSource->GetSharedDescriptorGuard()->FindFieldId(field->GetFieldName(), fieldZeroId));
141 fUnzipTasks = std::make_unique<Experimental::Internal::RNTupleImtTaskScheduler>();
154 std::unique_ptr<ROOT::Internal::RPageSource> source,
160 if (!projectedFields.IsEmpty()) {
161 throw RException(
R__FAIL(
"model has projected fields, which is incompatible with providing a read model"));
182 std::string_view ntupleName, std::string_view storage,
185 return std::unique_ptr<RNTupleReader>(
192 return std::unique_ptr<RNTupleReader>(
196std::unique_ptr<ROOT::RNTupleReader>
199 return std::unique_ptr<RNTupleReader>(
207 return std::unique_ptr<RNTupleReader>(
211std::unique_ptr<ROOT::RNTupleReader>
213 std::string_view ntupleName, std::string_view storage,
216 auto reader = std::unique_ptr<RNTupleReader>(
218 reader->fCreateModelOptions = createModelOpts;
222std::unique_ptr<ROOT::RNTupleReader>
226 auto reader = std::unique_ptr<RNTupleReader>(
228 reader->fCreateModelOptions = createModelOpts;
254 std::unique_ptr<ROOT::RNTupleModel> fullModel;
256 auto descriptorGuard =
fSource->GetSharedDescriptorGuard();
257 name = descriptorGuard->GetName();
263 fullModel = descriptorGuard->CreateModel(opts);
267 output <<
"RNTuple : " <<
name <<
"\n";
276 fullModel->GetConstFieldZero().AcceptVisitor(prepVisitor);
281 fullModel->GetConstFieldZero().AcceptVisitor(printVisitor);
282 output << std::flush;
298 auto fullModel =
fSource->GetSharedDescriptorGuard()->CreateModel(opts);
308 const auto &entry = reader->GetModel().GetDefaultEntry();
310 reader->LoadEntry(index);
312 for (
auto iValue = entry.begin(); iValue != entry.end();) {
315 iValue->GetField().AcceptVisitor(visitor);
317 if (++iValue == entry.end()) {
324 output <<
"}" << std::endl;
329 auto descriptorGuard =
fSource->GetSharedDescriptorGuard();
337 auto fieldId =
fSource->GetSharedDescriptorGuard()->FindFieldId(fieldName);
339 throw RException(
R__FAIL(
"no field named '" + std::string(fieldName) +
"' in RNTuple '" +
340 fSource->GetSharedDescriptorGuard()->GetName() +
"'"));
345std::unique_ptr<ROOT::Experimental::RNTupleAttrSetReader>
350 std::find_if(attrSets.begin(), attrSets.end(), [&](
const auto &
d) { return d.GetName() == attrSetName; });
351 if (it == attrSets.end())
354 auto attrSource =
fSource->OpenWithDifferentAnchor({it->GetAnchorLocator(), it->GetAnchorLength()}, readOpts);
355 auto newReader = std::unique_ptr<RNTupleReader>(
new RNTupleReader(std::move(attrSource), readOpts));
357 auto attrSetReader = std::unique_ptr<ROOT::Experimental::RNTupleAttrSetReader>(
359 return attrSetReader;
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Class used to read a RNTupleAttrSet in the context of a RNTupleReader.
static std::unique_ptr< RPageSourceFile > CreateFromAnchor(const RNTuple &anchor, const ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions())
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 ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions())
Guess the concrete derived page source from the file name (location).
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)
Renders a JSON value corresponding to the field.
Base class for all ROOT issued exceptions.
The on-storage metadata of an RNTuple.
The RNTupleModel encapulates the schema of an RNTuple.
Common user-tunable settings for reading RNTuples.
bool GetEnableMetrics() const
An active entry token is a pledge for the data of a certain entry number not to be evicted from the p...
std::shared_ptr< RActiveEntriesControlBlock > fPtrControlBlock
NTupleSize_t fEntryNumber
RActiveEntryToken & operator=(const RActiveEntryToken &other)
void ActivateEntry(NTupleSize_t entryNumber)
void Reset()
Release the entry number, i.e.
RActiveEntryToken(std::shared_ptr< RActiveEntriesControlBlock > ptrControlBlock)
void DeactivateEntry(NTupleSize_t entryNumber)
void SetEntryNumber(NTupleSize_t entryNumber)
Set or replace the entry number.
Reads RNTuple data from storage.
std::unique_ptr< RNTupleReader > fDisplayReader
We use a dedicated on-demand reader for Show().
std::unique_ptr< ROOT::REntry > CreateEntry()
static std::unique_ptr< RNTupleReader > Open(std::string_view ntupleName, std::string_view storage, const ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions())
Open an RNTuple for reading.
void InitPageSource(bool enableMetrics)
std::unique_ptr< Internal::RPageStorage::RTaskScheduler > fUnzipTasks
Set as the page source's scheduler for parallel page decompression if implicit multi-threading (IMT) ...
ROOT::NTupleSize_t fNEntries
We know that the RNTupleReader is always reading a single RNTuple, so the number of entries is fixed.
std::unique_ptr< ROOT::RNTupleModel > fModel
Needs to be destructed before fSource.
const ROOT::RNTupleDescriptor & GetDescriptor()
Returns a cached copy of the page source descriptor.
std::optional< ROOT::RNTupleDescriptor::RCreateModelOptions > fCreateModelOptions
If not nullopt, these will be used when creating the model.
void PrintInfo(const ENTupleInfo what=ENTupleInfo::kSummary, std::ostream &output=std::cout) const
Prints a detailed summary of the RNTuple, including a list of fields.
std::unique_ptr< Internal::RPageSource > fSource
RNTupleReader(std::unique_ptr< ROOT::RNTupleModel > model, std::unique_ptr< Internal::RPageSource > source, const ROOT::RNTupleReadOptions &options)
const ROOT::RNTupleModel & GetModel()
std::unique_ptr< Experimental::RNTupleAttrSetReader > OpenAttributeSet(std::string_view attrSetName, const ROOT::RNTupleReadOptions &options={})
Looks for an attribute set with the given name and creates an RNTupleAttrSetReader for it,...
std::optional< ROOT::RNTupleDescriptor > fCachedDescriptor
The RNTuple descriptor in the page source is protected by a read-write lock.
std::shared_ptr< RActiveEntriesControlBlock > fActiveEntriesControlBlock
Initialized when the page source is connected.
void ConnectModel(ROOT::RNTupleModel &model, bool allowFieldSubstitutions)
ROOT::NTupleSize_t GetNEntries() const
Returns the number of entries in this RNTuple.
ROOT::DescriptorId_t RetrieveFieldId(std::string_view fieldName) const
void Show(ROOT::NTupleSize_t index, std::ostream &output=std::cout)
Shows the values of the i-th entry/row, starting with 0 for the first entry.
RNTupleReader * GetDisplayReader()
Experimental::Detail::RNTupleMetrics fMetrics
void EnableMetrics()
Enable performance measurements (decompression time, bytes read from storage, etc....
Representation of an RNTuple data set in a ROOT file.
void SetAllowFieldSubstitutions(RFieldZero &fieldZero, bool val)
ROOT::RFieldZero & GetFieldZeroOfModel(RNTupleModel &model)
ROOT::DescriptorId_t CallFindClusterIdOn(const ROOT::RNTupleDescriptor &desc, ROOT::NTupleSize_t entryIdx)
void CallConnectPageSourceOnField(RFieldBase &, ROOT::Internal::RPageSource &)
RProjectedFields & GetProjectedFieldsOfModel(RNTupleModel &model)
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
constexpr NTupleSize_t kInvalidNTupleIndex
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.
constexpr DescriptorId_t kInvalidDescriptorId
Modifiers passed to CreateModel().
void SetCreateBare(bool v)
void SetEmulateUnknownTypes(bool v)