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

impossible to use type-erased write API to write an existing object #9069

Closed
eguiraud opened this issue Oct 5, 2021 · 2 comments · Fixed by #9317
Closed

impossible to use type-erased write API to write an existing object #9069

eguiraud opened this issue Oct 5, 2021 · 2 comments · Fixed by #9317

Comments

@eguiraud
Copy link
Member

eguiraud commented Oct 5, 2021

I would like to write (something equivalent to) the following:

auto m = RNTupleModel::Create();
auto field = RFieldBase::Create("v", "ROOT::VecOps::RVec<int>").Unwrap();
ROOT::RVec<int> rvec = {1, 2, 3};
m->AddField(std::move(field), (void*)&rvec);
auto w = RNTupleWriter::Recreate(std::move(m), "r", "somefile.root");

but that RNTupleModel::AddField signature is missing and I could not find another way to do this correctly.
For example the following example code adds a single field to the model ("v") but it adds two corresponding RFieldValues to model->GetDefaultEntry(), one explicitly with m->GetDefaultEntry()->CaptureValue() and one implicitly with the m->AddField(std::move(field)) call.

   // write out RVec
   {
      auto m = RNTupleModel::Create();
      auto field = RFieldBase::Create("v", "ROOT::VecOps::RVec<int>").Unwrap();
      ROOT::RVec<int> rvec = {1, 2, 3};
      m->GetDefaultEntry()->CaptureValue(field->CaptureValue(&rvec));
      m->AddField(std::move(field));

      auto w = RNTupleWriter::Recreate(std::move(m), "r", fileGuard.GetPath());
      w->Fill();
      rvec.clear();
      rvec.push_back(42);
      w->Fill();
   }
@jblomer
Copy link
Contributor

jblomer commented Oct 13, 2021

Remember to fix-up the rfield_vector.cxx unit test once this has been addressed.

@github-actions
Copy link

Hi @jalopezg-r00t, @jblomer,

It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise.

Sincerely,
🤖

@jalopezg-git jalopezg-git added this to Issues in Fixed in 6.28/00 via automation Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants