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_RTRIVIALDS
12#define ROOT_RTRIVIALDS
13
15#include "ROOT/RDataSource.hxx"
16
17namespace ROOT::Internal::RDF {
25} // namespace ROOT::Internal::RDF
26
27namespace ROOT {
28
29namespace RDF {
30
31/// \brief A simple data-source implementation, for demo purposes.
32///
33/// Constructing an RDataFrame as `RDataFrame(nEntries)` is a superior alternative.
34/// If size is std::numeric_limits<ULong64_t>::max(), this acts as an infinite data-source:
35/// it returns entries from GetEntryRanges forever or until a Range stops the event loop (for test purposes).
37private:
39 bool fSkipEvenEntries = false;
40 std::vector<std::pair<ULong64_t, ULong64_t>> fEntryRanges;
41 std::vector<std::string> fColNames{"col0"};
42 std::vector<ULong64_t> fCounter;
43 std::vector<ULong64_t *> fCounterAddr;
44 std::vector<void *> GetColumnReadersImpl(std::string_view name, const std::type_info &) final;
45
46protected:
47 std::string AsString() final { return "trivial data source"; };
48
49public:
51 /// This ctor produces a data-source that returns infinite entries
52 RTrivialDS();
53 // Rule of five
54 RTrivialDS(const RTrivialDS &) = delete;
55 RTrivialDS &operator=(const RTrivialDS &) = delete;
56 RTrivialDS(RTrivialDS &&) = delete;
59
60 const std::vector<std::string> &GetColumnNames() const final;
61 bool HasColumn(std::string_view colName) const final;
62 std::string GetTypeName(std::string_view) const final;
63 std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges() final;
64 bool SetEntry(unsigned int slot, ULong64_t entry) final;
65 void SetNSlots(unsigned int nSlots) final;
66 void Initialize() final;
67 std::string GetLabel() final;
68
69 std::unique_ptr<ROOT::Detail::RDF::RColumnReaderBase>
70 GetColumnReaders(unsigned int slot, std::string_view colName, const std::type_info &tid) final;
71};
72
73/// \brief Make a RDF wrapping a RTrivialDS with the specified amount of entries.
74///
75/// Constructing an RDataFrame as `RDataFrame(nEntries)` is a superior alternative.
76/// If size is std::numeric_limits<ULong64_t>::max(), this acts as an infinite data-source:
77/// it returns entries from GetEntryRanges forever or until a Range stops the event loop (for test purposes).
78RInterface<RDFDetail::RLoopManager> MakeTrivialDataFrame(ULong64_t size, bool skipEvenEntries = false);
79/// \brief Make a RDF wrapping a RTrivialDS with infinite entries, for demo purposes.
80RInterface<RDFDetail::RLoopManager> MakeTrivialDataFrame();
81
82} // ns RDF
83
84} // ns ROOT
85
86#endif
dim_t fSize
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
Definition RtypesCore.h:84
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
Pure virtual base class for all column reader types.
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.
~RTrivialDS() final=default
RTrivialDS & operator=(const RTrivialDS &)=delete
RTrivialDS & operator=(RTrivialDS &&)=delete
std::vector< std::pair< ULong64_t, ULong64_t > > fEntryRanges
RTrivialDS(RTrivialDS &&)=delete
std::vector< ULong64_t * > fCounterAddr
std::vector< ULong64_t > fCounter
std::string AsString() final
RTrivialDS(const RTrivialDS &)=delete
Namespace for new ROOT classes and functions.