# RDataFrame Snapshot of RVec\<std::string\>

**URL:** <https://root-forum.cern.ch/t/rdataframe-snapshot-of-rvec-std-string/44767>\
**Category:** ROOT\
**Tags:** rdataframe\
**Created:** [May 7, 2021, 6:09pm UTC](https://root-forum.cern.ch/t/rdataframe-snapshot-of-rvec-std-string/44767 "2021-05-07T18:09:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhubacek](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/z/9de0a6/32.png) [@zhubacek](https://root-forum.cern.ch/u/zhubacek)\
**Post date:** [May 7, 2021, 6:09pm UTC](https://root-forum.cern.ch/t/rdataframe-snapshot-of-rvec-std-string/44767/1 "2021-05-07T18:09:42Z")

</div>

Dear experts,  
My question seems to be related to [this issue](https://root-forum.cern.ch/t/snapshot-of-rvec-rvec-t-produces-broken-root-file/43960)  
I tried to save my dataframe with a Snapshot of column type `ROOT::RVec<std::string>` because I though that the RVec is preferred over `std::vector` - I am not able to save the tree correctly (I don’t generate the dictionary)

```auto
Error in <TTree::Branch>: The class requested (vector<string,ROOT::Detail::VecOps::RAdoptAllocator<string> >) for the branch "aaa" is an instance of an stl collection and does not have a compiled CollectionProxy. Please generate the dictionary for this collection (vector<string,ROOT::Detail::VecOps::RAdoptAllocator<string> >) to avoid to write corrupted data.

```

if I change the code to `std::vector<std::string>` the tree gets saved.

According to the linked thread, ROOT is doing some on the fly conversion from RVec to std::vector - is it supposed to work on `std::string` or do I always need the dictionary in this case?

Thanks  
Zdenek

* * *

_ROOT Version:_ 6.22/00  
_Platform:_ CentOS7/MacOS  
_Compiler:_ g++

* * *

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [May 7, 2021, 6:47pm UTC](https://root-forum.cern.ch/t/rdataframe-snapshot-of-rvec-std-string/44767/2 "2021-05-07T18:47:00Z")

</div>

Maybe @eguiraud can give some hints

---

<div class="post-metadata">

**Author:** ![zhubacek](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/z/9de0a6/32.png) [@zhubacek](https://root-forum.cern.ch/u/zhubacek)\
**Post date:** [May 7, 2021, 6:53pm UTC](https://root-forum.cern.ch/t/rdataframe-snapshot-of-rvec-std-string/44767/3 "2021-05-07T18:53:56Z")

</div>

I’m attaching an example - in my case, I create the `RVec<string>` or `vector<string>` on the fly, it is not read from disk  
[rdf\_rvecstring.C](https://root-forum.cern.ch/uploads/short-url/hIPmmTEHij3ILmg4rEtGr8zy0aU.C) (418 Bytes)

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [May 10, 2021, 7:45am UTC](https://root-forum.cern.ch/t/rdataframe-snapshot-of-rvec-std-string/44767/4 "2021-05-10T07:45:15Z")

</div>

Hi @zhubacek ,  
Snapshot performs an on-the-fly conversion to std::vector but due to some subtleties, for types other than fundamental types, you still need dictionaries that you wouldn’t need if you just used std::vectors.  
We are making things better for 6.26: there RVec will behave the same as std::vector in terms of I/O, and if it doesn’t it’s a bug to fix/improvement to add.

The simplest solution for 6.24 (the current stable release) and previous releases is to use `vector<std::string>`.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [May 24, 2021, 7:45am UTC](https://root-forum.cern.ch/t/rdataframe-snapshot-of-rvec-std-string/44767/5 "2021-05-24T07:45:20Z")

</div>

Closed on May 24, 2021, 7:45am UTC

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