-
Notifications
You must be signed in to change notification settings - Fork 12
FORM Test for ROOT Schema Evolution #388
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
Open
aolivier23
wants to merge
3
commits into
main
Choose a base branch
from
feature/aolivier-form-schema-evolution-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| set(FORM_EXTRA_DATA_PROD_LIB_NAME "form_test_data_products_schema_evolution") | ||
| add_library(${FORM_EXTRA_DATA_PROD_LIB_NAME} SHARED track_start.cpp) | ||
|
|
||
| if(FORM_USE_ROOT_STORAGE) | ||
| find_package(ROOT REQUIRED COMPONENTS RIO) | ||
| include_directories(${ROOT_INCLUDE_DIRS}) | ||
| reflex_generate_dictionary( | ||
| ${FORM_EXTRA_DATA_PROD_LIB_NAME} dict.h SELECTION classes_def.xml | ||
| ) | ||
| target_link_libraries(${FORM_EXTRA_DATA_PROD_LIB_NAME} PRIVATE ROOT::RIO) | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <lcgdict> | ||
| <class name="TrackStart"/> | ||
| <class name="std::vector<TrackStart>"/> | ||
| </lcgdict> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| #include "track_start.hpp" | ||
| #include <vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #include "track_start.hpp" | ||
|
|
||
| TrackStart::TrackStart() : m_x(0), m_y(0), m_z(0), m_index(0) {} | ||
|
|
||
| TrackStart::TrackStart(float x, float y, float z, int index) : | ||
| m_x(x), m_y(y), m_z(z), m_index(index) | ||
| { | ||
| } | ||
|
|
||
| float TrackStart::getX() const { return m_x; } | ||
|
|
||
| float TrackStart::getY() const { return m_y; } | ||
|
|
||
| float TrackStart::getZ() const { return m_z; } | ||
|
|
||
| int TrackStart::getIndex() const { return m_index; } | ||
|
|
||
| void TrackStart::setX(float x) { m_x = x; } | ||
|
|
||
| void TrackStart::setY(float y) { m_y = y; } | ||
|
|
||
| void TrackStart::setZ(float z) { m_z = z; } | ||
|
|
||
| void TrackStart::setIndex(int index) { m_index = index; } | ||
|
|
||
| TrackStart TrackStart::operator+(TrackStart const& other) const | ||
| { | ||
| return TrackStart(m_x + other.m_x, m_y + other.m_y, m_z + other.m_z, m_index + other.m_index); | ||
| } | ||
|
|
||
| TrackStart& TrackStart::operator+=(TrackStart const& other) | ||
| { | ||
| m_x += other.m_x; | ||
| m_y += other.m_y; | ||
| m_z += other.m_z; | ||
| m_index += other.m_index; | ||
| return *this; | ||
| } | ||
|
|
||
| TrackStart TrackStart::operator-(TrackStart const& other) const | ||
| { | ||
| return TrackStart(m_x - other.m_x, m_y - other.m_y, m_z - other.m_z, m_index - other.m_index); | ||
| } | ||
|
|
||
| std::ostream& operator<<(std::ostream& os, TrackStart const& track) | ||
| { | ||
| os << "TrackStart{" << track.getX() << ", " << track.getY() << ", " << track.getZ() << "}"; | ||
| return os; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| //A TrackStart is a 3-vector of position components. | ||
| //This is a simple test data product for demonstrating the features of FORM. | ||
|
|
||
| #include <iostream> | ||
|
|
||
| #ifndef TRACKSTART_HPP | ||
| #define TRACKSTART_HPP | ||
|
|
||
| class TrackStart { | ||
| public: | ||
| TrackStart(); | ||
| TrackStart(float x, float y, float z, int index); | ||
| ~TrackStart() = default; | ||
|
|
||
| float getX() const; | ||
| float getY() const; | ||
| float getZ() const; | ||
| int getIndex() const; | ||
|
|
||
| void setX(float x); | ||
| void setY(float y); | ||
| void setZ(float z); | ||
| void setIndex(int index); | ||
|
|
||
| TrackStart operator+(TrackStart const& other) const; | ||
| TrackStart& operator+=(TrackStart const& other); | ||
| TrackStart operator-(TrackStart const& other) const; | ||
|
|
||
| private: | ||
| float m_x; | ||
| float m_y; | ||
| float m_z; | ||
|
|
||
| int m_index; | ||
| }; | ||
|
|
||
| std::ostream& operator<<(std::ostream& os, TrackStart const& track); | ||
|
|
||
| #endif //TRACKSTART_HPP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| //Part two of schema evolution unit test: can we build a program against a new dictionary for the same product that reads the old product and gets back the correct values? | ||
|
|
||
| #include "test/form/data_products/extra_member/track_start.hpp" | ||
| #include "test/form/test_utils.hpp" | ||
|
|
||
| #include <fstream> | ||
| #include <iostream> | ||
| #include <vector> | ||
|
|
||
| using namespace form::test; | ||
|
|
||
| int main(int const argc, char const** argv) | ||
| { | ||
| int const technology = getTechnology(argc, argv); | ||
| if (technology < 0) | ||
| return 1; | ||
|
|
||
| auto const& [prods] = read<std::vector<TrackStart>>(technology); | ||
| std::ofstream outFile("form_root_schema_read_log.txt"); | ||
| for (auto const& prod : *prods) | ||
| outFile << prod << std::endl; | ||
|
|
||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| //Schema evolution test component: write old version of a data product to disk | ||
|
|
||
| #include "test/form/data_products/track_start.hpp" | ||
| #include "test/form/test_utils.hpp" | ||
| #include "test/form/toy_tracker.hpp" | ||
|
|
||
| #include <fstream> | ||
| #include <iostream> | ||
| #include <vector> | ||
|
|
||
| using namespace form::test; | ||
|
|
||
| int main(int const argc, char const** argv) | ||
| { | ||
| int const technology = getTechnology(argc, argv); | ||
| if (technology < 0) | ||
| return 1; | ||
|
|
||
| ToyTracker tracker(4 * 1024); | ||
| std::vector<TrackStart> const prods = tracker(); | ||
|
|
||
| std::ofstream outFile("form_root_schema_write_log.txt"); | ||
| for (auto const& prod : prods) | ||
| outFile << prod << std::endl; | ||
|
|
||
| write(technology, prods); | ||
|
|
||
| return 0; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should it be
#include "test/form/data_products/extra_member/track_start.hpp"here?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.
No, this is intentional.
form_root_schema_write_testwrites the old, non-extra_member version of the data product to a file.form_root_schema_read_testreads the old product with only the new product's definition. ROOT should automatically fill in the in-memory new product with as much of the old product's data as possible.