Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RDFInterfaceUtils.cxx
Go to the documentation of this file.
1// Author: Enrico Guiraud, Danilo Piparo CERN 02/2018
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#include <ROOT/RDataSource.hxx>
12#include <ROOT/RTTreeDS.hxx>
15#include <ROOT/RDF/RDisplay.hxx>
20#include "ROOT/RLogger.hxx"
22#include <ROOT/RDF/Utils.hxx>
23#include <string_view>
24#include <TBranch.h>
25#include <TClass.h>
26#include <TClassEdit.h>
27#include <TDataType.h>
28#include <TError.h>
29#include <TLeaf.h>
30#include <TObjArray.h>
31#include <TPRegexp.h>
32#include <TROOT.h>
33#include <TString.h>
34#include <TTree.h>
35#include <TVirtualMutex.h>
36
37// pragma to disable warnings on Rcpp which have
38// so many noise compiling
39#if defined(__GNUC__)
40#pragma GCC diagnostic push
41#pragma GCC diagnostic ignored "-Woverloaded-virtual"
42#pragma GCC diagnostic ignored "-Wshadow"
43#endif
44#include "lexertk.hpp"
45#if defined(__GNUC__)
46#pragma GCC diagnostic pop
47#endif
48
49#include <algorithm>
50#include <cassert>
51#include <cstdlib> // for size_t
52#include <iterator> // for back_insert_iterator
53#include <map>
54#include <memory>
55#include <set>
56#include <sstream>
57#include <stdexcept>
58#include <string>
59#include <typeinfo>
60#include <unordered_map>
61#include <unordered_set>
62#include <utility> // for pair
63#include <vector>
64
65namespace ROOT::Detail::RDF {
66class RDefineBase;
67}
68
69namespace {
72
73/// A string expression such as those passed to Filter and Define, digested to a standardized form
74struct ParsedExpression {
75 /// The string expression with the dummy variable names in fVarNames in place of the original column names
76 std::string fExpr;
77 /// The list of valid column names that were used in the original string expression.
78 /// Duplicates are removed and column aliases (created with Alias calls) are resolved.
79 ColumnNames_t fUsedCols;
80 /// The list of variable names used in fExpr, with same ordering and size as fUsedCols
81 ColumnNames_t fVarNames;
82};
83
84/// Look at expression `expr` and return a pair of (column names used, aliases used)
85std::pair<ColumnNames_t, ColumnNames_t> FindUsedColsAndAliases(const std::string &expr,
87 const ColumnNames_t &dataSourceColNames)
88{
89 lexertk::generator tokens;
90 const auto tokensOk = tokens.process(expr);
91 if (!tokensOk) {
92 const auto msg = "Failed to tokenize expression:\n" + expr + "\n\nMake sure it is valid C++.";
93 throw std::runtime_error(msg);
94 }
95
96 std::unordered_set<std::string> usedCols;
97 std::unordered_set<std::string> usedAliases;
98
99 // iterate over tokens in expression and fill usedCols and usedAliases
100 const auto nTokens = tokens.size();
101 const auto kSymbol = lexertk::token::e_symbol;
102 for (auto i = 0u; i < nTokens; ++i) {
103 const auto &tok = tokens[i];
104 // lexertk classifies '&' as e_symbol for some reason
105 if (tok.type != kSymbol || tok.value == "&" || tok.value == "|") {
106 // token is not a potential variable name, skip it
107 continue;
108 }
109
110 ColumnNames_t potentialColNames({tok.value});
111
112 // if token is the start of a dot chain (a.b.c...), a.b, a.b.c etc. are also potential column names
113 auto dotChainKeepsGoing = [&](unsigned int _i) {
114 return _i + 2 <= nTokens && tokens[_i + 1].value == "." && tokens[_i + 2].type == kSymbol;
115 };
116 while (dotChainKeepsGoing(i)) {
117 potentialColNames.emplace_back(potentialColNames.back() + "." + tokens[i + 2].value);
118 i += 2; // consume the tokens we looked at
119 }
120
121 // in an expression such as `a.b`, if `a` is a column alias add it to `usedAliases` and
122 // replace the alias with the real column name in `potentialColNames`.
123 const auto maybeAnAlias = potentialColNames[0]; // intentionally a copy as we'll modify potentialColNames later
124 const auto &resolvedAlias = colRegister.ResolveAlias(maybeAnAlias);
125 if (resolvedAlias != maybeAnAlias) { // this is an alias
127 for (auto &s : potentialColNames)
128 s.replace(0, maybeAnAlias.size(), resolvedAlias);
129 }
130
131 // find the longest potential column name that is an actual column name
132 // (potential columns are sorted by length, so we search from the end to find the longest)
133 auto isRDFColumn = [&](const std::string &col) {
134 if (colRegister.IsDefineOrAlias(col) || IsStrInVec(col, dataSourceColNames))
135 return true;
136 return false;
137 };
138 const auto longestRDFColMatch = std::find_if(potentialColNames.crbegin(), potentialColNames.crend(), isRDFColumn);
141 }
142
143 return {{usedCols.begin(), usedCols.end()}, {usedAliases.begin(), usedAliases.end()}};
144}
145
146/// Substitute each '.' in a string with '\.'
147std::string EscapeDots(const std::string &s)
148{
149 TString out(s);
150 TPRegexp dot("\\.");
151 dot.Substitute(out, "\\.", "g");
152 return std::string(std::move(out));
153}
154
155TString ResolveAliases(const TString &expr, const ColumnNames_t &usedAliases,
157{
158 TString out(expr);
159
160 for (const auto &alias : usedAliases) {
161 const auto &col = colRegister.ResolveAlias(alias);
162 TPRegexp replacer("\\b" + EscapeDots(alias) + "\\b");
163 replacer.Substitute(out, col.data(), "g");
164 }
165
166 return out;
167}
168
169ParsedExpression ParseRDFExpression(std::string_view expr, const ROOT::Internal::RDF::RColumnRegister &colRegister,
170 const ColumnNames_t &dataSourceColNames)
171{
172 // transform `#var` into `R_rdf_sizeof_var`
174 // regex explanation:
175 // #
176 // - matches the literal character #
177 // (?!(ifdef|ifndef|if|else|elif|endif|pragma|define|undef|include|line))
178 // - negative lookahead (i.e. don't match these occurrences) to exclude preprocessor directives e.g. #ifdef
179 // ([a-zA-Z_][a-zA-Z0-9_]*)
180 // - match characters that make up the variable name after the #
181 // (?=(?:[^"]*"[^"]*")*[^"]*$)
182 // - positive lookahead (i.e. match these occurrences) checking that there is always an even number of quotes
183 // *after* the matched character sequence, using the non-capturing group (?:[^"]*"[^"]*"). We leverage the
184 // fact that for any character sequence to be within quotes there must be an odd number of quotes after the
185 // sequence and before the end of the line.
187 R"REGEX(#(?!(ifdef|ifndef|if|else|elif|endif|pragma|define|undef|include|line))([a-zA-Z_][a-zA-Z0-9_]*)(?=(?:[^"]*"[^"]*")*[^"]*$))REGEX");
188 colSizeReplacer.Substitute(preProcessedExpr, "R_rdf_sizeof_$2", "g");
189
190 ColumnNames_t usedCols;
191 ColumnNames_t usedAliases;
192 std::tie(usedCols, usedAliases) =
194
196
197 // when we are done, exprWithVars willl be the same as preProcessedExpr but column names will be substituted with
198 // the dummy variable names in varNames
200
201 ColumnNames_t varNames(usedCols.size());
202 for (auto i = 0u; i < varNames.size(); ++i)
203 varNames[i] = "var" + std::to_string(i);
204
205 // sort the vector usedColsAndAliases by decreasing length of its elements,
206 // so in case of friends we guarantee we never substitute a column name with another column containing it
207 // ex. without sorting when passing "x" and "fr.x", the replacer would output "var0" and "fr.var0",
208 // because it has already substituted "x", hence the "x" in "fr.x" would be recognized as "var0",
209 // whereas the desired behaviour is handling them as "var0" and "var1"
210 std::sort(usedCols.begin(), usedCols.end(),
211 [](const std::string &a, const std::string &b) { return a.size() > b.size(); });
212 for (const auto &col : usedCols) {
213 const auto varIdx = std::distance(usedCols.begin(), std::find(usedCols.begin(), usedCols.end(), col));
214 TPRegexp replacer("\\b" + EscapeDots(col) + "\\b");
215 replacer.Substitute(exprWithVars, varNames[varIdx], "g");
216 }
217
218 return ParsedExpression{std::string(std::move(exprWithVars)), std::move(usedCols), std::move(varNames)};
219}
220
221/// Return the static global map of Filter/Define functions that have been jitted.
222/// It's used to check whether a given expression has already been jitted, and
223/// to look up its associated variable name if it is.
224/// Keys in the map are the body of the expression, values are the name of the
225/// jitted variable that corresponds to that expression. For example, for:
226/// auto f1(){ return 42; }
227/// key would be "(){ return 42; }" and value would be "f1".
228std::unordered_map<std::string, std::string> &GetJittedExprs() {
229 static std::unordered_map<std::string, std::string> jittedExpressions;
230 return jittedExpressions;
231}
232
233std::string BuildFunctionString(const std::string &expr, const ColumnNames_t &vars, const ColumnNames_t &varTypes,
234 bool isSingleColumn = false, const std::string &varyColType = "")
235{
236 assert(vars.size() == varTypes.size());
237
238 TPRegexp re(R"(\breturn\b)");
239 const bool hasReturnStmt = re.MatchB(expr);
240
241 static const std::vector<std::string> fundamentalTypes = {
242 "int",
243 "signed",
244 "signed int",
245 "Int_t",
246 "unsigned",
247 "unsigned int",
248 "UInt_t",
249 "double",
250 "Double_t",
251 "float",
252 "Float_t",
253 "char",
254 "Char_t",
255 "unsigned char",
256 "UChar_t",
257 "bool",
258 "Bool_t",
259 "short",
260 "short int",
261 "Short_t",
262 "long",
263 "long int",
264 "long long int",
265 "Long64_t",
266 "unsigned long",
267 "unsigned long int",
268 "ULong64_t",
269 "std::size_t",
270 "size_t",
271 "Ssiz_t"
272 };
273
274 std::stringstream ss;
275 ss << "(";
276 for (auto i = 0u; i < vars.size(); ++i) {
277 std::string fullType;
278 const auto &type = varTypes[i];
280 // pass it by const value to help detect common mistakes such as if(x = 3)
281 fullType = "const " + type + " ";
282 } else {
283 // We pass by reference to avoid expensive copies
284 // It can't be const reference in general, as users might want/need to call non-const methods on the values
285 fullType = type + "& ";
286 }
287 ss << fullType << vars[i] << ", ";
288 }
289 if (!vars.empty())
290 ss.seekp(-2, ss.cur);
291
292 // When building the function expression for a Vary call, we try to help the
293 // user by removing the need to explicitly write the vector return type.
294 // For now, Vary works by returning a (nested) RVec, depending on how many
295 // variables need to vary in lockstep.
296 auto finalizeExprForVary = [&]() {
297 std::string trailRetType{};
298 // Trim formatting characters at the extremes of the user expression
299 auto first_not_space = expr.find_first_not_of(" \n\t");
300 auto last_not_space = expr.find_last_not_of(" \n\t");
301 if (first_not_space != std::string::npos && last_not_space != std::string::npos && expr[first_not_space] == '{' &&
302 expr[last_not_space] == '}') {
303 // User expression is of type '{...}', a potential constructor for an
304 // RVec. At the same time, they have not decided the RVec return type
305 // Add trailing return type for the convenience of the user
306 // The innermost value type is by default the type of the first given column
307 trailRetType = " -> ";
308 if (isSingleColumn)
309 trailRetType += "ROOT::RVec<" + varyColType + ">";
310 else
311 trailRetType += "ROOT::RVec<ROOT::RVec<" + varyColType + ">>";
312 trailRetType += ' ';
313 }
314 std::string trailRetToken{trailRetType.empty() ? ") {" : ')' + trailRetType + '{'};
315 if (!hasReturnStmt)
316 trailRetToken += " return ";
317 return trailRetToken;
318 };
319
320 if (!varyColType.empty())
322 else
323 ss << (hasReturnStmt ? ") {" : ") { return ");
324
325 // Must inject \n to avoid cases where the user puts a comment after the expression
326 ss << expr << "\n;}\n";
327
328 return ss.str();
329}
330
331/// Declare a function to the interpreter in namespace R_rdf, return the name of the jitted function.
332/// If the function is already in GetJittedExprs, return the name for the function that has already been jitted.
333std::string DeclareFunction(const std::string &expr, const ColumnNames_t &vars, const ColumnNames_t &varTypes,
334 bool isSingleColumn = false, const std::string &varyColType = "")
335{
337
339 auto &exprMap = GetJittedExprs();
340 const auto exprIt = exprMap.find(funcCode);
341 if (exprIt != exprMap.end()) {
342 // expression already there
343 const auto funcName = exprIt->second;
344 return funcName;
345 }
346
347 // new expression
348 const auto funcBaseName = "func" + std::to_string(exprMap.size());
349 const auto funcFullName = "R_rdf::" + funcBaseName;
350
351 const auto toDeclare = "namespace R_rdf {\nauto " + funcBaseName + funcCode + "\nusing " + funcBaseName +
352 "_ret_t = typename ROOT::TypeTraits::CallableTraits<decltype(" + funcBaseName +
353 ")>::ret_type;\n}";
355
356 // InterpreterDeclare could throw. If it doesn't, mark the function as already jitted
357 exprMap.insert({funcCode, funcFullName});
358
359 return funcFullName;
360}
361
362/// Each jitted function comes with a func_ret_t type alias for its return type.
363/// Resolve that alias and return the true type as string.
364std::string RetTypeOfFunc(const std::string &funcName)
365{
366 const auto dt = gROOT->GetType((funcName + "_ret_t").c_str());
367 R__ASSERT(dt != nullptr);
368 const auto type = dt->GetFullTypeName();
369 return type;
370}
371
372[[noreturn]] void
373ThrowJitBuildActionHelperTypeError(const std::string &actionTypeNameBase, const std::type_info &helperArgType)
374{
375 int err = 0;
377 std::string actionHelperTypeName = cname;
378 delete[] cname;
379 if (err != 0)
381
382 std::string exceptionText =
383 "RDataFrame::Jit: cannot just-in-time compile a \"" + actionTypeNameBase + "\" action using helper type \"" +
385 "\". This typically happens in a custom `Fill` or `Book` invocation where the types of the input columns have "
386 "not been specified as template parameters and the ROOT interpreter has no knowledge of this type of action "
387 "helper. Please add template parameters for the types of the input columns to avoid jitting this action (i.e. "
388 "`df.Fill<float>(..., {\"x\"})`, where `float` is the type of `x`) or declare the action helper type to the "
389 "interpreter, e.g. via gInterpreter->Declare.";
390
391 throw std::runtime_error(exceptionText);
392}
393
394} // anonymous namespace
395
396namespace ROOT {
397namespace Internal {
398namespace RDF {
399
400/// Take a list of column names, return that list with entries starting by '#' filtered out.
401/// The function throws when filtering out a column this way.
402ColumnNames_t FilterArraySizeColNames(const ColumnNames_t &columnNames, const std::string &action)
403{
404 ColumnNames_t columnListWithoutSizeColumns;
405 ColumnNames_t filteredColumns;
406 std::copy_if(columnNames.begin(), columnNames.end(), std::back_inserter(columnListWithoutSizeColumns),
407 [&](const std::string &name) {
408 if (name[0] == '#') {
409 filteredColumns.emplace_back(name);
410 return false;
411 } else {
412 return true;
413 }
414 });
415
416 if (!filteredColumns.empty()) {
417 std::string msg = "Column name(s) {";
418 for (auto &c : filteredColumns)
419 msg += c + ", ";
420 msg[msg.size() - 2] = '}';
421 msg += "will be ignored. Please go through a valid Alias to " + action + " an array size column";
422 throw std::runtime_error(msg);
423 }
424
426}
427
428void CheckValidCppVarName(std::string_view var, const std::string &where)
429{
430 bool isValid = true;
431
432 if (var.empty())
433 isValid = false;
434 const char firstChar = var[0];
435
436 // first character must be either a letter or an underscore
437 auto isALetter = [](char c) { return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'); };
438 const bool isValidFirstChar = firstChar == '_' || isALetter(firstChar);
439 if (!isValidFirstChar)
440 isValid = false;
441
442 // all characters must be either a letter, an underscore or a number
443 auto isANumber = [](char c) { return c >= '0' && c <= '9'; };
444 auto isValidTok = [&isALetter, &isANumber](char c) { return c == '_' || isALetter(c) || isANumber(c); };
445 for (const char c : var)
446 if (!isValidTok(c))
447 isValid = false;
448
449 if (!isValid) {
450 const auto objName = where == "Define" ? "column" : "variation";
451 const auto error = "RDataFrame::" + where + ": cannot define " + objName + " \"" + std::string(var) +
452 "\". Not a valid C++ variable name.";
453 throw std::runtime_error(error);
454 }
455}
456
457std::string DemangleTypeIdName(const std::type_info &typeInfo)
458{
459 int dummy(0);
461 std::string tname(tn);
462 free(tn);
463 return tname;
464}
465
466ColumnNames_t
467ConvertRegexToColumns(const ColumnNames_t &colNames, std::string_view columnNameRegexp, std::string_view callerName)
468{
469 const auto theRegexSize = columnNameRegexp.size();
470 std::string theRegex(columnNameRegexp);
471
472 const auto isEmptyRegex = 0 == theRegexSize;
473 // This is to avoid cases where branches called b1, b2, b3 are all matched by expression "b"
474 if (theRegexSize > 0 && theRegex[0] != '^')
475 theRegex = "^" + theRegex;
476 if (theRegexSize > 0 && theRegex[theRegexSize - 1] != '$')
477 theRegex = theRegex + "$";
478
479 ColumnNames_t selectedColumns;
480
481 // Since we support gcc48 and it does not provide in its stl std::regex,
482 // we need to use TPRegexp
483 TPRegexp regexp(theRegex);
484 for (auto &&colName : colNames) {
485 if ((isEmptyRegex || regexp.MatchB(colName.c_str())) && !IsInternalColumn(colName)) {
486 selectedColumns.emplace_back(colName);
487 }
488 }
489
490 if (selectedColumns.empty()) {
491 std::string text(callerName);
492 if (columnNameRegexp.empty()) {
493 text = ": there is no column available to match.";
494 } else {
495 text = ": regex \"" + std::string(columnNameRegexp) + "\" did not match any column.";
496 }
497 throw std::runtime_error(text);
498 }
499 return selectedColumns;
500}
501
502/// Throw if column `definedColView` is already there.
503void CheckForRedefinition(const std::string &where, std::string_view definedColView, const RColumnRegister &colRegister,
504 const ColumnNames_t &dataSourceColumns)
505{
506
507 std::string error{};
508 if (colRegister.IsAlias(definedColView))
509 error = "An alias with that name, pointing to column \"" + std::string(colRegister.ResolveAlias(definedColView)) +
510 "\", already exists in this branch of the computation graph.";
511 else if (colRegister.IsDefineOrAlias(definedColView))
512 error = "A column with that name has already been Define'd. Use Redefine to force redefinition.";
514 error =
515 "A column with that name is already present in the input data source. Use Redefine to force redefinition.";
516
517 if (!error.empty()) {
518 error = "RDataFrame::" + where + ": cannot define column \"" + std::string(definedColView) + "\". " + error;
519 throw std::runtime_error(error);
520 }
521}
522
523/// Throw if column `definedColView` is _not_ already there.
524void CheckForDefinition(const std::string &where, std::string_view definedColView, const RColumnRegister &colRegister,
525 const ColumnNames_t &dataSourceColumns)
526{
527 std::string error{};
528
529 if (colRegister.IsAlias(definedColView)) {
530 error = "An alias with that name, pointing to column \"" + std::string(colRegister.ResolveAlias(definedColView)) +
531 "\", already exists. Aliases cannot be Redefined or Varied.";
532 }
533
534 if (error.empty()) {
535 const bool isAlreadyDefined = colRegister.IsDefineOrAlias(definedColView);
536 const bool isADSColumn =
538
540 error = "No column with that name was found in the dataset. Use Define to create a new column.";
541 }
542
543 if (!error.empty()) {
544 if (where == "DefaultValueFor")
545 error = "RDataFrame::" + where + ": cannot provide default values for column \"" +
546 std::string(definedColView) + "\". " + error;
547 else
548 error = "RDataFrame::" + where + ": cannot redefine or vary column \"" + std::string(definedColView) + "\". " +
549 error;
550 throw std::runtime_error(error);
551 }
552}
553
554/// Throw if the column has systematic variations attached.
555void CheckForNoVariations(const std::string &where, std::string_view definedColView, const RColumnRegister &colRegister)
556{
557 const std::string definedCol(definedColView);
558 const auto &variationDeps = colRegister.GetVariationDeps(definedCol);
559 if (!variationDeps.empty()) {
560 if (where == "Redefine") {
561 const std::string error = "RDataFrame::" + where + ": cannot redefine column \"" + definedCol +
562 "\". The column depends on one or more systematic variations and re-defining varied "
563 "columns is not supported.";
564 throw std::runtime_error(error);
565 } else if (where == "DefaultValueFor") {
566 const std::string error = "RDataFrame::" + where + ": cannot provide a default value for column \"" +
567 definedCol +
568 "\". The column depends on one or more systematic variations and it should not be "
569 "possible to have missing values in varied columns.";
570 throw std::runtime_error(error);
571 } else {
572 const std::string error =
573 "RDataFrame::" + where + ": this operation cannot work with columns that depend on systematic variations.";
574 throw std::runtime_error(error);
575 }
576 }
577}
578
579void CheckTypesAndPars(unsigned int nTemplateParams, unsigned int nColumnNames)
580{
582 std::string err_msg = "The number of template parameters specified is ";
583 err_msg += std::to_string(nTemplateParams);
584 err_msg += " while ";
585 err_msg += std::to_string(nColumnNames);
586 err_msg += " columns have been specified.";
587 throw std::runtime_error(err_msg);
588 }
589}
590
591/// Choose between local column names or default column names, throw in case of errors.
592const ColumnNames_t
593SelectColumns(unsigned int nRequiredNames, const ColumnNames_t &names, const ColumnNames_t &defaultNames)
594{
595 if (names.empty()) {
596 // use default column names
597 if (defaultNames.size() < nRequiredNames)
598 throw std::runtime_error(
599 std::to_string(nRequiredNames) + " column name" + (nRequiredNames == 1 ? " is" : "s are") +
600 " required but none were provided and the default list has size " + std::to_string(defaultNames.size()));
601 // return first nRequiredNames default column names
602 return ColumnNames_t(defaultNames.begin(), defaultNames.begin() + nRequiredNames);
603 } else {
604 // use column names provided by the user to this particular transformation/action
605 if (names.size() != nRequiredNames) {
606 auto msg = std::to_string(nRequiredNames) + " column name" + (nRequiredNames == 1 ? " is" : "s are") +
607 " required but " + std::to_string(names.size()) + (names.size() == 1 ? " was" : " were") +
608 " provided:";
609 for (const auto &name : names)
610 msg += " \"" + name + "\",";
611 msg.back() = '.';
612 throw std::runtime_error(msg);
613 }
614 return names;
615 }
616}
617
618ColumnNames_t FindUnknownColumns(const ColumnNames_t &requiredCols, const RColumnRegister &definedCols,
619 const ColumnNames_t &dataSourceColumns)
620{
621 ColumnNames_t unknownColumns;
622 for (auto &column : requiredCols) {
623 if (definedCols.IsDefineOrAlias(column))
624 continue;
625 const auto isDataSourceColumn =
628 continue;
629 unknownColumns.emplace_back(column);
630 }
631 return unknownColumns;
632}
633
634std::vector<std::string> GetFilterNames(const std::shared_ptr<RLoopManager> &loopManager)
635{
636 return loopManager->GetFiltersNames();
637}
638
640{
641 // split name into directory and treename if needed
642 std::string_view dirName = "";
643 std::string_view treeName = fullTreeName;
644 const auto lastSlash = fullTreeName.rfind('/');
645 if (std::string_view::npos != lastSlash) {
646 dirName = treeName.substr(0, lastSlash);
647 treeName = treeName.substr(lastSlash + 1, treeName.size());
648 }
649 return {std::string(treeName), std::string(dirName)};
650}
651
652std::string PrettyPrintAddr(const void *const addr)
653{
654 std::stringstream s;
655 // Windows-friendly
657 return s.str();
658}
659
660/// Book the jitting of a Filter call
661std::shared_ptr<RDFDetail::RJittedFilter>
662BookFilterJit(std::shared_ptr<RDFDetail::RNodeBase> prevNode, std::string_view name, std::string_view expression,
663 const RColumnRegister &colRegister, TTree *tree, RDataSource *ds)
664{
665 const auto &dsColumns = ds ? ds->GetColumnNames() : ColumnNames_t{};
666
667 const auto parsedExpr = ParseRDFExpression(expression, colRegister, dsColumns);
668 const auto exprVarTypes =
669 GetValidatedArgTypes(parsedExpr.fUsedCols, colRegister, tree, ds, "Filter", /*vector2RVec=*/true);
670 const auto funcName = DeclareFunction(parsedExpr.fExpr, parsedExpr.fVarNames, exprVarTypes);
671 const auto type = RetTypeOfFunc(funcName);
672 if (type != "bool")
673 throw std::runtime_error("Filter: the following expression does not evaluate to bool:\n" +
674 std::string(expression));
675
676 auto *lm = prevNode->GetLoopManagerUnchecked();
677 const auto jittedFilter = std::make_shared<RDFDetail::RJittedFilter>(
678 lm, name, Union(colRegister.GetVariationDeps(parsedExpr.fUsedCols), prevNode->GetVariations()), prevNode);
679
680 // Produce code snippet that creates the filter and registers it with the corresponding RJittedFilter
681 std::stringstream filterInvocation;
682 filterInvocation << "(const std::vector<std::string> &colNames, "
683 << "ROOT::Internal::RDF::RColumnRegister &colRegister, "
684 << "ROOT::Detail::RDF::RLoopManager &lm, "
685 << "void *jittedFilter, "
686 << "std::shared_ptr<void> *) {\n";
687 filterInvocation << " ROOT::Internal::RDF::JitFilterHelper(" << funcName << ", "
688 << "colNames, "
689 << "colRegister, "
690 << "lm, "
691 << "reinterpret_cast<ROOT::Detail::RDF::RJittedFilter*>(jittedFilter)"
692 << ");\n}\n";
693 lm->RegisterJitHelperCall(filterInvocation.str(),
694 std::make_unique<ROOT::Internal::RDF::RColumnRegister>(colRegister), parsedExpr.fUsedCols,
696
697 return jittedFilter;
698}
699
700/// Book the jitting of a Define call
701std::shared_ptr<RJittedDefine> BookDefineJit(std::string_view name, std::string_view expression, RLoopManager &lm,
702 RDataSource *ds, const RColumnRegister &colRegister)
703{
704 const auto &dsColumns = ds ? ds->GetColumnNames() : ColumnNames_t{};
705
706 const auto parsedExpr = ParseRDFExpression(expression, colRegister, dsColumns);
707 const auto exprVarTypes =
708 GetValidatedArgTypes(parsedExpr.fUsedCols, colRegister, nullptr, ds, "Define", /*vector2RVec=*/true);
709 const auto funcName = DeclareFunction(parsedExpr.fExpr, parsedExpr.fVarNames, exprVarTypes);
710 const auto type = RetTypeOfFunc(funcName);
711
712 auto jittedDefine = std::make_shared<RDFDetail::RJittedDefine>(name, type, lm, colRegister, parsedExpr.fUsedCols);
713
714 // lifetime of pointees:
715 // - lm is the loop manager, and if that goes out of scope jitting does not happen at all (i.e. will always be valid)
716 // - jittedDefine: heap-allocated weak_ptr that will be deleted by JitDefineHelper after usage
717 // - definesAddr: heap-allocated, will be deleted by JitDefineHelper after usage
718 std::stringstream defineInvocation;
719 defineInvocation << "(const std::vector<std::string> &colNames, "
720 << "ROOT::Internal::RDF::RColumnRegister &colRegister, "
721 << "ROOT::Detail::RDF::RLoopManager &lm, "
722 << "void *jittedDefine, "
723 << "std::shared_ptr<void> *) {\n";
724 defineInvocation << " ROOT::Internal::RDF::JitDefineHelper<ROOT::Internal::RDF::DefineTypes::RDefineTag>("
725 << funcName << ", "
726 << "colNames, "
727 << "colRegister, "
728 << "lm, "
729 << "reinterpret_cast<ROOT::Detail::RDF::RJittedDefine *>(jittedDefine)"
730 << ");\n}\n";
731 lm.RegisterJitHelperCall(defineInvocation.str(), std::make_unique<ROOT::Internal::RDF::RColumnRegister>(colRegister),
732 parsedExpr.fUsedCols, jittedDefine);
733
734 return jittedDefine;
735}
736
737/// Book the jitting of a DefinePerSample call
738std::shared_ptr<RJittedDefine> BookDefinePerSampleJit(std::string_view name, std::string_view expression,
739 RLoopManager &lm, const RColumnRegister &colRegister)
740{
741 const auto funcName = DeclareFunction(std::string(expression), {"rdfslot_", "rdfsampleinfo_"},
742 {"unsigned int", "const ROOT::RDF::RSampleInfo"});
743 const auto retType = RetTypeOfFunc(funcName);
744
745 auto jittedDefine = std::make_shared<RDFDetail::RJittedDefine>(name, retType, lm, colRegister, ColumnNames_t{});
746
747 // lifetime of pointees:
748 // - lm is the loop manager, and if that goes out of scope jitting does not happen at all (i.e. will always be valid)
749 // - jittedDefine: heap-allocated weak_ptr that will be deleted by JitDefineHelper after usage
750 // - definesAddr: heap-allocated, will be deleted by JitDefineHelper after usage
751 std::stringstream defineInvocation;
752 defineInvocation << "(const std::vector<std::string> &colNames, "
753 << "ROOT::Internal::RDF::RColumnRegister &colRegister, "
754 << "ROOT::Detail::RDF::RLoopManager &lm, "
755 << "void *jittedDefine, "
756 << "std::shared_ptr<void> *) {\n";
757 defineInvocation << " ROOT::Internal::RDF::JitDefineHelper<ROOT::Internal::RDF::DefineTypes::RDefinePerSampleTag>("
758 << funcName << ", "
759 << "colNames, "
760 << "colRegister, "
761 << "lm, "
762 << "reinterpret_cast<ROOT::Detail::RDF::RJittedDefine *>(jittedDefine)"
763 << ");\n}\n";
764 lm.RegisterJitHelperCall(defineInvocation.str(), std::make_unique<ROOT::Internal::RDF::RColumnRegister>(colRegister),
765 {}, jittedDefine);
766 return jittedDefine;
767}
768
769/// Book the jitting of a Vary call
770std::shared_ptr<RJittedVariation>
771BookVariationJit(const std::vector<std::string> &colNames, std::string_view variationName,
772 const std::vector<std::string> &variationTags, std::string_view expression, RLoopManager &lm,
773 RDataSource *ds, const RColumnRegister &colRegister, bool isSingleColumn,
774 const std::string &varyColType)
775{
776 const auto &dsColumns = ds ? ds->GetColumnNames() : ColumnNames_t{};
777
778 const auto parsedExpr = ParseRDFExpression(expression, colRegister, dsColumns);
779 const auto exprVarTypes =
780 GetValidatedArgTypes(parsedExpr.fUsedCols, colRegister, nullptr, ds, "Vary", /*vector2RVec=*/true);
781 const auto funcName =
783 const auto type = RetTypeOfFunc(funcName);
784
785 if (type.rfind("ROOT::VecOps::RVec", 0) != 0) {
786 throw std::runtime_error(
787 "Jitted Vary expressions must return an RVec object. The following expression return type is '" + type +
788 "' instead:\n" + parsedExpr.fExpr);
789 }
790
791 auto jittedVariation = std::make_shared<RJittedVariation>(colNames, variationName, variationTags, type, colRegister,
792 lm, parsedExpr.fUsedCols);
793
794 // build invocation to JitVariationHelper
795 // variation tag (array of strings) passed as const char** plus size.
796 // lifetime of pointees:
797 // - lm is the loop manager, and if that goes out of scope jitting does not happen at all (i.e. will always be valid)
798 // - jittedVariation: heap-allocated weak_ptr that will be deleted by JitDefineHelper after usage
799 // - definesAddr: heap-allocated, will be deleted by JitDefineHelper after usage
800 // - variedColsOnHeap: deleted by registration function
801 std::stringstream varyInvocation;
802 varyInvocation << "(const std::vector<std::string> &inputColNames, "
803 << "ROOT::Internal::RDF::RColumnRegister &colRegister, "
804 << "ROOT::Detail::RDF::RLoopManager &lm, "
805 << "void *jittedVariation, "
806 << "std::shared_ptr<void> *helperArg) {\n";
808 << " auto *variedColNamesAndTags = reinterpret_cast<std::shared_ptr<std::pair<std::vector<std::string>, "
809 "std::vector<std::string>>> *>(helperArg);"
810 << " ROOT::Internal::RDF::JitVariationHelper<" << (isSingleColumn ? "true" : "false") << ">(" << funcName
811 << ", "
812 << "inputColNames, "
813 << "colRegister, "
814 << "lm, "
815 << "reinterpret_cast<ROOT::Internal::RDF::RJittedVariation *>(jittedVariation), "
816 << "(*variedColNamesAndTags)->first, "
817 << "(*variedColNamesAndTags)->second"
818 << ");\n}\n";
819 lm.RegisterJitHelperCall(
820 varyInvocation.str(), std::make_unique<ROOT::Internal::RDF::RColumnRegister>(colRegister), parsedExpr.fUsedCols,
822 std::make_shared<std::pair<std::vector<std::string>, std::vector<std::string>>>(colNames, variationTags));
823 return jittedVariation;
824}
825
826// Jit and call something equivalent to "this->BuildAndBook<ColTypes...>(params...)"
827// (see comments in the body for actual jitted code)
828std::string JitBuildAction(const ColumnNames_t &cols, const std::type_info &helperArgType, const std::type_info &at,
829 TTree *tree, const unsigned int nSlots, const RColumnRegister &colRegister, RDataSource *ds,
830 const bool vector2RVec)
831{
832 // retrieve type of action as a string
834 if (!actionTypeClass) {
835 std::string exceptionText = "An error occurred while inferring the action type of the operation.";
836 throw std::runtime_error(exceptionText);
837 }
838 const std::string actionTypeName = actionTypeClass->GetName();
839 const std::string actionTypeNameBase = actionTypeName.substr(actionTypeName.rfind(':') + 1);
840
841 // retrieve type of result of the action as a string
843 if (helperArgTypeName.empty()) {
845 }
846
847 // Build a call to CallBuildAction with the appropriate argument. When run through the interpreter, this code will
848 // just-in-time create an RAction object and it will assign it to its corresponding RJittedAction.
849 std::stringstream createAction_str;
850 createAction_str << "(const std::vector<std::string> &colNames, "
851 << "ROOT::Internal::RDF::RColumnRegister &colRegister, "
852 << "ROOT::Detail::RDF::RLoopManager &lm, "
853 << "void *jittedAction, "
854 << "std::shared_ptr<void> *helperArg) {\n";
855 createAction_str << " ROOT::Internal::RDF::CallBuildAction<" << actionTypeName;
857 for (auto &colType : columnTypeNames)
858 createAction_str << ", " << colType;
859 createAction_str << ">("
860 << "colNames, "
861 << "colRegister, "
862 << "lm, "
863 << "reinterpret_cast<ROOT::Internal::RDF::RJittedAction *>(jittedAction), " << nSlots << ", "
864 << "reinterpret_cast<std::shared_ptr<" << helperArgTypeName << "> *>(helperArg)"
865 << ");\n}\n";
866 return createAction_str.str();
867}
868
869bool AtLeastOneEmptyString(const std::vector<std::string_view> strings)
870{
871 for (const auto &s : strings) {
872 if (s.empty())
873 return true;
874 }
875 return false;
876}
877
878std::shared_ptr<RNodeBase> UpcastNode(std::shared_ptr<RNodeBase> ptr)
879{
880 return ptr;
881}
882
883/// Given the desired number of columns and the user-provided list of columns:
884/// * fallback to using the first nColumns default columns if needed (or throw if nColumns > nDefaultColumns)
885/// * check that selected column names refer to valid branches, custom columns or datasource columns (throw if not)
886/// * replace column names from aliases by the actual column name
887/// Return the list of selected column names.
888ColumnNames_t GetValidatedColumnNames(RLoopManager &lm, const unsigned int nColumns, const ColumnNames_t &columns,
889 const RColumnRegister &colRegister, RDataSource *ds)
890{
891 auto selectedColumns = SelectColumns(nColumns, columns, lm.GetDefaultColumnNames());
892
893 for (auto &col : selectedColumns) {
894 col = colRegister.ResolveAlias(col);
895 }
896
897 // Complain if there are still unknown columns at this point
898 auto unknownColumns = FindUnknownColumns(selectedColumns, colRegister, ds ? ds->GetColumnNames() : ColumnNames_t{});
899
900 if (!unknownColumns.empty()) {
901 // Some columns are still unknown, we need to understand if the error
902 // should be printed or if the user requested to explicitly disable it.
903 // Look for a possible overlap between the unknown columns and the
904 // columns we should ignore for the purpose of the following exception
905 std::set<std::string> intersection;
906 const auto &colsToIgnore = lm.GetSuppressErrorsForMissingBranches();
907 std::sort(unknownColumns.begin(), unknownColumns.end());
908 std::set_intersection(unknownColumns.cbegin(), unknownColumns.cend(), colsToIgnore.cbegin(), colsToIgnore.cend(),
909 std::inserter(intersection, intersection.begin()));
910 if (intersection.empty()) {
911 std::string errMsg = std::string("Unknown column") + (unknownColumns.size() > 1 ? "s: " : ": ");
912 for (auto &unknownColumn : unknownColumns)
913 errMsg += '"' + unknownColumn + "\", ";
914 errMsg.resize(errMsg.size() - 2); // remove last ", "
915 throw std::runtime_error(errMsg);
916 }
917 }
918
919 return selectedColumns;
920}
921
922std::vector<std::string> GetValidatedArgTypes(const ColumnNames_t &colNames, const RColumnRegister &colRegister,
923 TTree *tree, RDataSource *ds, const std::string &context,
924 bool vector2RVec)
925{
926 auto toCheckedArgType = [&](const std::string &c) {
927 RDFDetail::RDefineBase *define = colRegister.GetDefine(c);
928 const auto colType = ColumnName2ColumnTypeName(c, tree, ds, define, vector2RVec);
929 if (colType.rfind("CLING_UNKNOWN_TYPE", 0) == 0) { // the interpreter does not know this type
930 const auto msg =
931 "The type of custom column \"" + c + "\" (" + colType.substr(19) +
932 ") is not known to the interpreter, but a just-in-time-compiled " + context +
933 " call requires this column. Make sure to create and load ROOT dictionaries for this column's class.";
934 throw std::runtime_error(msg);
935 }
936 return colType;
937 };
938 std::vector<std::string> colTypes;
939 colTypes.reserve(colNames.size());
940 std::transform(colNames.begin(), colNames.end(), std::back_inserter(colTypes), toCheckedArgType);
941 return colTypes;
942}
943
944void CheckForDuplicateSnapshotColumns(const ColumnNames_t &cols)
945{
946 std::unordered_set<std::string> uniqueCols;
947 for (auto &col : cols) {
948 if (!uniqueCols.insert(col).second) {
949 const auto msg = "Error: column \"" + col +
950 "\" was passed to Snapshot twice. This is not supported: only one of the columns would be "
951 "readable with RDataFrame.";
952 throw std::logic_error(msg);
953 }
954 }
955}
956
958{
960 std::string optionName;
961
962 if (opts.fOutputFormat == ROOT::RDF::ESnapshotOutputFormat::kTTree ||
964 if (opts.fApproxZippedClusterSize != defaultSnapshotOpts.fApproxZippedClusterSize) {
965 optionName = "fApproxZippedClusterSize";
966 } else if (opts.fMaxUnzippedClusterSize != defaultSnapshotOpts.fMaxUnzippedClusterSize) {
967 optionName = "fMaxUnzippedClusterSize";
968 } else if (opts.fInitialUnzippedPageSize != defaultSnapshotOpts.fInitialUnzippedPageSize) {
969 optionName = "fInitialUnzippedPageSize";
970 } else if (opts.fMaxUnzippedPageSize != defaultSnapshotOpts.fMaxUnzippedPageSize) {
971 optionName = "fMaxUnzippedPageSize";
972 } else if (opts.fEnablePageChecksums != defaultSnapshotOpts.fEnablePageChecksums) {
973 optionName = "fEnablePageChecksums";
974 } else if (opts.fEnableSamePageMerging != defaultSnapshotOpts.fEnableSamePageMerging) {
975 optionName = "fEnableSamePageMerging";
976 }
977
978 if (!optionName.empty()) {
979 Warning("Snapshot",
980 "The RNTuple-specific %s option in RSnapshotOptions has been set, but the output format is "
981 "set to TTree, so this option won't have any effect. Use the other options available in "
982 "RSnapshotOptions to "
983 "configure the output TTree. Alternatively, change fOutputFormat to snapshot to RNTuple instead.",
984 optionName.c_str());
985 }
986 } else if (opts.fOutputFormat == ROOT::RDF::ESnapshotOutputFormat::kRNTuple) {
987 if (opts.fAutoFlush != defaultSnapshotOpts.fAutoFlush) {
988 optionName = "fAutoFlush";
989 } else if (opts.fSplitLevel != defaultSnapshotOpts.fSplitLevel) {
990 optionName = "fSplitLevel";
991 } else if (opts.fBasketSize != defaultSnapshotOpts.fBasketSize) {
992 optionName = "fBasketSize";
993 }
994
995 if (!optionName.empty()) {
996 Warning(
997 "Snapshot",
998 "The TTree-specific %s option in RSnapshotOptions has been set, but the output format is set to RNTuple, "
999 "so this option won't have any effect. Use the fNTupleWriteOptions option available in RSnapshotOptions to "
1000 "configure the output RNTuple. Alternatively, change fOutputFormat to snapshot to TTree instead.",
1001 optionName.c_str());
1002 }
1003 }
1004}
1005
1006/// Return copies of colsWithoutAliases and colsWithAliases with size branches for variable-sized array branches added
1007/// in the right positions (i.e. before the array branches that need them).
1008std::pair<std::vector<std::string>, std::vector<std::string>>
1009AddSizeBranches(ROOT::RDF::RDataSource *ds, std::vector<std::string> &&colsWithoutAliases,
1010 std::vector<std::string> &&colsWithAliases)
1011{
1012 TTree *tree{};
1013 if (auto treeDS = dynamic_cast<ROOT::Internal::RDF::RTTreeDS *>(ds))
1014 tree = treeDS->GetTree();
1015 if (!tree) // nothing to do
1016 return {std::move(colsWithoutAliases), std::move(colsWithAliases)};
1017
1018 assert(colsWithoutAliases.size() == colsWithAliases.size());
1019
1020 auto nCols = colsWithoutAliases.size();
1021 // Use index-iteration as we modify the vector during the iteration.
1022 for (std::size_t i = 0u; i < nCols; ++i) {
1023 const auto &colName = colsWithoutAliases[i];
1024
1025 auto *b = tree->GetBranch(colName.c_str());
1026 if (!b) // try harder
1027 b = tree->FindBranch(colName.c_str());
1028
1029 if (!b)
1030 continue;
1031
1032 auto *leaves = b->GetListOfLeaves();
1033 if (b->IsA() != TBranch::Class() || leaves->GetEntries() != 1)
1034 continue; // this branch is not a variable-sized array, nothing to do
1035
1036 TLeaf *countLeaf = static_cast<TLeaf *>(leaves->At(0))->GetLeafCount();
1037 if (!countLeaf || IsStrInVec(countLeaf->GetName(), colsWithoutAliases))
1038 continue; // not a variable-sized array or the size branch is already there, nothing to do
1039
1040 // otherwise we must insert the size in colsWithoutAliases _and_ colsWithAliases
1041 colsWithoutAliases.insert(colsWithoutAliases.begin() + i, countLeaf->GetName());
1042 colsWithAliases.insert(colsWithAliases.begin() + i, countLeaf->GetName());
1043 ++nCols;
1044 ++i; // as we inserted an element in the vector we iterate over, we need to move the index forward one extra time
1045 }
1046
1047 return {std::move(colsWithoutAliases), std::move(colsWithAliases)};
1048}
1049
1050void RemoveDuplicates(ColumnNames_t &columnNames)
1051{
1052 std::set<std::string> uniqueCols;
1053 columnNames.erase(
1054 std::remove_if(columnNames.begin(), columnNames.end(),
1055 [&uniqueCols](const std::string &colName) { return !uniqueCols.insert(colName).second; }),
1056 columnNames.end());
1057}
1058
1059void RemoveRNTupleSubfields(ColumnNames_t &columnNames)
1060{
1061 ColumnNames_t parentFields;
1062
1063 std::copy_if(columnNames.cbegin(), columnNames.cend(), std::back_inserter(parentFields),
1064 [](const std::string &colName) { return colName.find('.') == std::string::npos; });
1065
1066 columnNames.erase(std::remove_if(columnNames.begin(), columnNames.end(),
1067 [&parentFields](const std::string &colName) {
1068 if (colName.find('.') == std::string::npos)
1069 return false;
1070 const auto parentFieldName = colName.substr(0, colName.find_first_of('.'));
1071 return std::find(parentFields.cbegin(), parentFields.cend(), parentFieldName) !=
1072 parentFields.end();
1073 }),
1074 columnNames.end());
1075}
1076} // namespace RDF
1077} // namespace Internal
1078} // namespace ROOT
1079
1080namespace {
1081void AddDataSourceColumn(const std::string &colName, const std::type_info &typeID, ROOT::Detail::RDF::RLoopManager &lm,
1083{
1084
1085 if (colRegister.IsDefineOrAlias(colName))
1086 return;
1087
1088 if (lm.HasDataSourceColumnReaders(colName, typeID))
1089 return;
1090
1091 if (!ds.HasColumn(colName) &&
1092 lm.GetSuppressErrorsForMissingBranches().find(colName) == lm.GetSuppressErrorsForMissingBranches().end())
1093 return;
1094
1095 const auto nSlots = lm.GetNSlots();
1096 std::vector<std::unique_ptr<ROOT::Detail::RDF::RColumnReaderBase>> colReaders;
1097 colReaders.reserve(nSlots);
1098 // TODO consider changing the interface so we return all of these for all slots in one go
1099 for (auto slot = 0u; slot < nSlots; ++slot)
1100 colReaders.emplace_back(
1101 ROOT::Internal::RDF::CreateColumnReader(ds, slot, colName, typeID, /*treeReader*/ nullptr));
1102
1103 lm.AddDataSourceColumnReaders(colName, std::move(colReaders), typeID);
1104}
1105} // namespace
1106
1107void ROOT::Internal::RDF::AddDSColumns(const std::vector<std::string> &colNames, ROOT::Detail::RDF::RLoopManager &lm,
1109 const std::vector<const std::type_info *> &colTypeIDs,
1111{
1112 auto nCols = colNames.size();
1113 assert(nCols == colTypeIDs.size() && "Must provide exactly one column type for each column to create");
1114 for (decltype(nCols) i{}; i < nCols; i++) {
1116 }
1117}
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char text
char name[80]
Definition TGX11.cxx:145
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:426
#define R__LOCKGUARD(mutex)
#define free
Definition civetweb.c:1578
The head node of a RDF computation graph.
A binder for user-defined columns, variations and aliases.
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
const_iterator begin() const
const_iterator end() const
static TClass * Class()
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2994
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition TLeaf.h:57
Basic string class.
Definition TString.h:138
A TTree represents a columnar dataset.
Definition TTree.h:89
virtual TBranch * FindBranch(const char *name)
Return the branch that correspond to the path 'branchname', which can include the name of the tree or...
Definition TTree.cxx:4950
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
Definition TTree.cxx:5438
std::string TypeID2TypeName(const std::type_info &id)
Returns the name of a type starting from its type_info An empty string is returned in case of failure...
Definition RDFUtils.cxx:200
bool IsStrInVec(const std::string &str, const std::vector< std::string > &vec)
Definition RDFUtils.cxx:550
std::string PrettyPrintAddr(const void *const addr)
std::unique_ptr< ROOT::Detail::RDF::RColumnReaderBase > CreateColumnReader(ROOT::RDF::RDataSource &ds, unsigned int slot, std::string_view col, const std::type_info &tid, TTreeReader *treeReader)
Definition RDFUtils.cxx:698
std::string ColumnName2ColumnTypeName(const std::string &colName, TTree *, RDataSource *, RDefineBase *, bool vector2RVec=true)
Return a string containing the type of the given branch.
Definition RDFUtils.cxx:339
std::vector< T > Union(const std::vector< T > &v1, const std::vector< T > &v2)
Return a vector with all elements of v1 and v2 and duplicates removed.
Definition Utils.hxx:272
bool IsInternalColumn(std::string_view colName)
Whether custom column with name colName is an "internal" column such as rdfentry_ or rdfslot_.
Definition RDFUtils.cxx:492
void InterpreterDeclare(const std::string &code)
Declare code in the interpreter via the TInterpreter::Declare method, throw in case of errors.
Definition RDFUtils.cxx:443
std::vector< std::string > ColumnNames_t
char * DemangleTypeIdName(const std::type_info &ti, int &errorCode)
Demangle in a portable way the type id name.
BVH_ALWAYS_INLINE T dot(const Vec< T, N > &a, const Vec< T, N > &b)
Definition vec.h:98
A collection of options to steer the creation of the dataset on disk through Snapshot().