Project
Loading...
Searching...
No Matches
test_TableSpawner.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#include <catch_amalgamated.hpp>
14
17
18using namespace o2::framework;
19using namespace o2::soa;
20using namespace o2::aod;
21
22namespace o2::aod
23{
24namespace test
25{
26DECLARE_SOA_COLUMN(X, x, float);
27DECLARE_SOA_COLUMN(Y, y, float);
28DECLARE_SOA_COLUMN(Z, z, float);
29DECLARE_SOA_EXPRESSION_COLUMN(Rsq, rsq, float, test::x* test::x + test::y * test::y + test::z * test::z);
30DECLARE_SOA_EXPRESSION_COLUMN(Sin, sin, float, test::x / nsqrt(test::x * test::x + test::y * test::y));
31
32DECLARE_SOA_CONFIGURABLE_EXPRESSION_COLUMN(Cfg, cfg, float, "configurable");
33} // namespace test
34
35DECLARE_SOA_TABLE(Points, "AOD", "PTSNG", test::X, test::Y, test::Z);
36DECLARE_SOA_EXTENDED_TABLE(ExPoints, Points, "EXPTSNG", 0, test::Rsq, test::Sin);
37
38DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE(ExcPoints, Points, "CFGPTS", test::Cfg);
39} // namespace o2::aod
40
41TEST_CASE("TestTableSpawner")
42{
44 auto w1 = b1.cursor<Points>();
45
46 for (auto i = 1; i < 10; ++i) {
47 w1(0, i * 2., i * 3., i * 4.);
48 }
49
50 auto t1 = b1.finalize();
51 Points st1{t1};
52
53 auto expoints_a = o2::soa::Extend<o2::aod::Points, test::Rsq, test::Sin>(st1);
55 auto extension = ExPointsExtension{o2::framework::spawner<o2::aod::Hash<"EXPTSNG/0"_h>>(t1, o2::aod::Hash<"ExPoints"_h>::str, s.projectors.data(), s.projector, s.schema)};
56 auto expoints = ExPoints{{t1, extension.asArrowTable()}, 0};
57
58 REQUIRE(expoints_a.size() == 9);
59 REQUIRE(extension.size() == 9);
60 REQUIRE(expoints.size() == 9);
61
62 auto rex = extension.begin();
63 auto rexp = expoints.begin();
64 auto rexp_a = expoints_a.begin();
65
66 for (auto i = 1; i < 10; ++i) {
67 float rsq = i * i * 4 + i * i * 9 + i * i * 16;
68 float sin = i * 2 / std::sqrt(i * i * 4 + i * i * 9);
69 REQUIRE(rexp_a.rsq() == rsq);
70 REQUIRE(rex.rsq() == rsq);
71 REQUIRE(rexp.rsq() == rsq);
72 REQUIRE(rexp_a.sin() == sin);
73 REQUIRE(rex.sin() == sin);
74 REQUIRE(rexp.sin() == sin);
75 ++rex;
76 ++rexp;
77 ++rexp_a;
78 }
79
80 Defines<ExcPoints> excpts;
81 excpts.projectors[0] = test::x * test::x + test::y * test::y + test::z * test::z;
82
83 auto extension_2 = ExcPointsCfgExtension{o2::framework::spawner<o2::aod::Hash<"EXCFGPTS/0"_h>>({t1}, o2::aod::Hash<"ExcPoints"_h>::str, excpts.projectors.data(), excpts.projector, excpts.schema)};
84 auto excpoints = ExcPoints{{t1, extension_2.asArrowTable()}, 0};
85
86 rex = extension.begin();
87 auto rex_2 = extension_2.begin();
88 auto rexcp = excpoints.begin();
89
90 for (auto i = 1; i < 10; ++i) {
91 float rsq = i * i * 4 + i * i * 9 + i * i * 16;
92 REQUIRE(rex.rsq() == rsq);
93 REQUIRE(rex_2.cfg() == rsq);
94 REQUIRE(rexcp.cfg() == rsq);
95 ++rex;
96 ++rex_2;
97 ++rexcp;
98 }
99}
#define DECLARE_SOA_TABLE(_Name_, _Origin_, _Desc_,...)
Definition ASoA.h:3093
#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE(_Name_, _Table_, _Description_,...)
Definition ASoA.h:3165
#define DECLARE_SOA_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Expression_)
Definition ASoA.h:2397
#define DECLARE_SOA_COLUMN(_Name_, _Getter_, _Type_)
Definition ASoA.h:2323
#define DECLARE_SOA_CONFIGURABLE_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Label_)
Definition ASoA.h:2402
#define DECLARE_SOA_EXTENDED_TABLE(_Name_, _Table_, _Description_, _Version_,...)
Definition ASoA.h:3135
int32_t i
const GPUTPCGMMerger::trackCluster & b1
GLint GLenum GLint x
Definition glcorearb.h:403
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
Definition glcorearb.h:5034
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
auto spawner(std::shared_ptr< arrow::Table > const &fullTable, const char *name, o2::framework::expressions::Projector *projectors, std::shared_ptr< gandiva::Projector > &projector, std::shared_ptr< arrow::Schema > const &schema)
Expression-based column generator to materialize columns.
TEST_CASE("test_prepareArguments")
FIXME: do not use data model tables.
std::array< o2::framework::expressions::Projector, N > projectors
std::shared_ptr< arrow::Schema > schema
std::shared_ptr< gandiva::Projector > projector
const std::string str