diff --git a/test/src/test-cppapi-aggregates.cc b/test/src/test-cppapi-aggregates.cc index 9be386a0d547..909320ffd265 100644 --- a/test/src/test-cppapi-aggregates.cc +++ b/test/src/test-cppapi-aggregates.cc @@ -35,7 +35,6 @@ #include "tiledb/sm/cpp_api/tiledb" #include "tiledb/sm/cpp_api/tiledb_experimental" #include "tiledb/sm/query/readers/aggregators/count_aggregator.h" -#include "tiledb/sm/query/readers/aggregators/mean_aggregator.h" #include "tiledb/sm/query/readers/aggregators/min_max_aggregator.h" #include "tiledb/sm/query/readers/aggregators/sum_aggregator.h" diff --git a/tiledb/CMakeLists.txt b/tiledb/CMakeLists.txt index 07acc6d27cfc..641d23810d9b 100644 --- a/tiledb/CMakeLists.txt +++ b/tiledb/CMakeLists.txt @@ -253,7 +253,6 @@ set(TILEDB_CORE_SOURCES ${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/query/query_condition.cc ${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/query/query_remote_buffer_storage.cc ${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/query/readers/aggregators/count_aggregator.cc - ${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/query/readers/aggregators/mean_aggregator.cc ${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/query/readers/aggregators/min_max_aggregator.cc ${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/query/readers/aggregators/operation.cc ${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/query/readers/aggregators/output_buffer_validator.cc diff --git a/tiledb/sm/query/query.h b/tiledb/sm/query/query.h index 49fb0d9f7e37..54759f9d8c70 100644 --- a/tiledb/sm/query/query.h +++ b/tiledb/sm/query/query.h @@ -743,14 +743,6 @@ class Query { default_channel_aggregates_.emplace(output_field_name, aggregator); } - /** - * Get all aggregates from the default channel. - */ - std::unordered_map> - get_default_channel_aggregates() { - return default_channel_aggregates_; - } - /** Returns an aggregate based on the output field. */ std::optional> get_aggregate( std::string output_field_name) const; diff --git a/tiledb/sm/query/readers/aggregators/CMakeLists.txt b/tiledb/sm/query/readers/aggregators/CMakeLists.txt index d4df7081b37b..291f96696252 100644 --- a/tiledb/sm/query/readers/aggregators/CMakeLists.txt +++ b/tiledb/sm/query/readers/aggregators/CMakeLists.txt @@ -31,7 +31,7 @@ include(object_library) # `aggregators` object library # commence(object_library aggregators) - this_target_sources(count_aggregator.cc mean_aggregator.cc min_max_aggregator.cc operation.cc output_buffer_validator.cc safe_sum.cc sum_aggregator.cc) + this_target_sources(count_aggregator.cc min_max_aggregator.cc operation.cc output_buffer_validator.cc safe_sum.cc sum_aggregator.cc) this_target_object_libraries(baseline array_schema) conclude(object_library) diff --git a/tiledb/sm/query/readers/aggregators/aggregate_with_count.h b/tiledb/sm/query/readers/aggregators/aggregate_with_count.h index 082d969767df..70ed41adccd5 100644 --- a/tiledb/sm/query/readers/aggregators/aggregate_with_count.h +++ b/tiledb/sm/query/readers/aggregators/aggregate_with_count.h @@ -28,8 +28,6 @@ * @section DESCRIPTION * * This file defines class AggregateWithCount. - * - * TODO: Add more benchmark coverage for this class (sc-33758). */ #ifndef TILEDB_AGGREGATE_WITH_COUNT_H diff --git a/tiledb/sm/query/readers/aggregators/mean_aggregator.cc b/tiledb/sm/query/readers/aggregators/mean_aggregator.cc deleted file mode 100644 index 4f4d845630b3..000000000000 --- a/tiledb/sm/query/readers/aggregators/mean_aggregator.cc +++ /dev/null @@ -1,153 +0,0 @@ -/** - * @file mean_aggregator.cc - * - * @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 file implements class MeanAggregator. - */ - -#include "tiledb/sm/query/readers/aggregators/mean_aggregator.h" - -#include "tiledb/sm/query/query_buffer.h" -#include "tiledb/sm/query/readers/aggregators/aggregate_buffer.h" - -namespace tiledb::sm { - -class MeanAggregatorStatusException : public StatusException { - public: - explicit MeanAggregatorStatusException(const std::string& message) - : StatusException("MeanAggregator", message) { - } -}; - -template -MeanAggregator::MeanAggregator(const FieldInfo field_info) - : OutputBufferValidator(field_info) - , field_info_(field_info) - , aggregate_with_count_(field_info) - , sum_(0) - , count_(0) - , validity_value_( - field_info_.is_nullable_ ? std::make_optional(0) : nullopt) - , sum_overflowed_(false) { - ensure_field_numeric(field_info_); -} - -template -void MeanAggregator::validate_output_buffer( - std::string output_field_name, - std::unordered_map& buffers) { - if (buffers.count(output_field_name) == 0) { - throw MeanAggregatorStatusException("Result buffer doesn't exist."); - } - - ensure_output_buffer_arithmetic(buffers[output_field_name]); -} - -template -void MeanAggregator::aggregate_data(AggregateBuffer& input_data) { - // TODO: While this could be shared with the sum implementation, it isn't - // because it will be improved soon... Means should always be able to be - // computed with no overflows. The simple formula is 2*(a/2 + b/2) + a%2 + - // b%2, but we need benchmarks to see what the performance hit would be to run - // this more complex formula (sc-32789). - - // Return if a previous aggregation has overflowed. - if (sum_overflowed_) { - return; - } - - try { - tuple::sum_type, uint64_t> res; - - // TODO: This is duplicated across aggregates but will go away with - // sc-33104. - if (input_data.is_count_bitmap()) { - res = aggregate_with_count_.template aggregate(input_data); - } else { - res = aggregate_with_count_.template aggregate(input_data); - } - - const auto value = std::get<0>(res); - const auto count = std::get<1>(res); - SafeSum().safe_sum(value, sum_); - count_ += count; - - // Here we know that if the count is greater than 0, it means at least one - // valid item was found, which means the result is valid. - if (field_info_.is_nullable_ && count) { - validity_value_ = 1; - } - } catch (std::overflow_error& e) { - sum_overflowed_ = true; - } -} - -template -void MeanAggregator::copy_to_user_buffer( - std::string output_field_name, - std::unordered_map& buffers) { - auto& result_buffer = buffers[output_field_name]; - auto s = static_cast(result_buffer.buffer_); - - if (sum_overflowed_) { - *s = std::numeric_limits::max(); - } else { - *s = static_cast(sum_) / count_; - } - - if (result_buffer.buffer_size_) { - *result_buffer.buffer_size_ = sizeof(double); - } - - if (field_info_.is_nullable_) { - auto v = static_cast(result_buffer.validity_vector_.buffer()); - if (sum_overflowed_) { - *v = 0; - } else { - *v = validity_value_.value(); - } - - if (result_buffer.validity_vector_.buffer_size()) { - *result_buffer.validity_vector_.buffer_size() = 1; - } - } -} - -// Explicit template instantiations -template MeanAggregator::MeanAggregator(const FieldInfo); -template MeanAggregator::MeanAggregator(const FieldInfo); -template MeanAggregator::MeanAggregator(const FieldInfo); -template MeanAggregator::MeanAggregator(const FieldInfo); -template MeanAggregator::MeanAggregator(const FieldInfo); -template MeanAggregator::MeanAggregator(const FieldInfo); -template MeanAggregator::MeanAggregator(const FieldInfo); -template MeanAggregator::MeanAggregator(const FieldInfo); -template MeanAggregator::MeanAggregator(const FieldInfo); -template MeanAggregator::MeanAggregator(const FieldInfo); - -} // namespace tiledb::sm diff --git a/tiledb/sm/query/readers/aggregators/mean_aggregator.h b/tiledb/sm/query/readers/aggregators/mean_aggregator.h deleted file mode 100644 index 96e38504188e..000000000000 --- a/tiledb/sm/query/readers/aggregators/mean_aggregator.h +++ /dev/null @@ -1,157 +0,0 @@ -/** - * @file mean_aggregator.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 file defines class MeanAggregator. - */ - -#ifndef TILEDB_MEAN_AGGREGATOR_H -#define TILEDB_MEAN_AGGREGATOR_H - -#include "tiledb/common/common.h" -#include "tiledb/sm/query/readers/aggregators/aggregate_with_count.h" -#include "tiledb/sm/query/readers/aggregators/field_info.h" -#include "tiledb/sm/query/readers/aggregators/iaggregator.h" -#include "tiledb/sm/query/readers/aggregators/safe_sum.h" -#include "tiledb/sm/query/readers/aggregators/sum_type.h" -#include "tiledb/sm/query/readers/aggregators/validity_policies.h" - -namespace tiledb::sm { - -class QueryBuffer; - -template -class MeanAggregator : public InputFieldValidator, - public OutputBufferValidator, - public IAggregator { - public: - /* ********************************* */ - /* CONSTRUCTORS & DESTRUCTORS */ - /* ********************************* */ - - MeanAggregator() = delete; - - /** - * Constructor. - * - * @param field_info Field info. - */ - MeanAggregator(FieldInfo field_info); - - DISABLE_COPY_AND_COPY_ASSIGN(MeanAggregator); - DISABLE_MOVE_AND_MOVE_ASSIGN(MeanAggregator); - - /* ********************************* */ - /* API */ - /* ********************************* */ - - /** Returns the field name for the aggregator. */ - std::string field_name() override { - return field_info_.name_; - } - - /** Returns if the aggregation is var sized or not. */ - bool aggregation_var_sized() override { - return false; - }; - - /** Returns if the aggregation is nullable or not. */ - bool aggregation_nullable() override { - return field_info_.is_nullable_; - } - - /** Returns if the aggregate needs to be recomputed on overflow. */ - bool need_recompute_on_overflow() override { - return true; - } - - /** - * Validate the result buffer. - * - * @param output_field_name Name for the output buffer. - * @param buffers Query buffers. - */ - void validate_output_buffer( - std::string output_field_name, - std::unordered_map& buffers) override; - - /** - * Aggregate data using the aggregator. - * - * @param input_data Input data for aggregation. - */ - void aggregate_data(AggregateBuffer& input_data) override; - - /** - * Copy final data to the user buffer. - * - * @param output_field_name Name for the output buffer. - * @param buffers Query buffers. - */ - void copy_to_user_buffer( - std::string output_field_name, - std::unordered_map& buffers) override; - - /** Returns name of the aggregate. */ - std::string aggregate_name() override { - return constants::aggregate_mean_str; - } - - /** Returns the TileDB datatype of the output field for the aggregate. */ - Datatype output_datatype() override { - return Datatype::FLOAT64; - } - - private: - /* ********************************* */ - /* PRIVATE ATTRIBUTES */ - /* ********************************* */ - - /** Field information. */ - const FieldInfo field_info_; - - /** AggregateWithCount to do summation of AggregateBuffer data. */ - AggregateWithCount::sum_type, SafeSum, NonNull> - aggregate_with_count_; - - /** Computed sum. */ - std::atomic::sum_type> sum_; - - /** Count of values. */ - std::atomic count_; - - /** Computed validity value. */ - optional validity_value_; - - /** Has the sum overflowed. */ - std::atomic sum_overflowed_; -}; - -} // namespace tiledb::sm - -#endif // TILEDB_MEAN_AGGREGATOR_H diff --git a/tiledb/sm/query/readers/aggregators/safe_sum.cc b/tiledb/sm/query/readers/aggregators/safe_sum.cc index ea74f2bfd515..e1f09924dfca 100644 --- a/tiledb/sm/query/readers/aggregators/safe_sum.cc +++ b/tiledb/sm/query/readers/aggregators/safe_sum.cc @@ -28,8 +28,6 @@ * @section DESCRIPTION * * This file implements class SafeSum. - * - * TODO: Testing for this class is not done (sc-33762). */ #include "tiledb/sm/query/readers/aggregators/safe_sum.h" diff --git a/tiledb/sm/query/readers/aggregators/sum_aggregator.cc b/tiledb/sm/query/readers/aggregators/sum_aggregator.cc index 53a0384fc8ac..21cb3647eb73 100644 --- a/tiledb/sm/query/readers/aggregators/sum_aggregator.cc +++ b/tiledb/sm/query/readers/aggregators/sum_aggregator.cc @@ -45,7 +45,7 @@ class SumAggregatorStatusException : public StatusException { }; template -SumAggregator::SumAggregator(const FieldInfo field_info) +SumWithCountAggregator::SumWithCountAggregator(const FieldInfo field_info) : OutputBufferValidator(field_info) , field_info_(field_info) , aggregate_with_count_(field_info) @@ -57,7 +57,7 @@ SumAggregator::SumAggregator(const FieldInfo field_info) } template -void SumAggregator::validate_output_buffer( +void SumWithCountAggregator::validate_output_buffer( std::string output_field_name, std::unordered_map& buffers) { if (buffers.count(output_field_name) == 0) { @@ -68,7 +68,7 @@ void SumAggregator::validate_output_buffer( } template -void SumAggregator::aggregate_data(AggregateBuffer& input_data) { +void SumWithCountAggregator::aggregate_data(AggregateBuffer& input_data) { // Return if a previous aggregation has overflowed. if (sum_overflowed_) { return; @@ -76,9 +76,6 @@ void SumAggregator::aggregate_data(AggregateBuffer& input_data) { try { tuple::sum_type, uint64_t> res; - - // TODO: This is duplicated across aggregates but will go away with - // sc-33104. if (input_data.is_count_bitmap()) { res = aggregate_with_count_.template aggregate(input_data); } else { @@ -88,6 +85,7 @@ void SumAggregator::aggregate_data(AggregateBuffer& input_data) { const auto value = std::get<0>(res); const auto count = std::get<1>(res); SafeSum().safe_sum(value, sum_); + count_ += count; // Here we know that if the count is greater than 0, it means at least one // valid item was found, which means the result is valid. @@ -99,6 +97,23 @@ void SumAggregator::aggregate_data(AggregateBuffer& input_data) { } } +template +void SumWithCountAggregator::copy_validity_value_to_user_buffers( + QueryBuffer& result_buffer) { + if (field_info_.is_nullable_) { + auto v = static_cast(result_buffer.validity_vector_.buffer()); + if (sum_overflowed_) { + *v = 0; + } else { + *v = validity_value_.value(); + } + + if (result_buffer.validity_vector_.buffer_size()) { + *result_buffer.validity_vector_.buffer_size() = 1; + } + } +} + template void SumAggregator::copy_to_user_buffer( std::string output_field_name, @@ -106,31 +121,61 @@ void SumAggregator::copy_to_user_buffer( auto& result_buffer = buffers[output_field_name]; auto s = static_cast::sum_type*>(result_buffer.buffer_); - if (sum_overflowed_) { + if (SumWithCountAggregator::sum_overflowed_) { *s = std::numeric_limits::sum_type>::max(); } else { - *s = sum_; + *s = SumWithCountAggregator::sum_; } if (result_buffer.buffer_size_) { *result_buffer.buffer_size_ = sizeof(typename sum_type_data::sum_type); } - if (field_info_.is_nullable_) { - auto v = static_cast(result_buffer.validity_vector_.buffer()); - if (sum_overflowed_) { - *v = 0; - } else { - *v = validity_value_.value(); - } + SumWithCountAggregator::copy_validity_value_to_user_buffers(result_buffer); +} - if (result_buffer.validity_vector_.buffer_size()) { - *result_buffer.validity_vector_.buffer_size() = 1; - } +template +void MeanAggregator::copy_to_user_buffer( + std::string output_field_name, + std::unordered_map& buffers) { + auto& result_buffer = buffers[output_field_name]; + auto s = static_cast(result_buffer.buffer_); + + if (SumWithCountAggregator::sum_overflowed_) { + *s = std::numeric_limits::max(); + } else { + *s = static_cast(SumWithCountAggregator::sum_) / + SumWithCountAggregator::count_; + } + + if (result_buffer.buffer_size_) { + *result_buffer.buffer_size_ = sizeof(double); } + + SumWithCountAggregator::copy_validity_value_to_user_buffers(result_buffer); } // Explicit template instantiations +template SumWithCountAggregator::SumWithCountAggregator( + const FieldInfo); +template SumWithCountAggregator::SumWithCountAggregator( + const FieldInfo); +template SumWithCountAggregator::SumWithCountAggregator( + const FieldInfo); +template SumWithCountAggregator::SumWithCountAggregator( + const FieldInfo); +template SumWithCountAggregator::SumWithCountAggregator( + const FieldInfo); +template SumWithCountAggregator::SumWithCountAggregator( + const FieldInfo); +template SumWithCountAggregator::SumWithCountAggregator( + const FieldInfo); +template SumWithCountAggregator::SumWithCountAggregator( + const FieldInfo); +template SumWithCountAggregator::SumWithCountAggregator(const FieldInfo); +template SumWithCountAggregator::SumWithCountAggregator( + const FieldInfo); + template SumAggregator::SumAggregator(const FieldInfo); template SumAggregator::SumAggregator(const FieldInfo); template SumAggregator::SumAggregator(const FieldInfo); @@ -142,4 +187,15 @@ template SumAggregator::SumAggregator(const FieldInfo); template SumAggregator::SumAggregator(const FieldInfo); template SumAggregator::SumAggregator(const FieldInfo); +template MeanAggregator::MeanAggregator(const FieldInfo); +template MeanAggregator::MeanAggregator(const FieldInfo); +template MeanAggregator::MeanAggregator(const FieldInfo); +template MeanAggregator::MeanAggregator(const FieldInfo); +template MeanAggregator::MeanAggregator(const FieldInfo); +template MeanAggregator::MeanAggregator(const FieldInfo); +template MeanAggregator::MeanAggregator(const FieldInfo); +template MeanAggregator::MeanAggregator(const FieldInfo); +template MeanAggregator::MeanAggregator(const FieldInfo); +template MeanAggregator::MeanAggregator(const FieldInfo); + } // namespace tiledb::sm diff --git a/tiledb/sm/query/readers/aggregators/sum_aggregator.h b/tiledb/sm/query/readers/aggregators/sum_aggregator.h index 0088f50fc389..14b5316e1c3d 100644 --- a/tiledb/sm/query/readers/aggregators/sum_aggregator.h +++ b/tiledb/sm/query/readers/aggregators/sum_aggregator.h @@ -45,25 +45,25 @@ namespace tiledb::sm { class QueryBuffer; template -class SumAggregator : public InputFieldValidator, - public OutputBufferValidator, - public IAggregator { +class SumWithCountAggregator : public InputFieldValidator, + public OutputBufferValidator, + public IAggregator { public: /* ********************************* */ /* CONSTRUCTORS & DESTRUCTORS */ /* ********************************* */ - SumAggregator() = delete; + SumWithCountAggregator() = delete; /** * Constructor. * * @param field_info Field info. */ - SumAggregator(FieldInfo field_info); + SumWithCountAggregator(FieldInfo field_info); - DISABLE_COPY_AND_COPY_ASSIGN(SumAggregator); - DISABLE_MOVE_AND_MOVE_ASSIGN(SumAggregator); + DISABLE_COPY_AND_COPY_ASSIGN(SumWithCountAggregator); + DISABLE_MOVE_AND_MOVE_ASSIGN(SumWithCountAggregator); /* ********************************* */ /* API */ @@ -106,6 +106,60 @@ class SumAggregator : public InputFieldValidator, */ void aggregate_data(AggregateBuffer& input_data) override; + /** + * Copy final validity value to the user buffer. + * + * @param result_buffer Query buffer to copy to. + */ + void copy_validity_value_to_user_buffers(QueryBuffer& result_buffer); + + protected: + /* ********************************* */ + /* PROTECTED ATTRIBUTES */ + /* ********************************* */ + + /** Field information. */ + const FieldInfo field_info_; + + /** AggregateWithCount to do summation of AggregateBuffer data. */ + AggregateWithCount::sum_type, SafeSum, NonNull> + aggregate_with_count_; + + /** Computed sum. */ + std::atomic::sum_type> sum_; + + /** Count of values. */ + std::atomic count_; + + /** Computed validity value. */ + optional validity_value_; + + /** Has the sum overflowed. */ + std::atomic sum_overflowed_; +}; + +template +class SumAggregator : public SumWithCountAggregator { + public: + /* ********************************* */ + /* CONSTRUCTORS & DESTRUCTORS */ + /* ********************************* */ + + SumAggregator() = delete; + + /** + * Constructor. + * + * @param field_info Field info. + */ + SumAggregator(FieldInfo field_info) + : SumWithCountAggregator(field_info) { + } + + /* ********************************* */ + /* API */ + /* ********************************* */ + /** * Copy final data to the user buffer. * @@ -125,27 +179,48 @@ class SumAggregator : public InputFieldValidator, Datatype output_datatype() override { return sum_type_data::tiledb_datatype; } +}; - private: +template +class MeanAggregator : public SumWithCountAggregator { + public: /* ********************************* */ - /* PRIVATE ATTRIBUTES */ + /* CONSTRUCTORS & DESTRUCTORS */ /* ********************************* */ - /** Field information. */ - const FieldInfo field_info_; + MeanAggregator() = delete; - /** AggregateWithCount to do summation of AggregateBuffer data. */ - AggregateWithCount::sum_type, SafeSum, NonNull> - aggregate_with_count_; + /** + * Constructor. + * + * @param field_info Field info. + */ + MeanAggregator(FieldInfo field_info) + : SumWithCountAggregator(field_info) { + } - /** Computed sum. */ - std::atomic::sum_type> sum_; + /* ********************************* */ + /* API */ + /* ********************************* */ + /** + * Copy final data to the user buffer. + * + * @param output_field_name Name for the output buffer. + * @param buffers Query buffers. + */ + void copy_to_user_buffer( + std::string output_field_name, + std::unordered_map& buffers) override; - /** Computed validity value. */ - optional validity_value_; + /** Returns name of the aggregate, e.g. COUNT, MIN, SUM. */ + std::string aggregate_name() override { + return constants::aggregate_mean_str; + } - /** Has the sum overflowed. */ - std::atomic sum_overflowed_; + /** Returns the TileDB datatype of the output field for the aggregate. */ + Datatype output_datatype() override { + return Datatype::FLOAT64; + } }; } // namespace tiledb::sm diff --git a/tiledb/sm/query/readers/aggregators/sum_type.h b/tiledb/sm/query/readers/aggregators/sum_type.h index ed2b77a0a682..11cf1403c8bb 100644 --- a/tiledb/sm/query/readers/aggregators/sum_type.h +++ b/tiledb/sm/query/readers/aggregators/sum_type.h @@ -28,8 +28,6 @@ * @section DESCRIPTION * * This file defines sum types in relation to basic types. - * - * TODO: This needs to be improved to remove macros (sc-33764). */ #ifndef TILEDB_SUM_TYPE_H diff --git a/tiledb/sm/query/readers/aggregators/test/unit_aggregators.cc b/tiledb/sm/query/readers/aggregators/test/unit_aggregators.cc index 354f89056525..f4fdd0538562 100644 --- a/tiledb/sm/query/readers/aggregators/test/unit_aggregators.cc +++ b/tiledb/sm/query/readers/aggregators/test/unit_aggregators.cc @@ -34,7 +34,6 @@ #include "tiledb/sm/query/query_buffer.h" #include "tiledb/sm/query/readers/aggregators/aggregate_buffer.h" #include "tiledb/sm/query/readers/aggregators/count_aggregator.h" -#include "tiledb/sm/query/readers/aggregators/mean_aggregator.h" #include "tiledb/sm/query/readers/aggregators/min_max_aggregator.h" #include "tiledb/sm/query/readers/aggregators/sum_aggregator.h"