RVec::Argsort issues

Hi,

auto fVar = tdf.Take<std::string>("col");
auto indexSort = Argsort(fVar);

causes following error message. How can I convert RResultPtr to an RVec ?

error: no matching function for call to 'Argsort'
auto indexSort = Argsort(fVar);
                 ^~~~~~~
/Users/eddyo/src/root_cmake/root_cmake/include/ROOT/RVec.hxx:721:35: note: candidate template ignored: could not match 'RVec' against 'RResultPtr'
RVec<typename RVec<T>::size_type> Argsort(const RVec<T> &v)

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


@Danilo could you have a look a this?

Hi Eddy,

this is in short (and code) the answer to your question:

   auto fVarResPtr = rdf.Take<std::string, RVec<std::string>>("col");
   auto &fVar = fVarResPtr.GetValue ();
   auto indexSort = Argsort(fVar);

   cout << indexSort << endl;

There are two important ingredients:

  1. Getting out of the result pointer the reference to the actuall result (GetReference)
  2. Instructing Take to store the information not in a std::vector (which is done by default), but rather in a RVec directly.

Cheers,
D

Hi Danilo,
Thank you for the quick response. But now I am confused because I thought that
the default output of a Take action was an RVec, see description on the
cheat sheet RDataFrame:

“Extract a column from the dataset as a collection of values. If the type of the column is a C-style array, the type stored in the return container is a ROOT::VecOps::RVec<T> to guarantee the lifetime of the data involved.”

-Eddy

Hi Eddy,

this is indeed true. The issue here is that the type of a branch is string and not double[5] (which is not a type, but ok :slight_smile: )
I admit that the sentence in the doc is to be improved and it will.

Cheers,
D

FYI: https://github.com/root-project/root/pull/2920

Hi Danilo,
Just to help you in the formulation (and stupid I was :slight_smile: ). For the formulation it was not clear to me that each row entry had to be a C-style array. I thought that as long it was a simple type, the whole column constituted a C-style array.
-Eddy

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.