Skip to content

Conversation

@jblomer
Copy link
Contributor

@jblomer jblomer commented Jan 26, 2024

Change raw pointer methods to shared pointers or const ref. Remove unsafe and unnecessary methods.

Add RNTupleModel::GenerateBulk().

@jblomer jblomer self-assigned this Jan 26, 2024
@jblomer jblomer requested a review from bellenot as a code owner January 26, 2024 13:39
@phsft-bot
Copy link

Starting build on ROOT-performance-centos8-multicore/soversion, ROOT-ubuntu2204/nortcxxmod, ROOT-ubuntu2004/python3, mac12arm/cxx20, windows10/default
How to customize builds

Copy link
Contributor

@enirolf enirolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I have left two small comments.

std::function<std::string(const std::string &)> mapping);

template <typename T>
T *Get(std::string_view fieldName) const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be an idea to have a Get<T> (perhaps named differently) that returns a shared pointer to the object? The use case would be for type-erased fields. Right now the (only) way to do it is through ntuple->GetModel().GetDefaultEntry()->GetPtr<T>("fieldname"), which feels a bit unwieldy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a possibility, a getter acting as a shortcut for GetModel().GetDefaultEntry()->GetPtr<T>. On the other hand, callers can could also first get the entry and then call (multiple times) entry.GetPtr<T>(). How about we see if users stumble across it and defer the addition of the method until then?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes fair enough, sounds good!

/// set memory addresses to be serialized / deserialized
std::unique_ptr<REntry> CreateBareEntry() const;
REntry *GetDefaultEntry() const;
Detail::RFieldBase::RBulk GenerateBulk(std::string_view fieldName) const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add some documentation

@github-actions
Copy link

github-actions bot commented Jan 26, 2024

Test Results

    10 files      10 suites   2d 0h 39m 48s ⏱️
 2 497 tests  2 497 ✅ 0 💤 0 ❌
23 867 runs  23 867 ✅ 0 💤 0 ❌

Results for commit 4eb071d.

♻️ This comment has been updated with latest results.

@phsft-bot
Copy link

Starting build on ROOT-performance-centos8-multicore/soversion, ROOT-ubuntu2204/nortcxxmod, ROOT-ubuntu2004/python3, mac12arm/cxx20, windows10/default
How to customize builds

@jblomer jblomer requested a review from enirolf January 26, 2024 21:21
Copy link
Contributor

@enirolf enirolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me, but following from the discussion on shared pointers on Friday maybe someone else should also have a look.

@hahnjo
Copy link
Member

hahnjo commented Jan 29, 2024

I already had a quick look last week and didn't have any further comments (except maybe that GenerateBulk is first used in the next commit titled "return const ref from RNTupleReader::GetModel()" 🙈)

@jblomer jblomer merged commit d424fcb into root-project:master Jan 29, 2024
@jblomer jblomer deleted the ntuple-interface-19 branch January 29, 2024 09:00
@smuzaffar
Copy link
Contributor

@jblomer , we are trying to test latest root master changes in CMSSW and our build failed with errors like [a]. Looks like this change is causing cmssw to fail. I guess we need to update cmssw to use model.GetDefaultEntry()->GetPtr<T>(name) instead of model.Get<T>(name) ... right? What about addField<T>() calls?

We also want same cmssw code to work for ROOT 6.26 and above. So should we add some #if ROOT_VERSION_CODE >= ROOT_VERSION(6,31,0) blocks ?

[a] https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-6f60ec/37085/build-logs/PhysicsTools/NanoAOD/log.html

  /data/cmsbld/jenkins/workspace/ib-run-pr-tests/CMSSW_14_0_ROOT6_X_2024-01-28-2300/src/PhysicsTools/NanoAOD/plugins/rntuple/TriggerOutputFields.cc:126:38: error: 'class ROOT::Experimental::RNTupleModel' has no member named 'Get'
   126 |   const auto* existing_field = model.Get<bool>(name);
      |                                      ^~~
  /data/cmsbld/jenkins/workspace/ib-run-pr-tests/CMSSW_14_0_ROOT6_X_2024-01-28-2300/src/PhysicsTools/NanoAOD/plugins/rntuple/TriggerOutputFields.cc:126:42: error: expected primary-expression before 'bool'
   126 |   const auto* existing_field = model.Get<bool>(name);
      |                                          ^~~~
/data/cmsbld/jenkins/workspace/ib-run-pr-tests/CMSSW_14_0_ROOT6_X_2024-01-28-2300/src/PhysicsTools/NanoAOD/plugins/rntuple/NanoAODRNTupleOutputModule.cc: In member function 'void NanoAODRNTupleOutputModule::CommonEventFields::createFields(ROOT::Experimental::RNTupleModel&)':
  /data/cmsbld/jenkins/workspace/ib-run-pr-tests/CMSSW_14_0_ROOT6_X_2024-01-28-2300/src/PhysicsTools/NanoAOD/plugins/rntuple/NanoAODRNTupleOutputModule.cc:77:28: error: expected primary-expression before '>' token
    77 |       model.AddField<UInt_t>("run", &m_run);
      |                            ^
  /data/cmsbld/jenkins/workspace/ib-run-pr-tests/CMSSW_14_0_ROOT6_X_2024-01-28-2300/src/PhysicsTools/NanoAOD/plugins/rntuple/NanoAODRNTupleOutputModule.cc:77:30: error: left operand of comma operator has no effect [-Werror=unused-value]
    77 |       model.AddField<UInt_t>("run", &m_run);
      |                              ^~~~~
  /data/cmsbld/jenkins/workspace/ib-run-pr-tests/CMSSW_14_0_ROOT6_X_2024-01-28-2300/src/PhysicsTools/NanoAOD/plugins/rntuple/NanoAODRNTupleOutputModule.cc:78:28: error: expected primary-expression before '>' token
    78 |       model.AddField<UInt_t>("luminosityBlock", &m_luminosityBlock);
      |                            ^
  /data/cmsbld/jenkins/workspace/ib-run-pr-tests/CMSSW_14_0_ROOT6_X_2024-01-28-2300/src/PhysicsTools/NanoAOD/plugins/rntuple/NanoAODRNTupleOutputModule.cc:78:30: error: left operand of comma operator has no effect [-Werror=unused-value]
    78 |       model.AddField<UInt_t>("luminosityBlock", &m_luminosityBlock);
      |                              ^~~~~~~~~~~~~~~~~
  /data/cmsbld/jenkins/workspace/ib-run-pr-tests/CMSSW_14_0_ROOT6_X_2024-01-28-2300/src/PhysicsTools/NanoAOD/plugins/rntuple/NanoAODRNTupleOutputModule.cc:79:35: error: expected primary-expression before '>' token
    79 |       model.AddField<std::uint64_t>("event", &m_event);
      |                                   ^
  /data/cmsbld/jenkins/workspace/ib-run-pr-tests/CMSSW_14_0_ROOT6_X_2024-01-28-2300/src/PhysicsTools/NanoAOD/plugins/rntuple/NanoAODRNTupleOutputModule.cc:79:37: error: left operand of comma operator has no effect [-Werror=unused-value]
    79 |       model.AddField<std::uint64_t>("event", &m_event);
      |                                     ^~~~~~~

@smuzaffar
Copy link
Contributor

@jblomer @hahnjo any suggestion about #14454 (comment) ?

@hahnjo
Copy link
Member

hahnjo commented Jan 30, 2024

I guess we need to update cmssw to use model.GetDefaultEntry()->GetPtr<T>(name) instead of model.Get<T>(name) ... right?

Yes, but with yesterday's changes I think it will be model.GetDefaultEntry().GetPtr<T>(name) because GetDefaultEntry returns a reference now. In general, there will be some more interface changes coming in the near future...

What about addField<T>() calls?

That one is a bit more complicated; after a quick look, I think CommonEventFields should call MakeField, store the returned std::shared_ptr and use that one in fill(const edm::EventID& id).

@smuzaffar
Copy link
Contributor

thanks @hahnjo , I have opened cms-sw/cmssw#43834

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants