Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[TDF] Add the GetColumnNames method to the TInterface
to give the possibility to the user to get the column names from the
TDataFrame nodes.
  • Loading branch information
dpiparo committed Sep 29, 2017
commit af8fde060ddb4c0ae3dfb9b4a5e8943ac8027d7c
30 changes: 30 additions & 0 deletions tree/treeplayer/inc/ROOT/TDFInterface.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,36 @@ public:
fProxiedPtr->Report();
}

/////////////////////////////////////////////////////////////////////////////
/// \brief Returns the names of the available columns
///
/// This is not an action nor a transformation, just a simple utility to
/// get columns names out of the TDataFrame nodes.
ColumnNames_t GetColumnNames()
{
ColumnNames_t allColumns;

auto addIfNotInternal = [&allColumns](std::string_view colName){ if (!TDFInternal::IsInternalColumn(colName)) allColumns.emplace_back(colName);};

std::for_each(fValidCustomColumns.begin(), fValidCustomColumns.end(), addIfNotInternal);

auto df = GetDataFrameChecked();
auto tree = df->GetTree();
if (tree) {
const auto branches = tree->GetListOfBranches();
for (auto branch : *branches) {
allColumns.emplace_back(branch->GetName());
}
}

if (fDataSource) {
auto &dsColNames = fDataSource->GetColumnNames();
allColumns.insert(allColumns.end(), dsColNames.begin(), dsColNames.end());
}

return allColumns;
}

private:
ColumnNames_t ConvertRegexToColumns(std::string_view columnNameRegexp)
{
Expand Down