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 std::shared_ptr<gandiva::Projector> projector = nullptr;
54
55 auto expoints_a = o2::soa::Extend<o2::aod::Points, test::Rsq, test::Sin>(st1);
56 auto extension = ExPointsExtension{o2::framework::spawner<o2::aod::Hash<"EXPTSNG/0"_h>>(t1, o2::aod::Hash<"ExPoints"_h>::str, projector)};
57 auto expoints = ExPoints{{t1, extension.asArrowTable()}, 0};
58
59 REQUIRE(expoints_a.size() == 9);
60 REQUIRE(extension.size() == 9);
61 REQUIRE(expoints.size() == 9);
62
63 auto rex = extension.begin();
64 auto rexp = expoints.begin();
65 auto rexp_a = expoints_a.begin();
66
67 for (auto i = 1; i < 10; ++i) {
68 float rsq = i * i * 4 + i * i * 9 + i * i * 16;
69 float sin = i * 2 / std::sqrt(i * i * 4 + i * i * 9);
70 REQUIRE(rexp_a.rsq() == rsq);
71 REQUIRE(rex.rsq() == rsq);
72 REQUIRE(rexp.rsq() == rsq);
73 REQUIRE(rexp_a.sin() == sin);
74 REQUIRE(rex.sin() == sin);
75 REQUIRE(rexp.sin() == sin);
76 ++rex;
77 ++rexp;
78 ++rexp_a;
79 }
80
81 Defines<ExcPoints> excpts;
82 excpts.projectors[0] = test::x * test::x + test::y * test::y + test::z * test::z;
83
84 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)};
85 auto excpoints = ExcPoints{{t1, extension_2.asArrowTable()}, 0};
86
87 rex = extension.begin();
88 auto rex_2 = extension_2.begin();
89 auto rexcp = excpoints.begin();
90
91 for (auto i = 1; i < 10; ++i) {
92 float rsq = i * i * 4 + i * i * 9 + i * i * 16;
93 REQUIRE(rex.rsq() == rsq);
94 REQUIRE(rex_2.cfg() == rsq);
95 REQUIRE(rexcp.cfg() == rsq);
96 ++rex;
97 ++rex_2;
98 ++rexcp;
99 }
100}
#define DECLARE_SOA_TABLE(_Name_, _Origin_, _Desc_,...)
Definition ASoA.h:3092
#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE(_Name_, _Table_, _Description_,...)
Definition ASoA.h:3164
#define DECLARE_SOA_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Expression_)
Definition ASoA.h:2396
#define DECLARE_SOA_COLUMN(_Name_, _Getter_, _Type_)
Definition ASoA.h:2322
#define DECLARE_SOA_CONFIGURABLE_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Label_)
Definition ASoA.h:2401
#define DECLARE_SOA_EXTENDED_TABLE(_Name_, _Table_, _Description_, _Version_,...)
Definition ASoA.h:3134
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
TEST_CASE("test_prepareArguments")
auto spawner(std::vector< std::shared_ptr< arrow::Table > > &&tables, const char *name, o2::framework::expressions::Projector *projectors, std::shared_ptr< gandiva::Projector > &projector)
Expression-based column generator to materialize columns.
FIXME: do not use data model tables.
std::array< o2::framework::expressions::Projector, N > projectors
std::shared_ptr< gandiva::Projector > projector
const std::string str