Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RTrivialDS.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_RTRIVIALTDS
12#define ROOT_RTRIVIALTDS
13
15#include "ROOT/RDataSource.hxx"
16
17namespace ROOT {
18
19namespace RDF {
20
21/// \brief A simple data-source implementation, for demo purposes.
22///
23/// Constructing an RDataFrame as `RDataFrame(nEntries)` is a superior alternative.
24class RTrivialDS final : public ROOT::RDF::RDataSource {
25private:
26 unsigned int fNSlots = 0U;
28 bool fSkipEvenEntries = false;
29 std::vector<std::pair<ULong64_t, ULong64_t>> fEntryRanges;
30 std::vector<std::string> fColNames{"col0"};
31 std::vector<ULong64_t> fCounter;
32 std::vector<ULong64_t *> fCounterAddr;
33 std::vector<void *> GetColumnReadersImpl(std::string_view name, const std::type_info &);
34
35protected:
36 std::string AsString() { return "trivial data source"; };
37
38public:
39 RTrivialDS(ULong64_t size, bool skipEvenEntries = false);
40 /// This ctor produces a data-source that returns infinite entries
41 RTrivialDS();
43 const std::vector<std::string> &GetColumnNames() const;
44 bool HasColumn(std::string_view colName) const;
45 std::string GetTypeName(std::string_view) const;
46 std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges();
47 bool SetEntry(unsigned int slot, ULong64_t entry);
48 void SetNSlots(unsigned int nSlots);
49 void Initialise();
50 std::string GetLabel();
51};
52
53/// \brief Make a RDF wrapping a RTrivialDS with the specified amount of entries.
54///
55/// Constructing an RDataFrame as `RDataFrame(nEntries)` is a superior alternative.
56RInterface<RDFDetail::RLoopManager> MakeTrivialDataFrame(ULong64_t size, bool skipEvenEntries = false);
57/// \brief Make a RDF wrapping a RTrivialDS with infinite entries, for demo purposes.
58RInterface<RDFDetail::RLoopManager> MakeTrivialDataFrame();
59
60} // ns RDF
61
62} // ns ROOT
63
64#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned long long ULong64_t
Definition RtypesCore.h:81
char name[80]
Definition TGX11.cxx:110
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
A simple data-source implementation, for demo purposes.
std::string GetLabel()
Return a string representation of the datasource type.
std::vector< std::pair< ULong64_t, ULong64_t > > GetEntryRanges()
Return ranges of entries to distribute to tasks.
void Initialise()
Convenience method called before starting an event-loop.
std::vector< void * > GetColumnReadersImpl(std::string_view name, const std::type_info &)
type-erased vector of pointers to pointers to column values - one per slot
bool SetEntry(unsigned int slot, ULong64_t entry)
Advance the "cursors" returned by GetColumnReaders to the selected entry for a particular slot.
std::vector< std::pair< ULong64_t, ULong64_t > > fEntryRanges
bool HasColumn(std::string_view colName) const
Checks if the dataset has a certain column.
std::vector< ULong64_t * > fCounterAddr
std::vector< ULong64_t > fCounter
std::vector< std::string > fColNames
RTrivialDS()
This ctor produces a data-source that returns infinite entries.
const std::vector< std::string > & GetColumnNames() const
Returns a reference to the collection of the dataset's column names.
void SetNSlots(unsigned int nSlots)
Inform RDataSource of the number of processing slots (i.e.
std::string GetTypeName(std::string_view) const
Type of a column as a string, e.g.
std::string AsString()
RInterface< RDFDetail::RLoopManager > MakeTrivialDataFrame()
Make a RDF wrapping a RTrivialDS with infinite entries, for demo purposes.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...