Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTupleDS.hxx
Go to the documentation of this file.
1/// \file RNTupleDS.hxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \author Enrico Guiraud <enrico.guiraud@cern.ch>
5/// \date 2018-10-04
6/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
7/// is welcome!
8
9/*************************************************************************
10 * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. *
11 * All rights reserved. *
12 * *
13 * For the licensing terms see $ROOTSYS/LICENSE. *
14 * For the list of contributors see $ROOTSYS/README/CREDITS. *
15 *************************************************************************/
16
17#ifndef ROOT_RNTupleDS
18#define ROOT_RNTupleDS
19
20#include <ROOT/RDataFrame.hxx>
21#include <ROOT/RDataSource.hxx>
22#include <ROOT/RNTupleUtil.hxx>
23#include <ROOT/RStringView.hxx>
24
25#include <cstdint>
26#include <memory>
27#include <string>
28#include <vector>
29
30namespace ROOT {
31namespace Experimental {
32
33class RNTupleDescriptor;
34
35namespace Detail {
36class RFieldBase;
37class RFieldValue;
38class RPageSource;
39
40} // namespace Detail
41
42class RNTupleDS final : public ROOT::RDF::RDataSource {
43 /// Clones of the first source, one for each slot
44 std::vector<std::unique_ptr<ROOT::Experimental::Detail::RPageSource>> fSources;
45
46 std::vector<std::string> fColumnNames;
47 std::vector<std::string> fColumnTypes;
48 std::vector<size_t> fActiveColumns;
49
50 unsigned fNSlots = 0;
51 bool fHasSeenAllRanges = false;
52
53 void AddFields(const RNTupleDescriptor &desc, DescriptorId_t parentId);
54
55public:
56 explicit RNTupleDS(std::unique_ptr<ROOT::Experimental::Detail::RPageSource> pageSource);
57 ~RNTupleDS() = default;
58 void SetNSlots(unsigned int nSlots) final;
59 const std::vector<std::string> &GetColumnNames() const final { return fColumnNames; }
60 bool HasColumn(std::string_view colName) const final;
61 std::string GetTypeName(std::string_view colName) const final;
62 std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges() final;
63
64 bool SetEntry(unsigned int slot, ULong64_t entry) final;
65
66 void Initialise() final;
67 void Finalise() final;
68
69 std::unique_ptr<ROOT::Detail::RDF::RColumnReaderBase>
70 GetColumnReaders(unsigned int /*slot*/, std::string_view /*name*/, const std::type_info &) final;
71
72protected:
73 Record_t GetColumnReadersImpl(std::string_view name, const std::type_info &) final;
74};
75
76RDataFrame MakeNTupleDataFrame(std::string_view ntupleName, std::string_view fileName);
77
78} // ns Experimental
79} // ns ROOT
80
81#endif
unsigned long long ULong64_t
Definition RtypesCore.h:74
char name[80]
Definition TGX11.cxx:110
A field translates read and write calls from/to underlying columns to/from tree values.
Represents transient storage of simple or complex C++ values.
std::unique_ptr< ROOT::Detail::RDF::RColumnReaderBase > GetColumnReaders(unsigned int, std::string_view, const std::type_info &) final
If the other GetColumnReaders overload returns an empty vector, this overload will be called instead.
const std::vector< std::string > & GetColumnNames() const final
Returns a reference to the collection of the dataset's column names.
Definition RNTupleDS.hxx:59
void SetNSlots(unsigned int nSlots) final
Inform RDataSource of the number of processing slots (i.e.
bool SetEntry(unsigned int slot, ULong64_t entry) final
Advance the "cursors" returned by GetColumnReaders to the selected entry for a particular slot.
std::vector< std::unique_ptr< ROOT::Experimental::Detail::RPageSource > > fSources
Clones of the first source, one for each slot.
Definition RNTupleDS.hxx:44
Record_t GetColumnReadersImpl(std::string_view name, const std::type_info &) final
type-erased vector of pointers to pointers to column values - one per slot
Definition RNTupleDS.cxx:94
std::vector< std::string > fColumnNames
Definition RNTupleDS.hxx:46
std::string GetTypeName(std::string_view colName) const final
Type of a column as a string, e.g.
std::vector< std::pair< ULong64_t, ULong64_t > > GetEntryRanges() final
Return ranges of entries to distribute to tasks.
std::vector< size_t > fActiveColumns
Definition RNTupleDS.hxx:48
bool HasColumn(std::string_view colName) const final
Checks if the dataset has a certain column.
void Finalise() final
Convenience method called after concluding an event-loop.
std::vector< std::string > fColumnTypes
Definition RNTupleDS.hxx:47
void AddFields(const RNTupleDescriptor &desc, DescriptorId_t parentId)
Definition RNTupleDS.cxx:73
void Initialise() final
Convenience method called before starting an event-loop.
The on-storage meta-data of an ntuple.
Pure virtual base class for all column reader types.
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
std::vector< void * > Record_t
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
RDataFrame MakeNTupleDataFrame(std::string_view ntupleName, std::string_view fileName)
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...