Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RRootDS.hxx
Go to the documentation of this file.
1// Author: Enrico Guiraud, Danilo Piparo CERN 9/2017
2
3/*************************************************************************
4 * Copyright (C) 1995-2018, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef ROOT_RROOTTDS
12#define ROOT_RROOTTDS
13
14#include "ROOT/RDataFrame.hxx"
15#include "ROOT/RDataSource.hxx"
16#include <TChain.h>
17
18#include <memory>
19
20namespace ROOT {
21
22namespace Internal {
23
24namespace RDF {
25
26/// This class is unused and it has only been implemented as a proof of concept.
27/// It shows how to implement the RDataSource API for a complex kind of source such as TTrees.
28class RRootDS final : public ROOT::RDF::RDataSource {
29private:
30 unsigned int fNSlots = 0U;
31 std::string fTreeName;
32 std::string fFileNameGlob;
33 mutable TChain fModelChain; // Mutable needed for getting the column type name
34 std::vector<double *> fAddressesToFree;
35 std::vector<std::string> fListOfBranches;
36 std::vector<std::pair<ULong64_t, ULong64_t>> fEntryRanges;
37 std::vector<std::vector<void *>> fBranchAddresses; // first container-> slot, second -> column;
38 std::vector<std::unique_ptr<TChain>> fChains;
39
40 std::vector<void *> GetColumnReadersImpl(std::string_view, const std::type_info &) final;
41
42protected:
43 std::string AsString() final { return "ROOT data source"; };
44
45public:
46 RRootDS(std::string_view treeName, std::string_view fileNameGlob);
47 ~RRootDS();
48 std::size_t GetNFiles() const final;
49 std::string GetTypeName(std::string_view colName) const final;
50 const std::vector<std::string> &GetColumnNames() const final;
51 bool HasColumn(std::string_view colName) const final;
52 void InitSlot(unsigned int slot, ULong64_t firstEntry) final;
53 void FinalizeSlot(unsigned int slot) final;
54 std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges() final;
55 bool SetEntry(unsigned int slot, ULong64_t entry) final;
56 void SetNSlots(unsigned int nSlots) final;
57 void Initialize() final;
58 std::string GetLabel() final;
59};
60
61} // ns RDF
62
63} // ns Internal
64
65} // ns ROOT
66
67#endif
unsigned long long ULong64_t
Definition RtypesCore.h:81
This class is unused and it has only been implemented as a proof of concept.
Definition RRootDS.hxx:28
std::string AsString() final
Definition RRootDS.hxx:43
bool SetEntry(unsigned int slot, ULong64_t entry) final
Advance the "cursors" returned by GetColumnReaders to the selected entry for a particular slot.
Definition RRootDS.cxx:134
void SetNSlots(unsigned int nSlots) final
Inform RDataSource of the number of processing slots (i.e.
Definition RRootDS.cxx:140
const std::vector< std::string > & GetColumnNames() const final
Returns a reference to the collection of the dataset's column names.
Definition RRootDS.cxx:87
void FinalizeSlot(unsigned int slot) final
Convenience method called at the end of the data processing associated to a slot.
Definition RRootDS.cxx:123
std::vector< std::pair< ULong64_t, ULong64_t > > GetEntryRanges() final
Return ranges of entries to distribute to tasks.
Definition RRootDS.cxx:128
std::string GetTypeName(std::string_view colName) const final
Type of a column as a string, e.g.
Definition RRootDS.cxx:71
std::vector< std::vector< void * > > fBranchAddresses
Definition RRootDS.hxx:37
std::vector< void * > GetColumnReadersImpl(std::string_view, const std::type_info &) final
type-erased vector of pointers to pointers to column values - one per slot
Definition RRootDS.cxx:23
std::vector< std::unique_ptr< TChain > > fChains
Definition RRootDS.hxx:38
bool HasColumn(std::string_view colName) const final
Checks if the dataset has a certain column.
Definition RRootDS.cxx:92
void InitSlot(unsigned int slot, ULong64_t firstEntry) final
Convenience method called at the start of the data processing associated to a slot.
Definition RRootDS.cxx:99
std::vector< std::string > fListOfBranches
Definition RRootDS.hxx:35
void Initialize() final
Convenience method called before starting an event-loop.
Definition RRootDS.cxx:153
std::vector< double * > fAddressesToFree
Definition RRootDS.hxx:34
std::string GetLabel() final
Return a string representation of the datasource type.
Definition RRootDS.cxx:169
std::size_t GetNFiles() const final
Returns the number of files from which the dataset is constructed.
Definition RRootDS.cxx:64
std::vector< std::pair< ULong64_t, ULong64_t > > fEntryRanges
Definition RRootDS.hxx:36
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
A chain is a collection of files containing TTree objects.
Definition TChain.h:33
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...