Skip to content

Commit 610001f

Browse files
committed
[df] Provide default implementation of virtual method
The SetNSlots method can now have a default implementation since the recent upstream of the fNSlots data member to the base class RDataSource.
1 parent 369a183 commit 610001f

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

tree/dataframe/inc/ROOT/RDataSource.hxx

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "TString.h"
1818

1919
#include <algorithm> // std::transform
20+
#include <cassert>
2021
#include <string>
2122
#include <typeinfo>
2223
#include <vector>
@@ -130,7 +131,12 @@ public:
130131
/// Slots numbers are used to simplify parallel execution: RDataFrame guarantees that different threads will always
131132
/// pass different slot values when calling methods concurrently.
132133
// clang-format on
133-
virtual void SetNSlots(unsigned int nSlots) = 0;
134+
virtual void SetNSlots(unsigned int nSlots)
135+
{
136+
assert(fNSlots == 0);
137+
assert(nSlots > 0);
138+
fNSlots = nSlots;
139+
};
134140

135141
/// \brief Returns the number of files from which the dataset is constructed
136142
virtual std::size_t GetNFiles() const { return 0; }

tree/dataframe/inc/ROOT/RVecDS.hxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public:
173173
return true;
174174
}
175175

176-
void SetNSlots(unsigned int nSlots)
176+
void SetNSlots(unsigned int nSlots) final
177177
{
178178
fNSlots = nSlots;
179179
const auto nCols = fColNames.size();

tree/dataframe/test/RArraysDS.hxx

-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ public:
4848
RArraysDS &operator=(RArraysDS &&) = delete;
4949
~RArraysDS() final = default;
5050

51-
void SetNSlots(unsigned int) final { }
52-
5351
const std::vector<std::string> &GetColumnNames() const final { return fColumnNames; }
5452

5553
bool HasColumn(std::string_view name) const final

tree/dataframe/test/RNonCopiableColumnDS.hxx

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ public:
4545
auto entryRanges(std::move(fEntryRanges)); // empty fEntryRanges
4646
return entryRanges;
4747
};
48-
bool SetEntry(unsigned int, ULong64_t) final { return true;};
49-
void SetNSlots(unsigned int) final {};
48+
bool SetEntry(unsigned int, ULong64_t) final { return true; };
5049
std::string GetLabel() final {
5150
return "NonCopiableColumnDS";
5251
}

tree/dataframe/test/RStreamingDS.hxx

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public:
2222
RStreamingDS &operator=(RStreamingDS &&) = delete;
2323
~RStreamingDS() final = default;
2424

25-
void SetNSlots(unsigned int nSlots) final { fNSlots = nSlots; }
2625
const std::vector<std::string> &GetColumnNames() const final { return fColumnNames; }
2726
bool HasColumn(std::string_view name) const final { return std::string(name) == "ans" ? true : false; }
2827
std::string GetTypeName(std::string_view) const final { return "int"; }

0 commit comments

Comments
 (0)