github-actions[bot] commented on code in PR #16562: URL: https://github.com/apache/doris/pull/16562#discussion_r1125700371
########## be/src/vec/aggregate_functions/aggregate_function_quantile_state.cpp: ########## @@ -0,0 +1,37 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "vec/aggregate_functions/aggregate_function_quantile_state.h" + +#include "vec/aggregate_functions//aggregate_function_simple_factory.h" + +namespace doris::vectorized { + +AggregateFunctionPtr create_aggregate_function_quantile_state_union(const std::string& name, + const DataTypes& argument_types, + const Array& parameters, + const bool result_is_nullable) { + return std::make_shared< + AggregateFunctionQuantileStateOp<AggregateFunctionQuantileStateUnionOp, double>>( + argument_types); +} + +void register_aggregate_function_quantile_state(AggregateFunctionSimpleFactory& factory) { + factory.register_function("quantile_union", create_aggregate_function_quantile_state_union); Review Comment: warning: reference to type 'const doris::vectorized::AggregateFunctionSimpleFactory::Creator' (aka 'const function<shared_ptr<doris::vectorized::IAggregateFunction> (const basic_string<char> &, const vector<shared_ptr<const doris::vectorized::IDataType>> &, const bool)>') could not bind to an lvalue of type 'doris::vectorized::AggregateFunctionPtr (const std::string &, const doris::vectorized::DataTypes &, const doris::vectorized::Array &, const bool)' (aka 'shared_ptr<doris::vectorized::IAggregateFunction> (const basic_string<char> &, const vector<shared_ptr<const doris::vectorized::IDataType>> &, const doris::vectorized::Array &, const bool)') [clang-diagnostic-error] ```cpp factory.register_function("quantile_union", create_aggregate_function_quantile_state_union); ^ ``` **be/src/vec/aggregate_functions/aggregate_function_simple_factory.h:101:** passing argument to parameter 'creator' here ```cpp void register_function(const std::string& name, const Creator& creator, bool nullable = false) { ^ ``` ########## be/src/vec/aggregate_functions/aggregate_function_reader.cpp: ########## @@ -32,6 +32,7 @@ void register_aggregate_function_reader_load(AggregateFunctionSimpleFactory& fac register_function("min", create_aggregate_function_min); register_function("bitmap_union", create_aggregate_function_bitmap_union); register_function("hll_union", create_aggregate_function_HLL_union<false>); + register_function("quantile_union", create_aggregate_function_quantile_state_union); Review Comment: warning: no matching function for call to object of type '(lambda at /github/workspace/be/src/vec/aggregate_functions/aggregate_function_reader.cpp:25:30)' [clang-diagnostic-error] ```cpp register_function("quantile_union", create_aggregate_function_quantile_state_union); ^ ``` **be/src/vec/aggregate_functions/aggregate_function_reader.cpp:24:** candidate function not viable: no known conversion from 'doris::vectorized::AggregateFunctionPtr (const std::string &, const doris::vectorized::DataTypes &, const doris::vectorized::Array &, const bool)' (aka 'shared_ptr<doris::vectorized::IAggregateFunction> (const basic_string<char> &, const vector<shared_ptr<const doris::vectorized::IDataType>> &, const doris::vectorized::Array &, const bool)') to 'const doris::vectorized::AggregateFunctionCreator' (aka 'const function<shared_ptr<doris::vectorized::IAggregateFunction> (const basic_string<char> &, const vector<shared_ptr<const doris::vectorized::IDataType>> &, const bool)>') for 2nd argument ```cpp auto register_function = [&](const std::string& name, const AggregateFunctionCreator& creator) { ^ ``` ########## be/src/vec/aggregate_functions/aggregate_function_quantile_state.h: ########## @@ -0,0 +1,143 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include "util/quantile_state.h" +#include "vec/aggregate_functions/aggregate_function.h" +#include "vec/columns/column_complex.h" +#include "vec/columns/column_nullable.h" +#include "vec/common/assert_cast.h" +#include "vec/data_types/data_type_nullable.h" +#include "vec/data_types/data_type_number.h" +#include "vec/data_types/data_type_quantilestate.h" + +namespace doris::vectorized { + +struct AggregateFunctionQuantileStateUnionOp { + static constexpr auto name = "quantile_union"; + + template <typename T> + static void add(QuantileState<T>& res, const T& data, bool& is_first) { + res.add_value(data); + } + + template <typename T> + static void add(QuantileState<T>& res, const QuantileState<T>& data, bool& is_first) { + if (UNLIKELY(is_first)) { + res = data; + is_first = false; + } else { + res.merge(data); + } + } + + template <typename T> + static void merge(QuantileState<T>& res, const QuantileState<T>& data, bool& is_first) { + if (UNLIKELY(is_first)) { + res = data; + is_first = false; + } else { + res.merge(data); + } + } +}; + +template <typename Op, typename InternalType> +struct AggregateFunctionQuantileStateData { + using DataType = QuantileState<InternalType>; + DataType value; + bool is_first = true; + + template <typename T> + void add(const T& data) { + Op::add(value, data, is_first); + } + + void merge(const DataType& data) { Op::merge(value, data, is_first); } + + void write(BufferWritable& buf) const { + DataTypeQuantileState<InternalType>::serialize_as_stream(value, buf); + } + + void read(BufferReadable& buf) { + DataTypeQuantileState<InternalType>::deserialize_as_stream(value, buf); + } + + void reset() { is_first = true; } + + DataType& get() { return value; } +}; + +template <typename Op, typename InternalType> +class AggregateFunctionQuantileStateOp final + : public IAggregateFunctionDataHelper<AggregateFunctionQuantileStateData<Op, InternalType>, + AggregateFunctionQuantileStateOp<Op, InternalType>> { +public: + using ResultDataType = QuantileState<InternalType>; + using ColVecType = ColumnQuantileState<InternalType>; + using ColVecResult = ColumnQuantileState<InternalType>; + + String get_name() const override { return Op::name; } + + AggregateFunctionQuantileStateOp(const DataTypes& argument_types_) + : IAggregateFunctionDataHelper<AggregateFunctionQuantileStateData<Op, InternalType>, Review Comment: warning: no matching constructor for initialization of 'IAggregateFunctionDataHelper<AggregateFunctionQuantileStateData<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>, AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>>' [clang-diagnostic-error] ```cpp : IAggregateFunctionDataHelper<AggregateFunctionQuantileStateData<Op, InternalType>, ^ ``` **/usr/include/c++/11/ext/new_allocator.h:161:** in instantiation of member function 'doris::vectorized::AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>::AggregateFunctionQuantileStateOp' requested here ```cpp { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } ^ ``` **/usr/include/c++/11/bits/alloc_traits.h:515:** in instantiation of function template specialization '__gnu_cxx::new_allocator<doris::vectorized::AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>>::construct<doris::vectorized::AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>, const std::vector<std::shared_ptr<const doris::vectorized::IDataType>> &>' requested here ```cpp __a.construct(__p, std::forward<_Args>(__args)...); ^ ``` **/usr/include/c++/11/bits/shared_ptr_base.h:518:** in instantiation of function template specialization 'std::allocator_traits<std::allocator<doris::vectorized::AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>>>::construct<doris::vectorized::AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>, const std::vector<std::shared_ptr<const doris::vectorized::IDataType>> &>' requested here ```cpp allocator_traits<_Alloc>::construct(__a, _M_ptr(), ^ ``` **/usr/include/c++/11/bits/shared_ptr_base.h:650:** in instantiation of function template specialization 'std::_Sp_counted_ptr_inplace<doris::vectorized::AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>, std::allocator<doris::vectorized::AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>>, __gnu_cxx::_S_atomic>::_Sp_counted_ptr_inplace<const std::vector<std::shared_ptr<const doris::vectorized::IDataType>> &>' requested here ```cpp _Sp_cp_type(__a._M_a, std::forward<_Args>(__args)...); ^ ``` **/usr/include/c++/11/bits/shared_ptr_base.h:1341:** in instantiation of function template specialization 'std::__shared_count<__gnu_cxx::_S_atomic>::__shared_count<doris::vectorized::AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>, std::allocator<doris::vectorized::AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>>, const std::vector<std::shared_ptr<const doris::vectorized::IDataType>> &>' requested here ```cpp : _M_ptr(), _M_refcount(_M_ptr, __tag, std::forward<_Args>(__args)...) ^ ``` **/usr/include/c++/11/bits/shared_ptr.h:408:** in instantiation of function template specialization 'std::__shared_ptr<doris::vectorized::AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>, __gnu_cxx::_S_atomic>::__shared_ptr<std::allocator<doris::vectorized::AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>>, const std::vector<std::shared_ptr<const doris::vectorized::IDataType>> &>' requested here ```cpp : __shared_ptr<_Tp>(__tag, std::forward<_Args>(__args)...) ^ ``` **/usr/include/c++/11/bits/shared_ptr.h:861:** in instantiation of function template specialization 'std::shared_ptr<doris::vectorized::AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>>::shared_ptr<std::allocator<doris::vectorized::AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>>, const std::vector<std::shared_ptr<const doris::vectorized::IDataType>> &>' requested here ```cpp return shared_ptr<_Tp>(_Sp_alloc_shared_tag<_Alloc>{__a}, ^ ``` **/usr/include/c++/11/bits/shared_ptr.h:877:** in instantiation of function template specialization 'std::allocate_shared<doris::vectorized::AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>, std::allocator<doris::vectorized::AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>>, const std::vector<std::shared_ptr<const doris::vectorized::IDataType>> &>' requested here ```cpp return std::allocate_shared<_Tp>(std::allocator<_Tp_nc>(), ^ ``` **be/src/vec/aggregate_functions/aggregate_function_quantile_state.cpp:27:** in instantiation of function template specialization 'std::make_shared<doris::vectorized::AggregateFunctionQuantileStateOp<doris::vectorized::AggregateFunctionQuantileStateUnionOp, double>, const std::vector<std::shared_ptr<const doris::vectorized::IDataType>> &>' requested here ```cpp return std::make_shared< ^ ``` **be/src/vec/aggregate_functions/aggregate_function.h:380:** candidate constructor not viable: requires single argument 'argument_types_', but 2 arguments were provided ```cpp IAggregateFunctionDataHelper(const DataTypes& argument_types_) ^ ``` **be/src/vec/aggregate_functions/aggregate_function.h:370:** candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided ```cpp class IAggregateFunctionDataHelper : public IAggregateFunctionHelper<Derived> { ^ ``` **be/src/vec/aggregate_functions/aggregate_function.h:370:** candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided ```cpp class IAggregateFunctionDataHelper : public IAggregateFunctionHelper<Derived> { ^ ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org