Logo ROOT  
Reference Guide
RArrowDS.hxx
Go to the documentation of this file.
1 #ifndef ROOT_RARROWTDS
2 #define ROOT_RARROWTDS
3 
4 #include "ROOT/RDataFrame.hxx"
5 #include "ROOT/RDataSource.hxx"
6 
7 #include <memory>
8 
9 namespace arrow {
10 class Table;
11 }
12 
13 namespace ROOT {
14 namespace Internal {
15 namespace RDF {
16 class TValueGetter;
17 } // namespace RDF
18 } // namespace Internal
19 
20 namespace RDF {
21 
22 class RArrowDS final : public RDataSource {
23 private:
24  std::shared_ptr<arrow::Table> fTable;
25  std::vector<std::pair<ULong64_t, ULong64_t>> fEntryRanges;
26  std::vector<std::string> fColumnNames;
27  size_t fNSlots = 0U;
28 
29  std::vector<std::pair<size_t, size_t>> fGetterIndex; // (columnId, visitorId)
30  std::vector<std::unique_ptr<ROOT::Internal::RDF::TValueGetter>> fValueGetters; // Visitors to be used to track and get entries. One per column.
31  std::vector<void *> GetColumnReadersImpl(std::string_view name, const std::type_info &type) override;
32 
33 public:
34  RArrowDS(std::shared_ptr<arrow::Table> table, std::vector<std::string> const &columns);
35  ~RArrowDS();
36  const std::vector<std::string> &GetColumnNames() const override;
37  std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges() override;
38  std::string GetTypeName(std::string_view colName) const override;
39  bool HasColumn(std::string_view colName) const override;
40  bool SetEntry(unsigned int slot, ULong64_t entry) override;
41  void InitSlot(unsigned int slot, ULong64_t firstEntry) override;
42  void SetNSlots(unsigned int nSlots) override;
43  void Initialise() override;
44  std::string GetLabel() override;
45 };
46 
47 ////////////////////////////////////////////////////////////////////////////////////////////////
48 /// \brief Factory method to create a Apache Arrow RDataFrame.
49 /// \param[in] table an apache::arrow table to use as a source.
50 RDataFrame MakeArrowDataFrame(std::shared_ptr<arrow::Table> table, std::vector<std::string> const &columns);
51 
52 } // namespace RDF
53 
54 } // namespace ROOT
55 
56 #endif
ROOT::RDF::RArrowDS::fColumnNames
std::vector< std::string > fColumnNames
Definition: RArrowDS.hxx:26
ROOT::RDF::RArrowDS::HasColumn
bool HasColumn(std::string_view colName) const override
Checks if the dataset has a certain column.
Definition: RArrowDS.cxx:493
ROOT::RDF::RArrowDS
RDataFrame data source class to interface with Apache Arrow.
Definition: RArrowDS.hxx:22
string_view
basic_string_view< char > string_view
Definition: libcpp_string_view.h:785
ROOT::RDF::RArrowDS::GetColumnReadersImpl
std::vector< void * > GetColumnReadersImpl(std::string_view name, const std::type_info &type) override
This needs to return a pointer to the pointer each value getter will point to.
Definition: RArrowDS.cxx:570
ROOT::RDataFrame
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
Definition: RDataFrame.hxx:42
ROOT::RDF::RDataSource
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
Definition: RDataSource.hxx:105
ROOT::RDF::RArrowDS::GetTypeName
std::string GetTypeName(std::string_view colName) const override
Type of a column as a string, e.g.
Definition: RArrowDS.cxx:475
RDataFrame.hxx
ROOT::RDF::RArrowDS::RArrowDS
RArrowDS(std::shared_ptr< arrow::Table > table, std::vector< std::string > const &columns)
Constructor to create an Arrow RDataSource for RDataFrame.
Definition: RArrowDS.cxx:388
RDataSource.hxx
ROOT::RDF::MakeArrowDataFrame
RDataFrame MakeArrowDataFrame(std::shared_ptr< arrow::Table > table, std::vector< std::string > const &columns)
Factory method to create a Apache Arrow RDataFrame.
Definition: RArrowDS.cxx:604
ROOT::RDF::RArrowDS::SetEntry
bool SetEntry(unsigned int slot, ULong64_t entry) override
Advance the "cursors" returned by GetColumnReaders to the selected entry for a particular slot.
Definition: RArrowDS.cxx:502
ROOT::RDF::RArrowDS::InitSlot
void InitSlot(unsigned int slot, ULong64_t firstEntry) override
Convenience method called at the start of the data processing associated to a slot.
Definition: RArrowDS.cxx:511
ROOT::RDF::RArrowDS::fEntryRanges
std::vector< std::pair< ULong64_t, ULong64_t > > fEntryRanges
Definition: RArrowDS.hxx:25
ROOT::RDF::RArrowDS::fValueGetters
std::vector< std::unique_ptr< ROOT::Internal::RDF::TValueGetter > > fValueGetters
Definition: RArrowDS.hxx:30
ROOT::RDF::RArrowDS::fNSlots
size_t fNSlots
Definition: RArrowDS.hxx:27
ROOT::RDF::RArrowDS::GetLabel
std::string GetLabel() override
Return a string representation of the datasource type.
Definition: RArrowDS.cxx:595
ROOT::RDF::RArrowDS::Initialise
void Initialise() override
Convenience method called before starting an event-loop.
Definition: RArrowDS.cxx:589
ULong64_t
unsigned long long ULong64_t
Definition: RtypesCore.h:74
ROOT::RDF::RArrowDS::~RArrowDS
~RArrowDS()
Destructor.
Definition: RArrowDS.cxx:460
ROOT::RDF::RArrowDS::GetColumnNames
const std::vector< std::string > & GetColumnNames() const override
Returns a reference to the collection of the dataset's column names.
Definition: RArrowDS.cxx:464
arrow
Definition: RArrowDS.hxx:9
name
char name[80]
Definition: TGX11.cxx:110
ROOT::RDF::RArrowDS::GetEntryRanges
std::vector< std::pair< ULong64_t, ULong64_t > > GetEntryRanges() override
Return ranges of entries to distribute to tasks.
Definition: RArrowDS.cxx:469
ROOT::RDF::RArrowDS::SetNSlots
void SetNSlots(unsigned int nSlots) override
Inform RDataSource of the number of processing slots (i.e.
Definition: RArrowDS.cxx:554
type
int type
Definition: TGX11.cxx:121
ROOT::RDF::RArrowDS::fTable
std::shared_ptr< arrow::Table > fTable
Definition: RArrowDS.hxx:24
ROOT::RDF::RArrowDS::fGetterIndex
std::vector< std::pair< size_t, size_t > > fGetterIndex
Definition: RArrowDS.hxx:29
ROOT
VSD Structures.
Definition: StringConv.hxx:21