Skip to content

Commit 450d19b

Browse files
committed
[ntuple] test automatic schema evolution of collections
1 parent 58b1e13 commit 450d19b

File tree

4 files changed

+402
-0
lines changed

4 files changed

+402
-0
lines changed

tree/ntuple/test/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ ROOT_GENERATE_DICTIONARY(RNTupleDescriptorDict ${CMAKE_CURRENT_SOURCE_DIR}/RNTup
3838

3939
ROOT_ADD_GTEST(ntuple_endian ntuple_endian.cxx LIBRARIES ROOTNTuple)
4040
ROOT_ADD_GTEST(ntuple_evolution_type ntuple_evolution_type.cxx LIBRARIES ROOTNTuple)
41+
ROOT_GENERATE_DICTIONARY(STLContainerEvolutionDict ${CMAKE_CURRENT_SOURCE_DIR}/STLContainerEvolution.hxx
42+
MODULE ntuple_evolution_type
43+
LINKDEF STLContainerEvolutionLinkDef.h
44+
OPTIONS -inlineInputHeader
45+
DEPENDENCIES CustomStruct)
4146
if(NOT MSVC)
4247
# These unit tests rely on fork(), which is not available on Windows.
4348
ROOT_ADD_GTEST(ntuple_evolution_shape ntuple_evolution_shape.cxx LIBRARIES ROOTNTuple)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef ROOT_RNTuple_Test_STLContainerEvolution
2+
#define ROOT_RNTuple_Test_STLContainerEvolution
3+
4+
#include <map>
5+
#include <set>
6+
#include <unordered_set>
7+
#include <unordered_map>
8+
#include <utility>
9+
#include <vector>
10+
11+
// The following std::hash specializations allow for creating unordered sets of pairs in the Collections test.
12+
// It is a quick but bad hash but for this test though it should be ok.
13+
template <>
14+
struct std::hash<std::pair<int, int>> {
15+
std::size_t operator()(const std::pair<int, int> &p) const noexcept
16+
{
17+
std::size_t h1 = std::hash<int>{}(p.first);
18+
std::size_t h2 = std::hash<int>{}(p.second);
19+
return h1 ^ (h2 << 1);
20+
}
21+
};
22+
23+
template <>
24+
struct std::hash<std::pair<short int, short int>> {
25+
std::size_t operator()(const std::pair<short int, short int> &p) const noexcept
26+
{
27+
std::size_t h1 = std::hash<short int>{}(p.first);
28+
std::size_t h2 = std::hash<short int>{}(p.second);
29+
return h1 ^ (h2 << 1);
30+
}
31+
};
32+
33+
template <typename T>
34+
struct CollectionProxy {
35+
using ValueType = T;
36+
std::vector<T> v; //!
37+
};
38+
39+
#endif
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#ifdef __CLING__
2+
3+
#pragma link C++ class std::set<int>+;
4+
#pragma link C++ class std::set<short int>+;
5+
#pragma link C++ class std::set<std::pair<int, int>>+;
6+
#pragma link C++ class std::set<std::pair<short int, short int>>+;
7+
8+
#pragma link C++ class std::unordered_set<int>+;
9+
#pragma link C++ class std::unordered_set<short int>+;
10+
#pragma link C++ class std::unordered_set<std::pair<int, int>>+;
11+
#pragma link C++ class std::unordered_set<std::pair<short int, short int>>+;
12+
13+
#pragma link C++ class std::multiset<int>+;
14+
#pragma link C++ class std::multiset<short int>+;
15+
#pragma link C++ class std::multiset<std::pair<int, int>>+;
16+
#pragma link C++ class std::multiset<std::pair<short int, short int>>+;
17+
18+
#pragma link C++ class std::unordered_multiset<int>+;
19+
#pragma link C++ class std::unordered_multiset<short int>+;
20+
#pragma link C++ class std::unordered_multiset<std::pair<int, int>>+;
21+
#pragma link C++ class std::unordered_multiset<std::pair<short int, short int>>+;
22+
23+
#pragma link C++ class std::map<int, int>+;
24+
#pragma link C++ class std::map<short int, short int>+;
25+
26+
#pragma link C++ class std::unordered_map<int, int>+;
27+
#pragma link C++ class std::unordered_map<short int, short int>+;
28+
29+
#pragma link C++ class std::multimap<int, int>+;
30+
#pragma link C++ class std::multimap<short int, short int>+;
31+
32+
#pragma link C++ class std::unordered_multimap<int, int>+;
33+
#pragma link C++ class std::unordered_multimap<short int, short int>+;
34+
35+
#pragma link C++ class CollectionProxy<int>+;
36+
#pragma link C++ class CollectionProxy<short int>+;
37+
#pragma link C++ class CollectionProxy<std::pair<int, int>>+;
38+
#pragma link C++ class CollectionProxy<std::pair<short int, short int>>+;
39+
40+
#endif

0 commit comments

Comments
 (0)