-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[ntuple] finalize automatic schema evolution between collections #20007
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
base: master
Are you sure you want to change the base?
Changes from all commits
2554f8d
2231faf
3d9bf61
f420cd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -871,23 +871,66 @@ void ROOT::RProxiedCollectionField::AcceptVisitor(ROOT::Detail::RFieldVisitor &v | |
//------------------------------------------------------------------------------ | ||
|
||
ROOT::RMapField::RMapField(std::string_view fieldName, EMapType mapType, std::unique_ptr<RFieldBase> itemField) | ||
: RProxiedCollectionField(fieldName, EnsureValidClass(BuildMapTypeName(mapType, itemField.get()))) | ||
: RProxiedCollectionField(fieldName, EnsureValidClass(BuildMapTypeName(mapType, itemField.get()))), fMapType(mapType) | ||
{ | ||
auto *itemClass = fProxy->GetValueClass(); | ||
fItemSize = itemClass->GetClassSize(); | ||
|
||
Attach(std::move(itemField)); | ||
} | ||
|
||
std::unique_ptr<ROOT::RFieldBase> ROOT::RMapField::CloneImpl(std::string_view newName) const | ||
{ | ||
return std::make_unique<RMapField>(newName, fMapType, fSubfields[0]->Clone(fSubfields[0]->GetFieldName())); | ||
} | ||
|
||
void ROOT::RMapField::ReconcileOnDiskField(const RNTupleDescriptor &desc) | ||
{ | ||
static const std::vector<std::string> prefixesRegular = {"std::map<", "std::unordered_map<", "std::set<"}; | ||
|
||
const auto &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId()); | ||
EnsureMatchingOnDiskField(fieldDesc, kDiffTypeName).ThrowOnError(); | ||
|
||
switch (fMapType) { | ||
case EMapType::kMap: | ||
case EMapType::kUnorderedMap: EnsureMatchingTypePrefix(fieldDesc, prefixesRegular).ThrowOnError(); break; | ||
default: | ||
break; | ||
// no restrictions for multimaps | ||
} | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
|
||
ROOT::RSetField::RSetField(std::string_view fieldName, ESetType setType, std::unique_ptr<RFieldBase> itemField) | ||
: ROOT::RProxiedCollectionField(fieldName, EnsureValidClass(BuildSetTypeName(setType, *itemField))) | ||
: ROOT::RProxiedCollectionField(fieldName, EnsureValidClass(BuildSetTypeName(setType, *itemField))), | ||
fSetType(setType) | ||
{ | ||
fItemSize = itemField->GetValueSize(); | ||
Attach(std::move(itemField)); | ||
} | ||
|
||
std::unique_ptr<ROOT::RFieldBase> ROOT::RSetField::CloneImpl(std::string_view newName) const | ||
{ | ||
return std::make_unique<RSetField>(newName, fSetType, fSubfields[0]->Clone(fSubfields[0]->GetFieldName())); | ||
} | ||
|
||
void ROOT::RSetField::ReconcileOnDiskField(const RNTupleDescriptor &desc) | ||
{ | ||
static const std::vector<std::string> prefixesRegular = {"std::set<", "std::unordered_set<", "std::map<"}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we discussed this, but I forgot the reasoning again, sorry: Why can we read into a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think from the point of view of I/O we could. But to make it happen, we would need an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why is this an issue for a And is it a fundamental issue or just an issue for the test? I.e. if a user had written a |
||
|
||
const auto &fieldDesc = desc.GetFieldDescriptor(GetOnDiskId()); | ||
EnsureMatchingOnDiskField(fieldDesc, kDiffTypeName).ThrowOnError(); | ||
|
||
switch (fSetType) { | ||
case ESetType::kSet: | ||
case ESetType::kUnorderedSet: EnsureMatchingTypePrefix(fieldDesc, prefixesRegular).ThrowOnError(); break; | ||
default: | ||
break; | ||
// no restrictions for multisets | ||
} | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
|
||
namespace { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef ROOT_RNTuple_Test_STLContainerEvolution | ||
#define ROOT_RNTuple_Test_STLContainerEvolution | ||
|
||
#include <map> | ||
#include <set> | ||
#include <unordered_set> | ||
#include <unordered_map> | ||
#include <utility> | ||
#include <vector> | ||
|
||
template <typename T> | ||
struct CollectionProxy { | ||
using ValueType = T; | ||
std::vector<T> v; //! | ||
}; | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifdef __CLING__ | ||
|
||
#pragma link C++ class std::set<int>+; | ||
#pragma link C++ class std::set<short int>+; | ||
#pragma link C++ class std::set<std::pair<int, int>>+; | ||
#pragma link C++ class std::set<std::pair<short int, short int>>+; | ||
|
||
#pragma link C++ class std::unordered_set<int>+; | ||
#pragma link C++ class std::unordered_set<short int>+; | ||
|
||
#pragma link C++ class std::multiset<int>+; | ||
#pragma link C++ class std::multiset<short int>+; | ||
#pragma link C++ class std::multiset<std::pair<int, int>>+; | ||
#pragma link C++ class std::multiset<std::pair<short int, short int>>+; | ||
|
||
#pragma link C++ class std::unordered_multiset<int>+; | ||
#pragma link C++ class std::unordered_multiset<short int>+; | ||
|
||
#pragma link C++ class std::map<int, int>+; | ||
#pragma link C++ class std::map<short int, short int>+; | ||
|
||
#pragma link C++ class std::unordered_map<int, int>+; | ||
#pragma link C++ class std::unordered_map<short int, short int>+; | ||
|
||
#pragma link C++ class std::multimap<int, int>+; | ||
#pragma link C++ class std::multimap<short int, short int>+; | ||
|
||
#pragma link C++ class std::unordered_multimap<int, int>+; | ||
#pragma link C++ class std::unordered_multimap<short int, short int>+; | ||
|
||
#pragma link C++ class CollectionProxy<int>+; | ||
#pragma link C++ class CollectionProxy<short int>+; | ||
#pragma link C++ class CollectionProxy<std::pair<int, int>>+; | ||
#pragma link C++ class CollectionProxy<std::pair<short int, short int>>+; | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similarly here:
std::unordered_set
?