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).
27private:
29 bool fSkipEvenEntries = false;
30 std::vector<std::pair<ULong64_t, ULong64_t>> fEntryRanges;
31 std::vector<std::string> fColNames{"col0"};
32 std::vector<ULong64_t> fCounter;
33 std::vector<ULong64_t *> fCounterAddr;
34 std::vector<void *> GetColumnReadersImpl(std::string_view name, const std::type_info &) final;
35
36protected:
37 std::string AsString() final { return "trivial data source"; };
38
39public:
41 /// This ctor produces a data-source that returns infinite entries
42 RTrivialDS();
43 // Rule of five
44 RTrivialDS(const RTrivialDS &) = delete;
45 RTrivialDS &operator=(const RTrivialDS &) = delete;
46 RTrivialDS(RTrivialDS &&) = delete;
49
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) const final;
53 std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges() final;
54 bool SetEntry(unsigned int slot, ULong64_t entry) final;
55 void SetNSlots(unsigned int nSlots) final;
56 void Initialize() final;
57 std::string GetLabel() final;
58};
59
60/// \brief Make a RDF wrapping a RTrivialDS with the specified amount of entries.
61///
62/// Constructing an RDataFrame as `RDataFrame(nEntries)` is a superior alternative.
63/// If size is std::numeric_limits<ULong64_t>::max(), this acts as an infinite data-source:
64/// it returns entries from GetEntryRanges forever or until a Range stops the event loop (for test purposes).
66/// \brief Make a RDF wrapping a RTrivialDS with infinite entries, for demo purposes.
68
69} // ns RDF
70
71} // ns ROOT
72
73#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned long long ULong64_t
Definition RtypesCore.h:70
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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.
~RTrivialDS() final=default
RTrivialDS & operator=(const RTrivialDS &)=delete
RTrivialDS & operator=(RTrivialDS &&)=delete
std::vector< std::pair< ULong64_t, ULong64_t > > fEntryRanges
std::string GetLabel() final
Return a string representation of the datasource type.
RTrivialDS(RTrivialDS &&)=delete
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.
RTrivialDS(const RTrivialDS &)=delete
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.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...