Logo ROOT  
Reference Guide
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/// \date 2018-10-04
5/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6/// is welcome!
7
8/*************************************************************************
9 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
10 * All rights reserved. *
11 * *
12 * For the licensing terms see $ROOTSYS/LICENSE. *
13 * For the list of contributors see $ROOTSYS/README/CREDITS. *
14 *************************************************************************/
15
16#ifndef ROOT_RNTupleDS
17#define ROOT_RNTupleDS
18
19#include <ROOT/RDataFrame.hxx>
20#include <ROOT/RDataSource.hxx>
21#include <ROOT/RStringView.hxx>
22
23#include <cstdint>
24#include <memory>
25#include <string>
26#include <vector>
27
28namespace ROOT {
29namespace Experimental {
30
31class RNTupleReader;
32class REntry;
33
34
35class RNTupleDS final : public ROOT::RDF::RDataSource {
36 /// Clones of the first reader, one for each slot
37 std::vector<std::unique_ptr<ROOT::Experimental::RNTupleReader>> fReaders;
38 std::vector<std::unique_ptr<ROOT::Experimental::REntry>> fEntries;
39 /// The raw pointers wrapped by the RValue items of fEntries
40 std::vector<std::vector<void*>> fValuePtrs;
41 unsigned fNSlots = 0;
42 bool fHasSeenAllRanges = false;
43 std::vector<std::string> fColumnNames;
44 std::vector<std::string> fColumnTypes;
45
46public:
47 explicit RNTupleDS(std::unique_ptr<ROOT::Experimental::RNTupleReader> ntuple);
48 ~RNTupleDS() = default;
49 void SetNSlots(unsigned int nSlots) final;
50 const std::vector<std::string> &GetColumnNames() const final;
51 bool HasColumn(std::string_view colName) const final;
52 std::string GetTypeName(std::string_view colName) const final;
53 std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges() final;
54
55 bool SetEntry(unsigned int slot, ULong64_t entry) final;
56
57 void Initialise() final;
58
59protected:
60 Record_t GetColumnReadersImpl(std::string_view name, const std::type_info &) final;
61};
62
63RDataFrame MakeNTupleDataFrame(std::string_view ntupleName, std::string_view fileName);
64
65} // ns Experimental
66} // ns ROOT
67
68#endif
unsigned long long ULong64_t
Definition: RtypesCore.h:70
char name[80]
Definition: TGX11.cxx:109
const std::vector< std::string > & GetColumnNames() const final
Returns a reference to the collection of the dataset's column names.
Definition: RNTupleDS.cxx:42
void SetNSlots(unsigned int nSlots) final
Inform RDataSource of the number of processing slots (i.e.
Definition: RNTupleDS.cxx:112
bool SetEntry(unsigned int slot, ULong64_t entry) final
Advance the "cursors" returned by GetColumnReaders to the selected entry for a particular slot.
Definition: RNTupleDS.cxx:62
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:48
std::vector< std::unique_ptr< ROOT::Experimental::RNTupleReader > > fReaders
Clones of the first reader, one for each slot.
Definition: RNTupleDS.hxx:37
std::vector< std::string > fColumnNames
Definition: RNTupleDS.hxx:43
std::string GetTypeName(std::string_view colName) const final
Type of a column as a string, e.g.
Definition: RNTupleDS.cxx:91
std::vector< std::pair< ULong64_t, ULong64_t > > GetEntryRanges() final
Return ranges of entries to distribute to tasks.
Definition: RNTupleDS.cxx:68
RNTupleDS(std::unique_ptr< ROOT::Experimental::RNTupleReader > ntuple)
Definition: RNTupleDS.cxx:30
bool HasColumn(std::string_view colName) const final
Checks if the dataset has a certain column.
Definition: RNTupleDS.cxx:99
std::vector< std::string > fColumnTypes
Definition: RNTupleDS.hxx:44
std::vector< std::unique_ptr< ROOT::Experimental::REntry > > fEntries
Definition: RNTupleDS.hxx:38
void Initialise() final
Convenience method called before starting an event-loop.
Definition: RNTupleDS.cxx:106
std::vector< std::vector< void * > > fValuePtrs
The raw pointers wrapped by the RValue items of fEntries.
Definition: RNTupleDS.hxx:40
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,...
Definition: RDataFrame.hxx:42
RDataFrame MakeNTupleDataFrame(std::string_view ntupleName, std::string_view fileName)
Definition: RNTupleDS.cxx:133
VSD Structures.
Definition: StringConv.hxx:21