Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RNTupleDS.hxx
Go to the documentation of this file.
1 /// \file RNTupleDS.hxx
2 /// \ingroup NTuple ROOT7
3 /// \author Jakob Blomer <jblomer@cern.ch>
4 /// \date 2018-10-04
5 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6 /// is welcome!
7 
8 /*************************************************************************
9  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
10  * All rights reserved. *
11  * *
12  * For the licensing terms see $ROOTSYS/LICENSE. *
13  * For the list of contributors see $ROOTSYS/README/CREDITS. *
14  *************************************************************************/
15 
16 #ifndef ROOT_RNTupleDS
17 #define ROOT_RNTupleDS
18 
19 #include <ROOT/RDataFrame.hxx>
20 #include <ROOT/RDataSource.hxx>
21 #include <ROOT/RStringView.hxx>
22 
23 #include <cstdint>
24 #include <memory>
25 #include <string>
26 #include <vector>
27 
28 namespace ROOT {
29 namespace Experimental {
30 
31 class RNTupleReader;
32 class REntry;
33 
34 
35 class RNTupleDS final : public ROOT::RDF::RDataSource {
36  /// Clones of the first reader, one for each slot
37  std::vector<std::unique_ptr<ROOT::Experimental::RNTupleReader>> fReaders;
38  std::vector<std::unique_ptr<ROOT::Experimental::REntry>> fEntries;
39  /// The raw pointers wrapped by the RValue items of fEntries
40  std::vector<std::vector<void*>> fValuePtrs;
41  unsigned fNSlots = 0;
42  bool fHasSeenAllRanges = false;
43  std::vector<std::string> fColumnNames;
44  std::vector<std::string> fColumnTypes;
45 
46 public:
47  explicit RNTupleDS(std::unique_ptr<ROOT::Experimental::RNTupleReader> ntuple);
48  ~RNTupleDS() = default;
49  void SetNSlots(unsigned int nSlots) final;
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 colName) const final;
53  std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges() final;
54 
55  bool SetEntry(unsigned int slot, ULong64_t entry) final;
56 
57  void Initialise() final;
58 
59 protected:
60  Record_t GetColumnReadersImpl(std::string_view name, const std::type_info &) final;
61 };
62 
63 RDataFrame MakeNTupleDataFrame(std::string_view ntupleName, std::string_view fileName);
64 
65 } // ns Experimental
66 } // ns ROOT
67 
68 #endif