Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DPL Inputrecord: fixing compilation error when trying to use get<std::vector<pod>> #2617

Merged

Conversation

matthiasrichter
Copy link
Collaborator

There was compilation problem when using the InputRecord API with vectors of
PODs. Adding also a test case to the unit test.

@matthiasrichter matthiasrichter requested a review from a team as a code owner November 26, 2019 12:57
@shahor02
Copy link
Collaborator

@matthiasrichter I also get a compilation error when trying to add a branch with std::vector<pod> to RootTreeWriter. The problem can be reproduced simply by changing
using Container = std::vector<o2::test::Polymorphic>; to
using Container = std::vector<int>; in your Framework/Utils/test/test_RootTreeWriter.cxx. The compilation produces (full log attached) :

/home/shahoian/alice/sw/SOURCES/O2/1.0.0/0/Framework/Core/include/Framework/SerializationMethods.h:55:3: error: static assertion failed: wrapped type can not be a pointer
   static_assert(std::is_pointer<T>::value == false, "wrapped type can not be a pointer");
   ^~~~~~~~~~~~~

Happens both with dev and this branch.

@matthiasrichter
Copy link
Collaborator Author

Hello @shahor02, right now this is actually by concept. We do not want to use ROOT serialization for std::vector<pod>, furthermore the streamer can not be detected at compile time if the ClassDef macros are not used, which is the case for std::vector<fundamental_type>.

I will investigate if it is enough to introduce a special type trait handling for vectors of fundamental types. I think in your case you want to have vector<int> stored in the branch in order to use macros and TreeViewer. I will try to enhance the ROOTTreeWriter to handle such cases.

There is a way to store the message as a binary blob in a binary branch, you have to specify BranchDef<const char*>. The ROOTTreeReader will restore the original message payload. This can be used for storage.

@matthiasrichter
Copy link
Collaborator Author

@shahor02 this concerns only the automatically generated streamers for vectors of fundamental types. With the current implementation of ROOTTreeWriter, a possible solution is e.g.

struct TheIndex {
  int index;

  ClassDefNV(TheIndex, 1)
};

and sending/storing std::vector<TheIndex>. This is messageable, and at the same time ROOT serializable for the TreeWriter.

@shahor02
Copy link
Collaborator

@matthiasrichter thanks! What I need is to store a vector<uint32_t> (not for macros/TreeViewer but to have a single container of cluster indices instead of per-track vector<uint32_t> of TrackTPC class (which makes it non-messagable). As a last resort, I can use the struct you suggested, but if takes a couple of days to learn if the TreeWriter can be adapted to trivial types, I better wait: anyway, there is another showstopper with ITS Cluster not being understood to be messagable.

@matthiasrichter matthiasrichter changed the title Bugfix: compilation error when trying to use get<std::vector<pod>> [WIP] Bugfix: compilation error when trying to use get<std::vector<pod>> Dec 2, 2019
@matthiasrichter
Copy link
Collaborator Author

There is more work needed to avoid the copy when extracting the unserialized vector object. In fact this PR only makes sense if this can be solved, the API needs to be corrected otherwise and this PR will be obsolete. Working on a prototype.

@ktf
Copy link
Member

ktf commented Mar 21, 2020

Is this still needed?

There was compilation problem when using the InputRecord API with vectors of
PODs. Adding also a test case to the unit test.
@matthiasrichter matthiasrichter changed the title [WIP] Bugfix: compilation error when trying to use get<std::vector<pod>> DPL Inputrecord: fixing compilation error when trying to use get<std::vector<pod>> Apr 24, 2020
@matthiasrichter matthiasrichter force-pushed the fix-dpl-input-record-api branch from 115bb2d to a969fb7 Compare April 24, 2020 09:17
@matthiasrichter
Copy link
Collaborator Author

yes, I have now adjusted all conflicting code for #2697 and we can go on with these two PRs. This one is ready for merging once the tests are ok.

@matthiasrichter matthiasrichter merged commit 63c5c67 into AliceO2Group:dev Apr 27, 2020
@matthiasrichter matthiasrichter deleted the fix-dpl-input-record-api branch April 27, 2020 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants