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.
24/// If size is std::numeric_limits<ULong64_t>::max(), this acts as an infinite data-source:
25/// it returns entries from GetEntryRanges forever or until a Range stops the event loop (for test purposes).
26class RTrivialDS final : public ROOT::RDF::RDataSource {
27private:
28 unsigned int fNSlots = 0U;
30 bool fSkipEvenEntries = false;
31 std::vector<std::pair<ULong64_t, ULong64_t>> fEntryRanges;
32 std::vector<std::string> fColNames{"col0"};
33 std::vector<ULong64_t> fCounter;
34 std::vector<ULong64_t *> fCounterAddr;
35 std::vector<void *> GetColumnReadersImpl(std::string_view name, const std::type_info &) final;
36
37protected:
38 std::string AsString() final { return "trivial data source"; };
39
40public:
41 RTrivialDS(ULong64_t size, bool skipEvenEntries = false);
42 /// This ctor produces a data-source that returns infinite entries
43 RTrivialDS();
45 const std::vector<std::string> &GetColumnNames() const final;
46 bool HasColumn(std::string_view colName) const final;
47 std::string GetTypeName(std::string_view) const final;
48 std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges() final;
49 bool SetEntry(unsigned int slot, ULong64_t entry) final;
50 void SetNSlots(unsigned int nSlots) final;
51 void Initialize() final;
52 std::string GetLabel() final;
53};
54
55/// \brief Make a RDF wrapping a RTrivialDS with the specified amount of entries.
56///
57/// Constructing an RDataFrame as `RDataFrame(nEntries)` is a superior alternative.
58/// If size is std::numeric_limits<ULong64_t>::max(), this acts as an infinite data-source:
59/// it returns entries from GetEntryRanges forever or until a Range stops the event loop (for test purposes).
60RInterface<RDFDetail::RLoopManager> MakeTrivialDataFrame(ULong64_t size, bool skipEvenEntries = false);
61/// \brief Make a RDF wrapping a RTrivialDS with infinite entries, for demo purposes.
63
64} // ns RDF
65
66} // ns ROOT
67
68#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.
The public interface to the RDataFrame federation of classes.
A simple data-source implementation, for demo purposes.
std::string GetTypeName(std::string_view) const final
Type of a column as a string, e.g.
bool HasColumn(std::string_view colName) const final
Checks if the dataset has a certain column.
void SetNSlots(unsigned int nSlots) final
Inform RDataSource of the number of processing slots (i.e.
std::vector< std::pair< ULong64_t, ULong64_t > > fEntryRanges
std::string GetLabel() final
Return a string representation of the datasource type.
std::vector< ULong64_t * > fCounterAddr
std::vector< void * > GetColumnReadersImpl(std::string_view name, const std::type_info &) final
type-erased vector of pointers to pointers to column values - one per slot
std::vector< ULong64_t > fCounter
std::vector< std::string > fColNames
bool SetEntry(unsigned int slot, ULong64_t entry) final
Advance the "cursors" returned by GetColumnReaders to the selected entry for a particular slot.
std::string AsString() final
RTrivialDS()
This ctor produces a data-source that returns infinite entries.
std::vector< std::pair< ULong64_t, ULong64_t > > GetEntryRanges() final
Return ranges of entries to distribute to tasks.
const std::vector< std::string > & GetColumnNames() const final
Returns a reference to the collection of the dataset's column names.
void Initialize() final
Convenience method called before starting an event-loop.
RInterface< RDFDetail::RLoopManager > MakeTrivialDataFrame()
Make a RDF wrapping a RTrivialDS with infinite entries, for demo purposes.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.