Logo ROOT   6.18/05
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 std::unique_ptr<ROOT::Experimental::RNTupleReader> fNTuple;
37 std::unique_ptr<ROOT::Experimental::REntry> fEntry;
38 unsigned fNSlots;
40 std::vector<std::string> fColumnNames;
41 std::vector<std::string> fColumnTypes;
42 std::vector<void*> fValuePtrs;
43
44public:
45 RNTupleDS(std::unique_ptr<ROOT::Experimental::RNTupleReader> ntuple);
46 ~RNTupleDS();
47 void SetNSlots(unsigned int nSlots) final;
48 const std::vector<std::string> &GetColumnNames() const final;
49 bool HasColumn(std::string_view colName) const final;
50 std::string GetTypeName(std::string_view colName) const final;
51 std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges() final;
52
53 bool SetEntry(unsigned int slot, ULong64_t entry) final;
54
55 void Initialise() final;
56
57protected:
58 Record_t GetColumnReadersImpl(std::string_view name, const std::type_info &) final;
59};
60
61RDataFrame MakeNTupleDataFrame(std::string_view ntupleName, std::string_view fileName);
62
63} // ns Experimental
64} // ns ROOT
65
66#endif
unsigned long long ULong64_t
Definition: RtypesCore.h:70
char name[80]
Definition: TGX11.cxx:109
std::unique_ptr< ROOT::Experimental::REntry > fEntry
Definition: RNTupleDS.hxx:37
const std::vector< std::string > & GetColumnNames() const final
Returns a reference to the collection of the dataset's column names.
Definition: RNTupleDS.cxx:49
void SetNSlots(unsigned int nSlots) final
Inform RDataSource of the number of processing slots (i.e.
Definition: RNTupleDS.cxx:117
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:69
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:55
std::unique_ptr< ROOT::Experimental::RNTupleReader > fNTuple
Definition: RNTupleDS.hxx:36
std::vector< std::string > fColumnNames
Definition: RNTupleDS.hxx:40
std::string GetTypeName(std::string_view colName) const final
Type of a column as a string, e.g.
Definition: RNTupleDS.cxx:96
std::vector< std::pair< ULong64_t, ULong64_t > > GetEntryRanges() final
Return ranges of entries to distribute to tasks.
Definition: RNTupleDS.cxx:74
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:104
std::vector< std::string > fColumnTypes
Definition: RNTupleDS.hxx:41
std::vector< void * > fValuePtrs
Definition: RNTupleDS.hxx:42
void Initialise() final
Convenience method called before starting an event-loop.
Definition: RNTupleDS.cxx:111
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:123
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21