From 9329c4600ce41a9fab91247ca5aa8d6fbe47a10d Mon Sep 17 00:00:00 2001 From: Luc Rancourt Date: Thu, 19 Oct 2023 10:35:17 +0200 Subject: [PATCH] Remove default constructor argument for FieldInfo. This has caused misuse when refactoring tests and should be avoided. --- TYPE: NO_HISTORY DESC: Remove default constructor argument for FieldInfo. --- test/src/test-cppapi-aggregates.cc | 45 ++++- test/support/src/helper_type.h | 129 +++++++++++++ .../sm/query/readers/aggregators/field_info.h | 2 +- .../aggregators/test/bench_aggregators.cc | 4 +- .../test/compile_aggregators_main.cc | 172 +++++++++--------- .../test/unit_aggregate_with_count.cc | 6 +- .../aggregators/test/unit_aggregators.cc | 56 +++--- 7 files changed, 295 insertions(+), 119 deletions(-) create mode 100644 test/support/src/helper_type.h diff --git a/test/src/test-cppapi-aggregates.cc b/test/src/test-cppapi-aggregates.cc index 9be386a0d54..8f34d0af70a 100644 --- a/test/src/test-cppapi-aggregates.cc +++ b/test/src/test-cppapi-aggregates.cc @@ -39,6 +39,7 @@ #include "tiledb/sm/query/readers/aggregators/min_max_aggregator.h" #include "tiledb/sm/query/readers/aggregators/sum_aggregator.h" +#include #include using namespace tiledb; @@ -1395,7 +1396,11 @@ TEMPLATE_LIST_TEST_CASE_METHOD( "Mean", std::make_shared>( tiledb::sm::FieldInfo( - "a1", false, CppAggregatesFx::nullable_, 1))); + "a1", + false, + CppAggregatesFx::nullable_, + 1, + tdb_type()))); CppAggregatesFx::set_ranges_and_condition_if_needed( array, query, false); @@ -1798,7 +1803,8 @@ TEMPLATE_LIST_TEST_CASE_METHOD( "a1", false, CppAggregatesFx::nullable_, - cell_val_num))); + cell_val_num, + tdb_type()))); CppAggregatesFx::set_ranges_and_condition_if_needed( array, query, false); @@ -1892,7 +1898,11 @@ TEST_CASE_METHOD( "NullCount", std::make_shared( tiledb::sm::FieldInfo( - "a1", true, nullable_, TILEDB_VAR_NUM))); + "a1", + true, + nullable_, + TILEDB_VAR_NUM, + tdb_type()))); set_ranges_and_condition_if_needed(array, query, true); @@ -1987,7 +1997,12 @@ TEST_CASE_METHOD( query.ptr()->query_->add_aggregator_to_default_channel( "NullCount", std::make_shared( - tiledb::sm::FieldInfo("a1", true, nullable_, TILEDB_VAR_NUM))); + tiledb::sm::FieldInfo( + "a1", + true, + nullable_, + TILEDB_VAR_NUM, + tdb_type()))); // Add another aggregator on the second attribute. We will make the // first attribute get a var size overflow, which should not impact the @@ -1996,7 +2011,12 @@ TEST_CASE_METHOD( query.ptr()->query_->add_aggregator_to_default_channel( "NullCount2", std::make_shared( - tiledb::sm::FieldInfo("a2", true, nullable_, TILEDB_VAR_NUM))); + tiledb::sm::FieldInfo( + "a2", + true, + nullable_, + TILEDB_VAR_NUM, + tdb_type()))); set_ranges_and_condition_if_needed(array, query, true); @@ -2125,7 +2145,12 @@ TEST_CASE_METHOD( query.ptr()->query_->add_aggregator_to_default_channel( "NullCount", std::make_shared( - tiledb::sm::FieldInfo("a1", true, nullable_, TILEDB_VAR_NUM))); + tiledb::sm::FieldInfo( + "a1", + true, + nullable_, + TILEDB_VAR_NUM, + tdb_type()))); // Add another aggregator on the second attribute. We will make this // attribute get a var size overflow, which should impact the result of @@ -2133,7 +2158,12 @@ TEST_CASE_METHOD( query.ptr()->query_->add_aggregator_to_default_channel( "NullCount2", std::make_shared( - tiledb::sm::FieldInfo("a2", true, nullable_, TILEDB_VAR_NUM))); + tiledb::sm::FieldInfo( + "a2", + true, + nullable_, + TILEDB_VAR_NUM, + tdb_type()))); set_ranges_and_condition_if_needed(array, query, true); @@ -2198,6 +2228,7 @@ TEMPLATE_LIST_TEST_CASE_METHOD( for (tiledb_layout_t layout : CppAggregatesFx::layout_values_) { CppAggregatesFx::layout_ = layout; Query query(CppAggregatesFx::ctx_, array, TILEDB_READ); + // Add a count aggregator to the query. We add both sum and count as // they are processed separately in the dense case. QueryChannel default_channel = diff --git a/test/support/src/helper_type.h b/test/support/src/helper_type.h new file mode 100644 index 00000000000..67138936a68 --- /dev/null +++ b/test/support/src/helper_type.h @@ -0,0 +1,129 @@ +/** + * @file type.h + * + * @section LICENSE + * + * The MIT License + * + * @copyright Copyright (c) 2023 TileDB, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @section DESCRIPTION + * + * This defines TileDB datatypes. + */ + +#ifndef TILEDB_TEST_TYPE_H +#define TILEDB_TEST_TYPE_H + +namespace tiledb::test { + +using Datatype = tiledb::sm::Datatype; + +/** + * Convert a type into a tiledb::sm::Datatype. The default for all copyable + * types is char. + */ +template +struct type_to_tiledb { + using type = char; + static const Datatype tiledb_type = Datatype::STRING_ASCII; +}; + +template <> +struct type_to_tiledb { + using type = std::byte; + static const Datatype tiledb_type = Datatype::BLOB; +}; + +template <> +struct type_to_tiledb { + using type = bool; + static const Datatype tiledb_type = Datatype::BOOL; +}; + +template <> +struct type_to_tiledb { + using type = int8_t; + static const Datatype tiledb_type = Datatype::INT8; +}; + +template <> +struct type_to_tiledb { + using type = uint8_t; + static const Datatype tiledb_type = Datatype::UINT8; +}; + +template <> +struct type_to_tiledb { + using type = int16_t; + static const Datatype tiledb_type = Datatype::INT16; +}; + +template <> +struct type_to_tiledb { + using type = uint16_t; + static const Datatype tiledb_type = Datatype::UINT16; +}; + +template <> +struct type_to_tiledb { + using type = int32_t; + static const Datatype tiledb_type = Datatype::INT32; +}; + +template <> +struct type_to_tiledb { + using type = uint32_t; + static const Datatype tiledb_type = Datatype::UINT32; +}; + +template <> +struct type_to_tiledb { + using type = int64_t; + static const Datatype tiledb_type = Datatype::INT64; +}; + +template <> +struct type_to_tiledb { + using type = uint64_t; + static const Datatype tiledb_type = Datatype::UINT64; +}; + +template <> +struct type_to_tiledb { + using type = float; + static const Datatype tiledb_type = Datatype::FLOAT32; +}; + +template <> +struct type_to_tiledb { + using type = double; + static const Datatype tiledb_type = Datatype::FLOAT64; +}; + +template +Datatype tdb_type() { + return type_to_tiledb::tiledb_type; +} + +} // namespace tiledb::test + +#endif // TILEDB_TEST_TYPE_H diff --git a/tiledb/sm/query/readers/aggregators/field_info.h b/tiledb/sm/query/readers/aggregators/field_info.h index 1ee11ba9dd7..0a6d6071736 100644 --- a/tiledb/sm/query/readers/aggregators/field_info.h +++ b/tiledb/sm/query/readers/aggregators/field_info.h @@ -67,7 +67,7 @@ class FieldInfo { const bool var_sized, const bool is_nullable, const unsigned cell_val_num, - const Datatype type = Datatype::UINT8) + const Datatype type) : name_(name) , var_sized_(var_sized) , is_nullable_(is_nullable) diff --git a/tiledb/sm/query/readers/aggregators/test/bench_aggregators.cc b/tiledb/sm/query/readers/aggregators/test/bench_aggregators.cc index 16e0a7d133b..ffa2c3fa4f1 100644 --- a/tiledb/sm/query/readers/aggregators/test/bench_aggregators.cc +++ b/tiledb/sm/query/readers/aggregators/test/bench_aggregators.cc @@ -38,9 +38,11 @@ #include "tiledb/sm/query/readers/aggregators/sum_type.h" #include "tiledb/sm/query/readers/aggregators/validity_policies.h" +#include #include using namespace tiledb::sm; +using namespace tiledb::test; const uint64_t num_cells = 10 * 1024 * 1024; @@ -156,7 +158,7 @@ void run_bench() { << ", Segmented: " << (segmented ? "true" : "false")) { BENCHMARK("Bench") { AggregateWithCount aggregator( - FieldInfo("a1", var_sized, nullable, 1)); + FieldInfo("a1", var_sized, nullable, 1, tdb_type())); for (uint64_t s = 0; s < num_cells; s += increment) { AggregateBuffer input_data{ s, diff --git a/tiledb/sm/query/readers/aggregators/test/compile_aggregators_main.cc b/tiledb/sm/query/readers/aggregators/test/compile_aggregators_main.cc index ab526e51139..441c5c5de6b 100644 --- a/tiledb/sm/query/readers/aggregators/test/compile_aggregators_main.cc +++ b/tiledb/sm/query/readers/aggregators/test/compile_aggregators_main.cc @@ -35,96 +35,96 @@ int main() { tiledb::sm::CountAggregator(); - tiledb::sm::MeanAggregator( - tiledb::sm::FieldInfo("Mean", false, false, 1)); - tiledb::sm::MeanAggregator( - tiledb::sm::FieldInfo("Mean", false, false, 1)); - tiledb::sm::MeanAggregator( - tiledb::sm::FieldInfo("Mean", false, false, 1)); - tiledb::sm::MeanAggregator( - tiledb::sm::FieldInfo("Mean", false, false, 1)); - tiledb::sm::MeanAggregator( - tiledb::sm::FieldInfo("Mean", false, false, 1)); - tiledb::sm::MeanAggregator( - tiledb::sm::FieldInfo("Mean", false, false, 1)); - tiledb::sm::MeanAggregator( - tiledb::sm::FieldInfo("Mean", false, false, 1)); - tiledb::sm::MeanAggregator( - tiledb::sm::FieldInfo("Mean", false, false, 1)); - tiledb::sm::MeanAggregator( - tiledb::sm::FieldInfo("Mean", false, false, 1)); - tiledb::sm::MeanAggregator( - tiledb::sm::FieldInfo("Mean", false, false, 1)); + tiledb::sm::MeanAggregator(tiledb::sm::FieldInfo( + "Mean", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MeanAggregator(tiledb::sm::FieldInfo( + "Mean", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MeanAggregator(tiledb::sm::FieldInfo( + "Mean", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MeanAggregator(tiledb::sm::FieldInfo( + "Mean", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MeanAggregator(tiledb::sm::FieldInfo( + "Mean", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MeanAggregator(tiledb::sm::FieldInfo( + "Mean", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MeanAggregator(tiledb::sm::FieldInfo( + "Mean", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MeanAggregator(tiledb::sm::FieldInfo( + "Mean", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MeanAggregator(tiledb::sm::FieldInfo( + "Mean", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MeanAggregator(tiledb::sm::FieldInfo( + "Mean", false, false, 1, tiledb::sm::Datatype::UINT8)); - tiledb::sm::MinAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MinAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MinAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MinAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MinAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MinAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MinAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MinAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MinAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MinAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MinAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); + tiledb::sm::MinAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MinAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MinAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MinAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MinAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MinAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MinAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MinAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MinAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MinAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MinAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); - tiledb::sm::MaxAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MaxAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MaxAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MaxAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MaxAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MaxAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MaxAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MaxAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MaxAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MaxAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); - tiledb::sm::MaxAggregator( - tiledb::sm::FieldInfo("MinMax", false, false, 1)); + tiledb::sm::MaxAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MaxAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MaxAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MaxAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MaxAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MaxAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MaxAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MaxAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MaxAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MaxAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::MaxAggregator(tiledb::sm::FieldInfo( + "MinMax", false, false, 1, tiledb::sm::Datatype::UINT8)); - tiledb::sm::NullCountAggregator( - tiledb::sm::FieldInfo("NullCount", false, false, 1)); + tiledb::sm::NullCountAggregator(tiledb::sm::FieldInfo( + "NullCount", false, false, 1, tiledb::sm::Datatype::UINT8)); - tiledb::sm::SumAggregator( - tiledb::sm::FieldInfo("Sum", false, false, 1)); - tiledb::sm::SumAggregator( - tiledb::sm::FieldInfo("Sum", false, false, 1)); - tiledb::sm::SumAggregator( - tiledb::sm::FieldInfo("Sum", false, false, 1)); - tiledb::sm::SumAggregator( - tiledb::sm::FieldInfo("Sum", false, false, 1)); - tiledb::sm::SumAggregator( - tiledb::sm::FieldInfo("Sum", false, false, 1)); - tiledb::sm::SumAggregator( - tiledb::sm::FieldInfo("Sum", false, false, 1)); - tiledb::sm::SumAggregator( - tiledb::sm::FieldInfo("Sum", false, false, 1)); - tiledb::sm::SumAggregator( - tiledb::sm::FieldInfo("Sum", false, false, 1)); - tiledb::sm::SumAggregator( - tiledb::sm::FieldInfo("Sum", false, false, 1)); - tiledb::sm::SumAggregator( - tiledb::sm::FieldInfo("Sum", false, false, 1)); + tiledb::sm::SumAggregator(tiledb::sm::FieldInfo( + "Sum", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::SumAggregator(tiledb::sm::FieldInfo( + "Sum", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::SumAggregator(tiledb::sm::FieldInfo( + "Sum", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::SumAggregator(tiledb::sm::FieldInfo( + "Sum", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::SumAggregator(tiledb::sm::FieldInfo( + "Sum", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::SumAggregator(tiledb::sm::FieldInfo( + "Sum", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::SumAggregator(tiledb::sm::FieldInfo( + "Sum", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::SumAggregator(tiledb::sm::FieldInfo( + "Sum", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::SumAggregator(tiledb::sm::FieldInfo( + "Sum", false, false, 1, tiledb::sm::Datatype::UINT8)); + tiledb::sm::SumAggregator(tiledb::sm::FieldInfo( + "Sum", false, false, 1, tiledb::sm::Datatype::UINT8)); return 0; } \ No newline at end of file diff --git a/tiledb/sm/query/readers/aggregators/test/unit_aggregate_with_count.cc b/tiledb/sm/query/readers/aggregators/test/unit_aggregate_with_count.cc index c4474928ebe..e3a569ba282 100644 --- a/tiledb/sm/query/readers/aggregators/test/unit_aggregate_with_count.cc +++ b/tiledb/sm/query/readers/aggregators/test/unit_aggregate_with_count.cc @@ -37,9 +37,11 @@ #include "tiledb/sm/query/readers/aggregators/sum_type.h" #include "tiledb/sm/query/readers/aggregators/validity_policies.h" +#include #include using namespace tiledb::sm; +using namespace tiledb::test; typedef tuple< uint8_t, @@ -59,9 +61,9 @@ TEMPLATE_LIST_TEST_CASE( FixedTypesUnderTest) { typedef TestType T; AggregateWithCount::sum_type, SafeSum, NonNull> - aggregator(FieldInfo("a1", false, false, 1)); + aggregator(FieldInfo("a1", false, false, 1, tdb_type())); AggregateWithCount::sum_type, SafeSum, NonNull> - aggregator_nullable(FieldInfo("a2", false, true, 1)); + aggregator_nullable(FieldInfo("a2", false, true, 1, tdb_type())); std::vector fixed_data = {1, 2, 3, 4, 5, 5, 4, 3, 2, 1}; std::vector validity_data = {0, 0, 1, 0, 1, 0, 1, 0, 1, 0}; diff --git a/tiledb/sm/query/readers/aggregators/test/unit_aggregators.cc b/tiledb/sm/query/readers/aggregators/test/unit_aggregators.cc index 354f8905652..7973d56fa00 100644 --- a/tiledb/sm/query/readers/aggregators/test/unit_aggregators.cc +++ b/tiledb/sm/query/readers/aggregators/test/unit_aggregators.cc @@ -38,9 +38,11 @@ #include "tiledb/sm/query/readers/aggregators/min_max_aggregator.h" #include "tiledb/sm/query/readers/aggregators/sum_aggregator.h" +#include #include using namespace tiledb::sm; +using namespace tiledb::test; typedef tuple< SumAggregator, @@ -53,14 +55,14 @@ TEMPLATE_LIST_TEST_CASE( AggUnderTestConstructor) { SECTION("Var size") { CHECK_THROWS_WITH( - TestType(FieldInfo("a1", true, false, 1)), + TestType(FieldInfo("a1", true, false, 1, Datatype::UINT8)), "InputFieldValidator: Aggregate is not supported for var sized " "non-string fields."); } SECTION("Invalid cell val num") { CHECK_THROWS_WITH( - TestType(FieldInfo("a1", false, false, 2)), + TestType(FieldInfo("a1", false, false, 2, Datatype::UINT8)), "InputFieldValidator: Aggregate is not supported for non-string fields " "with cell_val_num greater than one."); } @@ -71,7 +73,7 @@ TEST_CASE( "[null-count-aggregator][constructor]") { SECTION("Non nullable") { CHECK_THROWS_WITH( - NullCountAggregator(FieldInfo("a1", false, false, 1)), + NullCountAggregator(FieldInfo("a1", false, false, 1, Datatype::UINT8)), "InputFieldValidator: Aggregate must only be requested for nullable " "fields."); } @@ -96,11 +98,13 @@ typedef tuple< AggUnderTest; TEMPLATE_LIST_TEST_CASE( "Aggregator: var sized", "[aggregator][var-sized]", AggUnderTest) { - auto aggregator{make_aggregator(FieldInfo("a1", false, true, 1))}; + auto aggregator{make_aggregator( + FieldInfo("a1", false, true, 1, Datatype::UINT8))}; CHECK(aggregator.aggregation_var_sized() == false); if constexpr (std::is_same>::value) { - MinAggregator aggregator2(FieldInfo("a1", true, false, 1)); + MinAggregator aggregator2( + FieldInfo("a1", true, false, 1, Datatype::UINT8)); CHECK(aggregator2.aggregation_var_sized() == true); } } @@ -109,7 +113,8 @@ TEMPLATE_LIST_TEST_CASE( "Aggregators: need recompute", "[aggregators][need-recompute]", AggUnderTest) { - auto aggregator{make_aggregator(FieldInfo("a1", false, true, 1))}; + auto aggregator{make_aggregator( + FieldInfo("a1", false, true, 1, Datatype::UINT8))}; bool need_recompute = true; if constexpr (std::is_same>::value) { need_recompute = false; @@ -119,7 +124,8 @@ TEMPLATE_LIST_TEST_CASE( TEMPLATE_LIST_TEST_CASE( "Aggregators: field name", "[aggregator][field-name]", AggUnderTest) { - auto aggregator{make_aggregator(FieldInfo("a1", false, true, 1))}; + auto aggregator{make_aggregator( + FieldInfo("a1", false, true, 1, Datatype::UINT8))}; if (std::is_same::value) { CHECK(aggregator.field_name() == constants::count_of_rows); } else { @@ -136,14 +142,15 @@ TEMPLATE_LIST_TEST_CASE( "Aggregators: Validate buffer", "[aggregators][validate-buffer]", AggUnderTestValidateBuffer) { - TestType aggregator(FieldInfo("a1", false, false, 1)); - TestType aggregator_nullable(FieldInfo("a2", false, true, 1)); + TestType aggregator(FieldInfo("a1", false, false, 1, Datatype::UINT8)); + TestType aggregator_nullable( + FieldInfo("a2", false, true, 1, Datatype::UINT8)); MinAggregator aggregator_var( - FieldInfo("a1", true, false, constants::var_num)); + FieldInfo("a1", true, false, constants::var_num, Datatype::UINT8)); MinAggregator aggregator_var_wrong_cvn( - FieldInfo("a1", true, false, 11)); + FieldInfo("a1", true, false, 11, Datatype::UINT8)); MinAggregator aggregator_fixed_string( - FieldInfo("a1", false, false, 5)); + FieldInfo("a1", false, false, 5, Datatype::UINT8)); std::unordered_map buffers; @@ -318,7 +325,8 @@ TEMPLATE_LIST_TEST_CASE( "Aggregators: Validate buffer count", "[aggregators][validate-buffer]", AggUnderTestValidateBufferCount) { - auto aggregator{make_aggregator(FieldInfo("a1", false, true, 1))}; + auto aggregator{make_aggregator( + FieldInfo("a1", false, true, 1, Datatype::UINT8))}; std::unordered_map buffers; SECTION("Doesn't exist") { @@ -437,12 +445,12 @@ void basic_aggregation_test(std::vector expected_results) { if constexpr (std::is_same::value) { aggregator.emplace(); } else { - aggregator.emplace(FieldInfo("a1", false, false, 1)); + aggregator.emplace(FieldInfo("a1", false, false, 1, tdb_type())); } } - auto aggregator_nullable{ - make_aggregator(FieldInfo("a1", false, true, 1))}; + auto aggregator_nullable{make_aggregator( + FieldInfo("a1", false, true, 1, tdb_type()))}; std::unordered_map buffers; @@ -702,7 +710,8 @@ TEMPLATE_LIST_TEST_CASE( TEST_CASE( "Sum aggregator: signed overflow", "[sum-aggregator][signed-overflow]") { - SumAggregator aggregator(FieldInfo("a1", false, false, 1)); + SumAggregator aggregator( + FieldInfo("a1", false, false, 1, tdb_type())); std::unordered_map buffers; @@ -786,7 +795,8 @@ TEST_CASE( TEST_CASE( "Sum aggregator: unsigned overflow", "[sum-aggregator][unsigned-overflow]") { - SumAggregator aggregator(FieldInfo("a1", false, false, 1)); + SumAggregator aggregator( + FieldInfo("a1", false, false, 1, tdb_type())); std::unordered_map buffers; @@ -824,7 +834,7 @@ TEMPLATE_LIST_TEST_CASE( "Sum aggregator: double overflow", "[sum-aggregator][double-overflow]", DoubleAggUnderTest) { - TestType aggregator(FieldInfo("a1", false, false, 1)); + TestType aggregator(FieldInfo("a1", false, false, 1, tdb_type())); std::unordered_map buffers; @@ -900,11 +910,12 @@ void basic_string_aggregation_test(std::vector expected_results) { // Optionally make the aggregator for non nullable values. optional aggregator; if constexpr (!std::is_same::value) { - aggregator.emplace(FieldInfo("a1", true, false, constants::var_num)); + aggregator.emplace(FieldInfo( + "a1", true, false, constants::var_num, tdb_type())); } AGGREGATOR aggregator_nullable( - FieldInfo("a2", true, true, constants::var_num)); + FieldInfo("a2", true, true, constants::var_num, tdb_type())); std::unordered_map buffers; @@ -1111,7 +1122,8 @@ TEST_CASE( TEST_CASE( "NullCount aggregator: output datatype", "[null-count-aggregator][output-datatype]") { - NullCountAggregator aggregator{FieldInfo{"a1", false, true, 1}}; + NullCountAggregator aggregator{ + FieldInfo{"a1", false, true, 1, Datatype::UINT8}}; CHECK(aggregator.output_datatype() == Datatype::UINT64); }